Skip to content

test: give each fixture its own Postgres database#52

Merged
Theauxm merged 4 commits intomainfrom
test/isolate-postgres-dbs-per-fixture
May 5, 2026
Merged

test: give each fixture its own Postgres database#52
Theauxm merged 4 commits intomainfrom
test/isolate-postgres-dbs-per-fixture

Conversation

@Theauxm
Copy link
Copy Markdown
Member

@Theauxm Theauxm commented May 5, 2026

Summary

  • Split the three Tests.Integration fixtures onto separate Postgres databases (trax_scheduler_default_submitter, trax_scheduler_builder_validation, trax_scheduler_builder_settings).
  • Add a CI step that CREATE DATABASEs each before the test run.

NUnit runs fixtures in parallel within an assembly. All three were sharing trax_scheduler_tests and each runs DatabaseMigrator.Migrate in OneTimeSetUp. When two fixtures hit the migrator advisory lock at the same time one can time out with an Npgsql operation-timeout. We saw this on Trax.Api on main; pre-empting it here. Per-DB isolation removes the contention without serializing the suite.

Test plan

  • Local: full Trax.Scheduler test suite passes (951 / 951)
  • CI: pull_request workflow green

Theauxm added 4 commits May 5, 2026 10:04
Three Tests.Integration fixtures (DefaultJobSubmitter, SchedulerBuilderValidation,
SchedulerConfigurationBuilderSettings) all migrated and ran against
trax_scheduler_tests. NUnit runs fixtures in parallel, so two could enter
DatabaseMigrator.Migrate at once, contend on the migrator advisory lock, and
one would time out with an Npgsql operation-timeout. We've seen this same
class of flake on Trax.Api; pre-empting it here.

Split each fixture onto its own DB and have CI psql CREATE DATABASE for
each before tests run.
…cheduler delayed-trigger / typed ScheduleOnce paths
The CREATE DATABASE bootstrap step was connecting via -d trax, but the
container's POSTGRES_DB is trax_scheduler_tests, so psql failed with
'database "trax" does not exist'. Switch the bootstrap connection to
the seed DB the container actually creates. Per-fixture DBs (and their
isolation) are unchanged.
@Theauxm Theauxm merged commit 7e2ea62 into main May 5, 2026
1 check passed
@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

@Theauxm Theauxm deleted the test/isolate-postgres-dbs-per-fixture branch May 5, 2026 17:11
@traxsharp
Copy link
Copy Markdown

traxsharp Bot commented May 8, 2026

This PR is included in version 1.29.0

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.

1 participant