test: share the aws_accounts and aws_connect_sessions fixture tables - #173
Merged
Merged
Conversation
Six backend suites each created these tables when missing and dropped them on the way out. Suites run in parallel workers against one database, so one suite's teardown could remove a table another suite was still using. Both tables now come from the shared fixture helper, which creates them under a transaction-scoped advisory lock and never drops them. Every suite's definition was identical, so the helper carries that definition unchanged. Each suite deletes only the rows it created. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Test-only change. No production code, migration, schema or CI workflow is touched.
The race. Six backend suites each created
aws_accounts(and two of themaws_connect_sessions) when the table was missing, then dropped whatever they had created inafterAll. Jest runs suites in parallel workers against one database, so a suite finishing first could drop a table another suite was still using. This is the same pattern #171 removed forapi_keysandsso_configurations.The change. Both tables move into
backend/src/routes/__tests__/shared-fixture-tables.tsand follow its existing pattern:CREATE TABLE IF NOT EXISTSinside a transaction holdingpg_advisory_xact_lock, client released infinally. No suite drops either table any more. Each suite deletes only rows for the organizations it created.Definitions. Before moving anything, every suite's
CREATE TABLEwas compared after whitespace normalisation:aws_accountsaws_connect_sessionsThe helper carries those definitions unchanged (same columns, types, defaults, primary keys and the two named unique constraints on
aws_accounts)..github/scripts/ci-bootstrap-schema.jsdefines neither table, so there was nothing to reconcile against it.Affected suites
routes/__tests__/aws-connection-funnel-event.test.tsroutes/__tests__/aws-connection-api-key-authorization.test.tsservices/__tests__/system-intelligence.service.cost-score.test.tsservices/__tests__/aws-cost-freshness.test.tsservices/__tests__/cloudwatch.service.fleet-pagination.test.tsservices/__tests__/cloudwatch.service.concurrency.test.tsOne behavioural note:
aws-connection-funnel-event.test.tspreviously relied on the table drop to clear its rows. It now deletes its ownaws_accounts/aws_connect_sessionsrows by organization id.Verification
All runs used a fresh local database built with
.github/scripts/ci-bootstrap-schema.js(48 migrations; both tables absent afterwards). Local Postgres is 15; CI uses 14.--maxWorkers=6, 8 rounds, both tables dropped before every round: 8/8 rounds pass, 6 suites / 68 tests each. Norelation ... does not exist, no duplicate-key or constraint errors, and 0 rows left in either table after every round.CREATE TABLE IF NOT EXISTSand no lock rejected 460 of 960 calls (pg_type_typname_nsp_index), which is the failure the lock prevents.tsc --noEmit(backend): clean.--maxWorkers=4: 186 of 187 suites pass, 3014 of 3016 tests. The two failures are both inservices/__tests__/migrate-deploy.test.ts("Case F" symlink cases). That suite runs a shell script and uses no database; it fails the same way when run on its own and is not touched here.Type of Change
Checklist
🤖 Generated with Claude Code