-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added TestExport to avoid creating unstructured json, fixes #860 #1212
Conversation
96a1977
to
45d0d74
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments;
-
Please can we have some user docs for test export/import?
-
One thought, how do we handle different versions of test import/export? Or how would we in the future? One significant impact of this change is that we are bound to one version of an exported test for the version of Horreum running, so say you could not export a test from Horreum 0.11.1 and import into 0.13.4 if the test data structure changes between releases.
The old API would allow users to upload the json payload an Horreum had the ability to perform some form of check, but with this change we would return a HTTP 400 bad request if the JSON did not deserialise to a valid TestExport.
I think we should consider backwards compatibility between Horreum Versions. I am not saying we should make import/export backwards compatible now, but leave the possibility of supporting it in the future
- We need to consider datastores? The default datastore is fine, but what about a Test with an Elastic backend etc? We either need to throw an error, or tell the user to configure a datastore first, or serialize datastore with the test. Serializing the datastore would require careful consideration about how to handle API tokens
horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/TestService.java
Show resolved
Hide resolved
horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/TestService.java
Outdated
Show resolved
Hide resolved
horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ActionServiceImpl.java
Outdated
Show resolved
Hide resolved
Please can you open an issue to track this |
Yes!
In reality there is no difference, before this change if someone would send a json that did not deserialize to a Test + the additional fields it would fail. With this change the JSON is a bit different, but it is typed and we avoid custom (de)serialization as it's handled by Quarkus.
With using TestExport we can add additional fields later on and it would still work with older version.
I have not considered datastores at all tbh, we could also add datastores to TestExport...? |
Under the hood Quarkus is using ObjectMapper to serialize/deserialize to/from json, we can still do the same without the custom deserialization. We can still enforce the type on the API, accepting different versions of concrete types. If we don't we are locking an instance of Horreum to only accept Tests exported from another Horreum instance that has exported the same TestExport entity. Adding fields might be fine, but if we remove required fields, change their type, or change the relationship between the test and other entities then it will break. At the moment, we are effectively writing the DB structure to JSON. I don't see that staying stable between Horreum versions, and a change to the API to something like this, would still provide type safety, but give us the opportunity to evolve the entity graph contained in TestExport, whilst also supporting backward compatibility;
|
We could, but how do we handle the secrets? This relates to secrets in the existing export as well. We can't encrypt/decrypt between Horreum instances that have different We might not want to handle that problem in this PR, so we could just add Datastore to the output and open another issue to handle secrets in the exported TestExport definition |
I think that's a fair limitation actually :)
Yes, and as I answered above it's a fair limitation imo, but I see your point.
Yes, I also see that changing in the not too distant future. What we then will end up with is a lot of parsing logic to support "old" versions of Horreum none might use... |
Yeah, that's a good suggestion. |
Ok, let us flip it round another way.. We have so far said that the REST API needs to be stable between major versions. What we are now saying is that the REST API AND the DB schema needs to stay stable for a major version, if we make a change to the TestExport entity graph, we need to cut a new "major" version. |
Parsing logic does not need to be complicated, it could be something like:
The might be custom Mapping code, but we could have a base abstract Mapping for a major version, and the subclasses could override only where there has been minor changes. |
@stalep I am not suggesting that we implement versioning now, but right now what we can do is change;
to
With the API configured as;
This would not lock the API into a particular version and we get all the benefits of type safety and auto parsing |
Ah, you might have misunderstood. Now in main, experiments&comparisons are not working correctly. #860 is tracking that. With this pr it all works (I think). |
Ah, sorry, I interpreted |
Ok, you convinced me :) |
Good point, I think returning TestExport would be better. |
203f9d3
to
ec340b1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks great, I think just some things to clean up with the docs and the openAPI spec, and ofc package-lock.json
:(
horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/SchemaExport.java
Outdated
Show resolved
Hide resolved
horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/TestExport.java
Outdated
Show resolved
Hide resolved
horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/TestService.java
Outdated
Show resolved
Hide resolved
horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/SchemaService.java
Outdated
Show resolved
Hide resolved
cb16294
to
306ec3b
Compare
horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/SchemaService.java
Outdated
Show resolved
Hide resolved
horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/services/TestService.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Merged. Thanks a lot for your contribution |
Importing new test should work now correctly. Currently Experiments&/Comparisons are not correctly imported.
fixes #860