Skip to content
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

Introduce shared context for migrations and add documentation #3407

Merged
merged 1 commit into from
Sep 28, 2023

Conversation

FloThinksPi
Copy link
Member

@FloThinksPi FloThinksPi commented Aug 24, 2023

Previously a migration was only tested by reverting (running down migrations) until being one migration before the one that shall be tested, then executing the actual test in which all migrations run the up part even of migrations that come after the migration one wants to test.

This commit introduces the 'migration' shared context, a valuable utility for Sequel migration testing. This new module reverts the database schema to its version prior to a specific migration, provides a directory with the migration file for running a given migration in a test, and restores the schema to its full state after test completion to avoid half-migrated database scenarios. Hereby only the up part of the migration one wants to test is executed opposite to all available
migrations to construct a meaningful test case.

The accompanying updates to the documentation elaborate on the distinctive operating nature of Sequel migration tests. Also extensive documentation on Sequel migrations itself in the scope of the supported dbs and cloud_controller_ng has been added to provide a good knowledge base for writing highly sophisticated migrations that are resilient, offer high level of consistency, are compatible with mysql and psql and fast.

Constraints and restrictions on Sequel migrations and test writing have also been detailed, stressing the need to exclude Cloud Controller code in migrations and tests to maintain consistency in test outcomes and behaviours.

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

@FloThinksPi FloThinksPi force-pushed the db_migration_test_framework branch from d3e347a to 39795c4 Compare September 4, 2023 14:18
@FloThinksPi FloThinksPi requested a review from a team September 5, 2023 13:16
@FloThinksPi FloThinksPi force-pushed the db_migration_test_framework branch from 39795c4 to 8dd73dc Compare September 6, 2023 09:20
@FloThinksPi FloThinksPi changed the title Introduce MigrationMixin and document Sequel migration tests Introduce MigrationMixin and document migration and tests Sep 6, 2023
@FloThinksPi FloThinksPi force-pushed the db_migration_test_framework branch 2 times, most recently from cd91acd to 3bd3ee7 Compare September 6, 2023 09:33
@philippthun
Copy link
Member

Here is the existing CAPI-Migration-Style-Guide. We should merge the contents and decide for a single location (and reference it from the other location).

@FloThinksPi FloThinksPi force-pushed the db_migration_test_framework branch 5 times, most recently from dcb0ab4 to f1eb75a Compare September 14, 2023 11:26
spec/migrations/Readme.md Outdated Show resolved Hide resolved
spec/migrations/Readme.md Outdated Show resolved Hide resolved
spec/migrations/Readme.md Outdated Show resolved Hide resolved
spec/migrations/Readme.md Outdated Show resolved Hide resolved
spec/migrations/Readme.md Outdated Show resolved Hide resolved
spec/migrations/Readme.md Outdated Show resolved Hide resolved
spec/migrations/Readme.md Outdated Show resolved Hide resolved
spec/migrations/Readme.md Outdated Show resolved Hide resolved
spec/migrations/Readme.md Show resolved Hide resolved
spec/migrations/Readme.md Outdated Show resolved Hide resolved
spec/migrations/Readme.md Outdated Show resolved Hide resolved
@philippthun philippthun force-pushed the db_migration_test_framework branch from 31068cc to 45c49e7 Compare September 26, 2023 15:26
Previously a migration was only tested by reverting (running down
migrations) until being one migration before the one that shall be
tested, then executing the actual test in which all migrations run the
up part even of migrations that come after the migration one wants to
test.

This commit introduces the 'migration' shared context, a valuable
utility for Sequel migration testing. This new module reverts the
database schema to its version prior to a specific migration, provides a
directory with the migration file for running a given migration in a
test, and restores the schema to its full state after test completion to
avoid half-migrated database scenarios. Hereby only the up part of the
migration one wants to test is executed opposite to all available
migrations to construct a meaningful test case.

The accompanying updates to the documentation elaborate on the
distinctive operating nature of Sequel migration tests. Also extensive
documentation on Sequel migrations itself in the scope of the supported
dbs and cloud_controller_ng has been added to provide a good knowledge
base for writing highly sophisticated migrations that are resilient,
offer high level of consistency, are compatible with mysql and psql and
fast.

Constraints and restrictions on Sequel migrations and test writing have
also been detailed, stressing the need to exclude Cloud Controller code
in migrations and tests to maintain consistency in test outcomes and
behaviours.

Co-authored-by: Philipp Thun <[email protected]>
@philippthun philippthun force-pushed the db_migration_test_framework branch from 45c49e7 to 2ba8386 Compare September 27, 2023 15:16
@philippthun philippthun changed the title Introduce MigrationMixin and document migration and tests Introduce shared context for migrations and add documentation Sep 27, 2023
@FloThinksPi FloThinksPi merged commit a65922d into main Sep 28, 2023
@FloThinksPi FloThinksPi deleted the db_migration_test_framework branch September 28, 2023 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants