-
Notifications
You must be signed in to change notification settings - Fork 37
Bootstrap test data from JSON fixtures instead of SQL migrations #802
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
Bootstrap test data from JSON fixtures instead of SQL migrations #802
Conversation
4d9f371 to
0a80643
Compare
this is more consistent with e.g. the 'locations' option for flyway
This allows us to include the prefix in the config, which is more flexible. For example, we can set file:fixtures for the default fixtures, which need to be overridable in the docker container, and we can set classpath:test-fixtures for the test fixtures, which can then be included in the test/resources dir. Moreover, this approach is similar to the way flyway.locations are specified.
the populator is done, but that does not necessarily mean any repositories were actually populated
This reverts commit 1ac2639.
* include root logger AppenderRef, so we only need to change the log level, when required * rename test logging config file for clarity and conformance to log4j2 best practices
0739c42 to
caddb3d
Compare
dd7d2df to
a1e6c8c
Compare
…ault 02xx fixtures
|
For testing it would be convenient to have the ability to select specific fixtures files or filter fixture files. We should allow passing complete ant-style patterns. This way we could do things like Also see PathMatchingResourcePatternResolver and AntPathMatcher for examples. |
|
In case we ever need to override or extend the default bootstrap locations from @TestPropertySource(properties = {
"bootstrap.locations[0]=file:fixtures",
"bootstrap.locations[1]=file:some/other/location"
})Note that this overrides the default location list, instead of extending it, so we need to add the default locations explicitly if needed. |
|
Warning Apparently there are foreign key cascades in place for objects related to user accounts (and probably other relations as well?). As a result, when a fixture replaces an existing record (e.g. from a fixture applied earlier) by using the same uuid, all related objects are removed automatically. For example, adding a test fixture that modifies the default Albert Einstein user account causes all existing api-keys and saved-queries for that user to be deleted silently. |
this enables us to specify simple directories, specific files, filters like 'fixtures/02*.json', and wildcards like 'fixtures/**/*.json'
the Path methods caused errors on windows if the location included ':' or '*' characters
description said Nikola Tesla, but uuid was for Albert Einstein
…ure data changed uuid and type for SearchSavedQuery objects to minimize interference with the existing acceptance tests
Due to the addition of DatabaseBootstrapTests, fixture 0130_test-users-with-api-keys-and-saved-queries.json now includes two new SearchSavedQuery objects. One of these new objects replaces the other, so the total number of SearchSavedQuery objects expected in the test database is increased by one.
05d7172 to
ce810ea
Compare
Although I prefer .org, existing docs and tests expect .com. Also it will likely lead to confusion because people will keep trying to log in using the .com addresses.
de8c19c to
7682cd4
Compare
| // re-populate the database using fixtures | ||
| populator.populate(new Repositories(applicationContext)); | ||
| // re-migrate acl data | ||
| // (TODO: AclMigration is in a subfolder of rdf/migration, but is it even related to rdf? Looks relational...) |
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.
That is indeed strange... it was probably there due to close relation to RDF records (it specifies access to an RDF records, but the ACL itself is relational - used to be in Mongo previously).
| @TestConfiguration | ||
| public class MetadataTestConfig { | ||
|
|
||
| // TODO: Looks like we can remove this class altogether. |
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.
👍🏻
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.
Decided to move the annotation cleanup to a separate PR because there's more than expected.
I reset this branch by a few commits and did a force-push, which is a bit messy, sorry for that.
7682cd4 to
2341d09
Compare
Replace SQL test data migrations by JSON test data fixtures.