A tool that helps with running tasks in parallel across multiple workers on CircleCI the ~ideal way.
Suppose you have 5 tests (pair of name and execution time) {A: 12, B: 2, C: 8, D: 2, E: 5} and 2 workers {X, Y} and you want to preserve the overall execution time as small as possible. The naïve solution won't work - in this case you may end up with subsets {A: 12, C: 8, E: 5} and {B: 2, D: 2}. These subsets lead to a big difference between total execution time of each worker - 25 (86.2%) vs. 4 (13.8%). The reason is that the exection times of each test are completely ignored.
Here comes the partition, which solves this problem almost ideally: Subsets produced by partition are {A: 12, B: 2} and {C: 8, D: 2, E: 5} - 14 (48.3%) vs. 15 (51.7%).
- Reads saved output from the previous successfull run. Each test in the output has to contain filename and execution time. To obtain the output from the previous run you need to have an access token to build artifacts.
- Loads all files in current test suite(s). Tests may be added and/or deleted accross runs.
- Applies solution of minimal difference partition problem to the set of execution times.
$ java -jar partition.jar --token <ACCESS_TOKEN> <PATH_TO_TESTS>
## Modes
Mode can be set by -m
(--mode
) option.
- delete: By default, partition operates in
delete
mode, which means that only files contained in bucket are preserved; other files are deleted. - copy - Second mode called
copy
copies files contained in bucket to newly created directory; original directory is left untouched.
dependencies:
post:
- java -jar partition.jar --token <ACCESS_TOKEN> test/features:
{parallel: true}
test:
override:
- set -o pipefail; nightwatch -g test/features | tee nightwatch_output:
{parallel: true}
general:
artifacts:
- nightwatch_output
$ lein test partition.core