Parallelizing your test suite with the Launchable CLI
To parallelize your test suite, you can take advantage of the parallelization feature built into launchable subset
. launchable subset
's primary purpose is Predictive Test Selection, but here, we're using --target 100%
to skip the test selection part but keep the parallelization feature.
Record your test results via Sending data to Launchable.
Kick off the process by running
launchable subset
with the--split
option and--target 100%
. The command will output an ID string you should save and pass into each runner. See Requesting and running a subset of tests for more details about this command.Start up your parallel test worker(s).
Request the bin of tests that the worker should run. To do this, run
launchable split-subset
with:the
--subset-id
option set to the ID you saved earlier, andthe
--bin
value set tobin-number/bin-count
. For example, to split your test suite across 3 workers, use1/3
,2/3
, etc.If you're using Zero Input Subsetting, add the
--output-exclusion-rules
option.
Run the tests on each worker as outlined in Requesting and running a subset of tests.
After each run finishes in each worker, record test results using
launchable record tests
with the--subset-id
option set to the ID you saved earlier.
In pseudocode:
# main$ launchable record build --name $BUILD_ID --source src=.$ launchable subset --split --target 100% --build $BUILD_ID bazel .subset/12345...# worker 1$ launchable split-subset --subset-id subset/12345 --bin 1/3 bazel > worker.txt$ bazel test $(cat worker.txt)$ launchable record tests --subset-id subset/12345 bazel .# worker 2$ launchable split-subset --subset-id subset/12345 --bin 2/3 bazel > worker.txt$ bazel test $(cat worker.txt)$ launchable record tests --subset-id subset/12345 bazel .# worker 3$ launchable split-subset --subset-id subset/12345 --bin 3/3 bazel > worker.txt$ bazel test $(cat worker.txt)$ launchable record tests --subset-id subset/12345 bazel .