Skip to content

Run DB integration tests concurrently#2134

Draft
sgillespie wants to merge 4 commits into
IntersectMBO:masterfrom
sgillespie:feature/concurrent-tests
Draft

Run DB integration tests concurrently#2134
sgillespie wants to merge 4 commits into
IntersectMBO:masterfrom
sgillespie:feature/concurrent-tests

Conversation

@sgillespie

Copy link
Copy Markdown
Contributor

Description

Run top-level test groups concurrently

The DB integration test suite now runs the groups concurrently:

  • Alonzo-era
  • Babbage-era
  • Conway-era
  • QSM (QuickCheck State Machine)

Concurrent tests cannot share a database, so each group has its own
copy. Grouping at the top level keeps the databases/threads manageable.

Note that this is the first iteration of parallelizing the tests. It results in a roughly 50% decrease in total execution time. However, this approach cannot scale anymore, because the floor is the Conway test, which takes at least 6 minutes.

In the future, we will probably want to use a database pool aquire/release pattern.

Checklist

  • Commit sequence broadly makes sense
  • Commits have useful messages
  • New tests are added if needed and existing tests are updated
  • Any changes are noted in the changelog
  • Code is formatted with fourmolu on version 0.17.0.0 (which can be run with scripts/fourmolize.sh)
  • Self-reviewed the diff

Migrations

  • The pr causes a breaking change of type a,b or c
  • If there is a breaking change, the pr includes a database migration and/or a fix process for old values, so that upgrade is possible
  • Resyncing and running the migrations provided will result in the same database semantically

If there is a breaking change, especially a big one, please add a justification here. Please elaborate
more what the migration achieves, what it cannot achieve or why a migration is not possible.

@sgillespie sgillespie changed the title Feature/concurrent tests Run DB integration tests concurrently Jun 4, 2026
@sgillespie sgillespie force-pushed the feature/concurrent-tests branch 2 times, most recently from b374c60 to 20edc9c Compare June 4, 2026 04:37
Previously, there were some tests that duplicated testLabels (copy/paste
errors). This is a prerequisite for running tests in parallel, as the
per-test state directory (`testfiles/temp/<testLabel>`) could have
collided.
Prerequisite for running tests concurrently.

All DB tests share the same database, so we can read the from the
`PGPASSFILE` environment variable. When we run them in parallel, this
won't be possible, since each running test will need its own database.

Instead, explicitly pass the `PGConfig` to all tests, which will allow
different database configs per test run.
The DB integration test suite now runs the groups concurrently:

 * Alonzo-era
 * Babbage-era
 * Conway-era
 * QSM (QuickCheck State Machine)

Concurrent tests cannot share a database, so each group has its own
copy. Grouping at the top level keeps the databases/threads manageable.

Also, add the required databases in the nix `preCheck` hook and GitHub
CI workflows.
@sgillespie sgillespie force-pushed the feature/concurrent-tests branch from 20edc9c to d2af3cc Compare June 29, 2026 14:22
This allows the user to add `-j N` to control how many threads to run
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