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.

  1. Record your test results via Sending data to Launchable.

  2. 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.

  3. Start up your parallel test worker(s).

  4. Request the bin of tests that the worker should run. To do this, run launchable split-subset with:

    1. the --subset-id option set to the ID you saved earlier, and

    2. the --bin value set to bin-number/bin-count. For example, to split your test suite across 3 workers, use 1/3, 2/3, etc.

    3. If you're using Zero Input Subsetting, add the --output-exclusion-rules option.

  5. Run the tests on each worker as outlined in Requesting and running a subset of tests.

  6. 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:

1# main
2$ launchable record build --name $BUILD_ID --source src=.
3$ launchable subset --split --target 100% --build $BUILD_ID bazel .
4subset/12345
5
6...
7
8# worker 1
9$ launchable split-subset --subset-id subset/12345 --bin 1/3 bazel > worker.txt
10$ bazel test $(cat worker.txt)
11$ launchable record tests --subset-id subset/12345 bazel .
12
13# worker 2
14$ launchable split-subset --subset-id subset/12345 --bin 2/3 bazel > worker.txt
15$ bazel test $(cat worker.txt)
16$ launchable record tests --subset-id subset/12345 bazel .
17
18# worker 3
19$ launchable split-subset --subset-id subset/12345 --bin 3/3 bazel > worker.txt
20$ bazel test $(cat worker.txt)
21$ launchable record tests --subset-id subset/12345 bazel .