/circleci-parallelism-option-test

Testing the behavior of CircleCI concurrency option

Primary LanguageTypeScriptMIT LicenseMIT

circleci-parallelism-option-test CircleCI

Testing the behavior of CircleCI parallelism option

Background

In order to run CircleCI steps in parallel, you need to set a value greater than 1 to the parallelism option first.

version: 2
jobs:
  test:
    docker:
      - image: circleci/node:latest
    parallelism: 3
    ...

Then you can use the CircleCI CLI for spliting tests

circleci tests glob "__test__/*.spec.ts" | circleci tests split --split-by=timing

CircleCI advertises that by passing --split-by=timing to the circleci tests split command, your tests will be split evenly.

To split by test timings, use the --split-by flag with the timings split type. The available timings data will then be analyzed and your tests will be split across your parallel-running containers as evenly as possible leading to the fastest possible test run time

Running Tests in Parallel

There are many strategies that can be potentially used for splitting tests.

One strong candidate is the Greedy Algorithm but it's not always the most optimized one.

So I decided to run the following tests in order to investigate the CircleCI's behavior.

Test Plan

I prepared the following tests.

I investigated how these tests are split when the parallelism option is set as 3.

If CircleCI chooses the most optimized strategy, then the tests should complete within 20 seconds.

Test Result

CircleCI seems to choose the Greedy Algorithm and it ended up with the following result

Container 1

Screen Shot 2022-01-05 at 3 38 33

Container 2

Screen Shot 2022-01-05 at 3 38 51

Container 3

Screen Shot 2022-01-05 at 3 39 03