1. Arrange pipeline stages
- Validate code and migration files with fast static checks.
- Provision a disposable database matching the supported engine/version.
- Apply all migrations from empty and from the prior supported revision.
- Load deterministic fixtures and run SQL, constraint, and repository tests.
- Run API/integration tests and targeted security assertions.
- Run bounded performance checks in a separately controlled job if needed.
- Publish sanitized results and logs, then destroy the database and verify cleanup.
2. Make the job fail safely
# Pipeline pseudocode; replace with your CI system's supported syntax.
set environment = "test"
assert database host is an approved ephemeral test target
provision pinned database engine and version
apply migrations; stop immediately on error
run tests with explicit timeouts
save sanitized diagnostics when tests fail
destroy only resources created by this pipeline run
verify resource cleanupThis is intentionally tool-neutral pseudocode, not a shell script. Implement cleanup in a guaranteed CI finalization step and scope cloud permissions to the specific test resources. Never pass production credentials into a test job.
3. Add reliable assertions and artifacts
Test results should identify the test, migration revision, engine version, environment, and failure point. Preserve sanitized logs, assertion diffs, and timing data with limited retention. Distinguish a product regression from an unavailable runner or database startup failure; neither should be reported as a passing test.
4. Capstone: order checkout release gate
- Create isolated customer, inventory, and order fixtures.
- Assert checkout creates one order, reduces inventory once, and records expected totals.
- Assert insufficient stock and invalid customer cases leave no partial writes.
- Retry the same idempotency key and assert no duplicate order or inventory change.
- Apply schema migrations from clean and previous-version states and verify existing data.
- Run a coordinated two-connection test and assert inventory never becomes negative.
- Check the query path under representative load in an approved performance environment.
- Confirm cleanup, capture results, and block release for any failed required assertion.
Release checklist
- Tests use the real target database engine for database-specific behavior.
- Targets and credentials are explicit, isolated, and least-privilege.
- Fixtures are deterministic, synthetic, and safely cleaned up.
- Migrations are tested from every supported starting point.
- Failure diagnostics are useful but contain no secrets or uncontrolled sensitive data.
- Timeouts, retry behavior, cleanup, ownership, and pass/fail policy are documented.
Progress stays in this browser.