feat: add deployment failure scenarios test #153
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Test deployment failure scenarios and rollback behavior
Summary
This PR investigates what happens to the LaunchQL migration database when SQL changes fail during deployment. It adds comprehensive tests for both transaction-based and non-transaction deployment modes using constraint violations as the failure mechanism.
Key findings:
launchql_migrate.eventstableImplementation details:
deploy-failure-scenarios.test.tswith 3 test casesgetMigrationState()method toMigrateTestFixtureclass that queries timestamp fields for chronological ordering but removes them from snapshots to avoid CI timestamp mismatchesTestDatabaseinterface to include the new methodDEPLOYMENT_FAILURE_ANALYSIS.mdReview & Testing Checklist for Human
getMigrationState()actually returns data ordered bydeployed_at/occurred_attimestamps as intendedgetMigrationState()works correctly and doesn't break other functionalityTestDatabaseinterface to ensure no regressions were introducedRecommended test plan: Run
yarn test deploy-failure-scenarios.test.tslocally with a fresh PostgreSQL setup, then manually trigger some deployment failures in a test environment to verify the documented behavior.Diagram
%%{ init : { "theme" : "default" }}%% graph TD TestFile["deploy-failure-scenarios.test.ts<br/>New test file"]:::major-edit MigrateFixture["MigrateTestFixture.ts<br/>Added getMigrationState()"]:::major-edit TestDB["TestDatabase.ts<br/>Updated interface"]:::minor-edit Snapshots["__snapshots__/<br/>deploy-failure-scenarios.test.ts.snap<br/>New snapshots"]:::major-edit Analysis["DEPLOYMENT_FAILURE_ANALYSIS.md<br/>Documentation"]:::major-edit TestFile --> MigrateFixture TestFile --> TestDB TestFile --> Snapshots TestFile --> Analysis MigrateFixture --> TestDB subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
getMigrationState()method was moved from the test file toMigrateTestFixtureper user request to keep test code clean and minimalSession details: Requested by Dan Lynch (@pyramation) - Link to Devin run