-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve the detection of schema changes and add tests (#715)
* Start to generalize schema evolution checking * Add basic test setup for running detection script tests * Make the checking script exit with non-zero for errors * Add detection for vector member additions * Add more tests for detecting changes to VectorMembers * Add (failing) tests related to relation schema changes * Add detection of relation schema changes * Remove unnecessary named variable * Simplify logic and re-use messages from SchemaChanges * Harmonize messages with the YAML grammar * Change import order to make pylint happy
- Loading branch information
Showing
28 changed files
with
410 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
set(should_fail_cases | ||
vector_members:add_new | ||
vector_members:add_additional | ||
vector_members:rm_one | ||
relations:new_single_relation | ||
relations:rm_single_relation | ||
relations:new_multi_relation | ||
relations:rm_multi_relation | ||
relations:mv_single_to_multi | ||
relations:mv_multi_to_single | ||
) | ||
|
||
set(should_succeed_cases | ||
members:float_to_double | ||
) | ||
|
||
set(should_warn_cases | ||
members:rename | ||
) | ||
|
||
foreach(test_case IN LISTS should_fail_cases should_succeed_cases should_warn_cases) | ||
add_test(NAME schema_evol:detection:${test_case} COMMAND ${CMAKE_CURRENT_LIST_DIR}/run_test_case.sh ${test_case}) | ||
PODIO_SET_TEST_ENV(schema_evol:detection:${test_case}) | ||
endforeach() | ||
|
||
foreach(test_case IN LISTS should_fail_cases) | ||
set_property(TEST schema_evol:detection:${test_case} PROPERTY WILL_FAIL true) | ||
endforeach() | ||
|
||
foreach(test_case IN LISTS should_warn_cases) | ||
set_property(TEST schema_evol:detection:${test_case} PROPERTY PASS_REGULAR_EXPRESSION "Warnings:") | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# *Detection* tests for `podio_schema_evolution.py` | ||
|
||
This folder contains small and targetted test cases to ensure that the | ||
`podio_schema_evolution.py` script reliably detects schema changes that are not | ||
trivial. These test cases only deal with detecting these occurences! Whether the | ||
detected schema evolution steps are supported by podio (yet) are not really | ||
interesting here and they (will be) tested in another place. | ||
|
||
## Setup of the tests | ||
|
||
In order to allow for some minimal form of automation and to avoid too much | ||
boilerplate the test cases are grouped into categories. Each category then has | ||
several *unit test like* setups where each test covers exactly one schema | ||
change. Each subfolder in this directory represents a category. In each | ||
subfolder there are for each test case (i.e. schema change) exactly two yaml | ||
files with the (minimal) schemas that have an example of the change. To allow | ||
for test automation these yaml files need to follow the naming convention | ||
`dm_<test-case-name>_{old,new}.yaml`, where the `old` yaml file needs to have a | ||
lower `schema_version` than the `new` yaml file. | ||
|
||
The `run_test_case.sh` script takes one argument in the form of | ||
`<category-name>:<test-case-name>`. It constructs the necessary file names from | ||
this input and then runs the `podio_schema_evolution.py` script on them. | ||
|
||
Finally, in the `CMakeLists.txt` file here, it is simply necessary to add new | ||
test cases to the `should_fail_cases`, `should_succeed_cases` or | ||
`should_warn_cases` lists and they will be automatically picked up. |
8 changes: 8 additions & 0 deletions
8
tests/schema_evolution/detection/members/dm_float_to_double_new.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
schema_version: 2 | ||
|
||
datatypes: | ||
TypeWithFloat: | ||
Description: "A type with a double that was a float" | ||
Author: "Thomas Madlener" | ||
Members: | ||
- double f // a float to become a double |
8 changes: 8 additions & 0 deletions
8
tests/schema_evolution/detection/members/dm_float_to_double_old.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
schema_version: 1 | ||
|
||
datatypes: | ||
TypeWithFloat: | ||
Description: "A type with a float that will become a double" | ||
Author: "Thomas Madlener" | ||
Members: | ||
- float f // a float to become a double |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
schema_version: 3 | ||
|
||
datatypes: | ||
TypeWithRenamedMember: | ||
Description: "A type with a renamed member" | ||
Author: "Thomas Madlener" | ||
Members: | ||
- int newName // the new name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
schema_version: 1 | ||
|
||
datatypes: | ||
TypeWithRenamedMember: | ||
Description: "A type with a member that will be renamed" | ||
Author: "Thomas Madlener" | ||
Members: | ||
- int oldName // the old name |
12 changes: 12 additions & 0 deletions
12
tests/schema_evolution/detection/relations/dm_mv_multi_to_single_new.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
schema_version: 2 | ||
|
||
datatypes: | ||
RelatedType: | ||
Description: "A type we use in the relation" | ||
Author: "Thomas Madlener" | ||
|
||
DataTypeWithRelationMigration: | ||
Description: "Type for testing the move from a OneToMany to a OneToOne relation" | ||
Author: "Thomas Madlener" | ||
OneToOneRelations: | ||
- RelatedType rel // a relation |
12 changes: 12 additions & 0 deletions
12
tests/schema_evolution/detection/relations/dm_mv_multi_to_single_old.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
schema_version: 1 | ||
|
||
datatypes: | ||
RelatedType: | ||
Description: "A type we use in the relation" | ||
Author: "Thomas Madlener" | ||
|
||
DataTypeWithRelationMigration: | ||
Description: "Type for testing the move from a OneToMany to a OneToOne relation" | ||
Author: "Thomas Madlener" | ||
OneToManyRelations: | ||
- RelatedType rel // a relation |
12 changes: 12 additions & 0 deletions
12
tests/schema_evolution/detection/relations/dm_mv_single_to_multi_new.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
schema_version: 2 | ||
|
||
datatypes: | ||
RelatedType: | ||
Description: "A type we use in the relation" | ||
Author: "Thomas Madlener" | ||
|
||
DataTypeWithRelationMigration: | ||
Description: "Type for testing the move from a OneToOne to a OneToMany relation" | ||
Author: "Thomas Madlener" | ||
OneToManyRelations: | ||
- RelatedType rel // a relation |
12 changes: 12 additions & 0 deletions
12
tests/schema_evolution/detection/relations/dm_mv_single_to_multi_old.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
schema_version: 1 | ||
|
||
datatypes: | ||
RelatedType: | ||
Description: "A type we use in the relation" | ||
Author: "Thomas Madlener" | ||
|
||
DataTypeWithRelationMigration: | ||
Description: "Type for testing the move from a OneToOne to a OneToMany relation" | ||
Author: "Thomas Madlener" | ||
OneToOneRelations: | ||
- RelatedType rel // a relation |
12 changes: 12 additions & 0 deletions
12
tests/schema_evolution/detection/relations/dm_new_multi_relation_new.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
schema_version: 2 | ||
|
||
datatypes: | ||
RelatedType: | ||
Description: "A type we use in the relation" | ||
Author: "Thomas Madlener" | ||
|
||
DataTypeWithNewMultiRelation: | ||
Description: "Type for testing the addition of new OneToManyRelations" | ||
Author: "Thomas Madlener" | ||
OneToManyRelations: | ||
- RelatedType rel // a new relation |
10 changes: 10 additions & 0 deletions
10
tests/schema_evolution/detection/relations/dm_new_multi_relation_old.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
schema_version: 1 | ||
|
||
datatypes: | ||
RelatedType: | ||
Description: "A type we use in the relation" | ||
Author: "Thomas Madlener" | ||
|
||
DataTypeWithNewMultiRelation: | ||
Description: "Type for testing the addition of new OneToManyRelations" | ||
Author: "Thomas Madlener" |
12 changes: 12 additions & 0 deletions
12
tests/schema_evolution/detection/relations/dm_new_single_relation_new.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
schema_version: 2 | ||
|
||
datatypes: | ||
RelatedType: | ||
Description: "A type we use in the relation" | ||
Author: "Thomas Madlener" | ||
|
||
DataTypeWithNewSingleRelation: | ||
Description: "Type for testing the addition of new OneToOneRelations" | ||
Author: "Thomas Madlener" | ||
OneToOneRelations: | ||
- RelatedType rel // a new relation |
10 changes: 10 additions & 0 deletions
10
tests/schema_evolution/detection/relations/dm_new_single_relation_old.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
schema_version: 1 | ||
|
||
datatypes: | ||
RelatedType: | ||
Description: "A type we use in the relation" | ||
Author: "Thomas Madlener" | ||
|
||
DataTypeWithNewSingleRelation: | ||
Description: "Type for testing the addition of new OneToOneRelations" | ||
Author: "Thomas Madlener" |
Oops, something went wrong.