Skip to content

Run scenarios in parallel workers - #405

Draft
schlessera wants to merge 3 commits into
mainfrom
perf/parallel-scenarios
Draft

schlessera wants to merge 3 commits into
mainfrom
perf/parallel-scenarios

Conversation

@schlessera

Copy link
Copy Markdown
Member

Addresses #390.

Scenarios ran strictly one after another, although almost all of them are independent of each other and the CI runners have several cores.

Setting WP_CLI_TEST_PARALLEL to a number of workers now spreads the scenarios over that many Behat processes. The scenarios are selected with the same tag filter as before, so a parallel run covers exactly the scenarios of a serial one.

  • Every worker but the first gets its own temporary directory, and with it its own home directory, caches and run directories, as well as its own test database (wp_cli_test_1, wp_cli_test_2, ...). composer prepare-tests now allows the test user to create these databases.
  • Scenarios using fixed ports, background processes, the scaffold test database or fixed paths in the system's temporary directory all run in the first worker, one after the other.
  • Scenarios are distributed by their expected cost, so that the workers finish at about the same time.
  • composer behat-rerun re-runs exactly the scenarios that failed in the last parallel run.
  • Without permission to create the worker databases, on Windows, when collecting code coverage, and when selecting scenarios by path or name, the scenarios run one after the other as before.

Locally, this package's own suite ran the same 97 scenarios and 393 steps with the same results as a serial run, in 27 instead of 47 seconds with 6 workers. A subset of 213 entity-command scenarios went from 491 to 140 seconds with 8 workers in an earlier experiment.

Parallel runs stay opt-in. Measurements on CI are recorded on #390.

Setting WP_CLI_TEST_PARALLEL to a number of workers spreads the scenarios
over that many Behat processes. Every worker but the first gets its own
temporary directory, and with it its own home directory, caches and run
directories, as well as its own test database. Scenarios relying on
resources shared across the system, such as fixed ports or fixed paths in
the system's temporary directory, all run in the first worker.

Scenarios are distributed by their expected cost, so that the workers
finish at about the same time, and the ones that fail are recorded so that
rerun-behat-tests runs exactly those again.

composer prepare-tests now allows the test user to create the databases of
the workers. Without that permission, and on Windows, when collecting code
coverage or when selecting scenarios by path or name, the scenarios still
run one after the other.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 30, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the scope:testing Related to testing label Oct 30, 2026
@codecov

codecov Bot commented Oct 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

schlessera and others added 2 commits October 30, 2026 21:09
Run Behat through the PHP binary, as a shell script cannot be run directly
on Windows, and do not hand the run to the parallel runner there at all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rerun of a parallel run has to go through the parallel runner, which
knows which scenarios failed. Otherwise Behat's own rerun cache, which does
not match the workers' arguments, runs every scenario again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant