Repository navigation
Run the test suite in parallel (2.24x faster) - #1412
Open
kennethrioja wants to merge 1 commit into
Open
kennethrioja wants to merge 1 commit into
kennethrioja wants to merge 1 commit into
Conversation
- Parallelise Minitest (4 workers by default, PARALLEL_WORKERS overrides, 1 = serial); each worker gets its own DB, Redis DB and TEST_ENV_NUMBER. - Make files written/read back by tests per worker (test job results, sitemaps, scraper logs). - Warm the Sprockets theme/JS lookup before forking. - Merge SimpleCov results from workers and clear stale resultsets at start. - Default test log level to warn (RAILS_LOG_LEVEL overrides). - Replace real sleeps in GitHub ingestor TTL tests with time travel. - Document parallel test options in docs/docker.md. Full suite: 91s -> ~40s (Minitest), same 1600 tests, 0 failures, 96.7% coverage. Co-authored-by: Copilot <[email protected]>, using Claude Opus 5.5 and 803+ AIC.
2 tasks done
Contributor
Author
|
It seems like #1411 has the same Capybara issue from the systems' tests. |
Contributor
Author
|
I can see also the improvement in the GitHub action in GitHub, when we compare |
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.
Summary of changes
[Etc.nprocessors, 4].min).PARALLEL_WORKERS=Noverrides it, andPARALLEL_WORKERS=1runs serially. Rails only goes parallel for 50+ tests, so single files and system tests stay serial.2 + worker) andTEST_ENV_NUMBER.HasTestJob), test sitemaps (config/sitemap.rb,sitemap_test.rb) and scraper logfiles (scraper_test.rb).SimpleCov.resultonly in workers) and clear stale resultsets at start, so serial and parallel runs report the same coverage.warn(RAILS_LOG_LEVEL=debugrestores the old behaviour).travel_to/travelinstead ofsleep(1)/sleep(2). This also fixes a flaky 604799 vs 604800 assertion under load. A mutation check confirmed the tests still fail when the TTL is wrong.docs/docker.mddocuments the new options.No test was removed, skipped or weakened: every run has the same 1600 tests and 8730 assertions.
Motivation and context
The full suite was slow to run in Docker. With the default 4 workers (benchmark below, same machine):
docker compose run test rails test: 97.4s → 50s, 48.7% less time (1.95× faster).The tests, assertions and coverage are unchanged: 1600 tests, 8730 assertions, 0 failures, 96.7% coverage (24437/25270 LOC, identical in serial and parallel).
Screenshots
Full suite run with
PARALLEL_WORKERS=1..10(Docker on Apple Silicon, 10 CPUs, 7.65 GiB VM shared with the dev stack):3–5 workers is the sweet spot. Beyond that, CPU/IO contention makes runs slower, and in earlier runs workers were OOM-killed. A killed worker makes Rails wait forever, which is why the default is capped at 4. Even serially the suite is faster (91.2s → 69.6s) thanks to the log level, asset warm-up and sleep removals.
Commands run (isolated Docker project,
PREFIX=tess-faster-tests):docker compose -p tess-faster-tests --profile test run --rm -e PARALLEL_WORKERS=$w test rails testfor w=1..10: all passed (table above).docker compose -p tess-faster-tests --profile test run --rm test rails test(default, 4 workers): 1600 tests, 0 failures, 0 errors, 10 skips, 39.4s, 96.7% coverage.This PR was done using GitHub Copilot CLI with Claude Opus 5.5 and 879.15 AIC (KR comment: that's too much for a ~2h session... still learning here).
Checklist