Skip to content

Commit 361ba88

Browse files
committed
test: add circleci sharding to bazel e2e tests
1 parent ec61f8a commit 361ba88

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

.circleci/dynamic_config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ jobs:
347347

348348
bazel-e2e-tests:
349349
executor: bazel-executor
350+
parallelism: 2
350351
parameters:
351352
build_type:
352353
type: enum
@@ -364,7 +365,7 @@ jobs:
364365
- run: mkdir /mnt/ramdisk/e2e
365366
- run:
366367
name: Test << parameters.build_type >> << parameters.subset >>
367-
command: yarn bazel test --define=E2E_TEMP=/mnt/ramdisk/e2e --config=<< parameters.build_type >> //tests/legacy-cli:e2e.<< parameters.subset >>
368+
command: yarn bazel test --define=E2E_TEMP=/mnt/ramdisk/e2e --define=E2E_SHARD_TOTAL=${CIRCLE_NODE_TOTAL} --define=E2E_SHARD=${CIRCLE_NODE_INDEX} --config=<< parameters.build_type >> //tests/legacy-cli:e2e.<< parameters.subset >>
368369
no_output_timeout: 40m
369370
- store_artifacts:
370371
path: dist/testlogs/tests/legacy-cli/e2e.<< parameters.subset >>

tests/legacy-cli/e2e.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def _e2e_tests(name, runner, **kwargs):
7878
tags = kwargs.pop("tags", []) + TEST_TAGS
7979

8080
# Passthru E2E variables in case it is customized by CI etc
81-
configuration_env_vars = kwargs.pop("configuration_env_vars", []) + ["E2E_TEMP"]
81+
configuration_env_vars = kwargs.pop("configuration_env_vars", []) + ["E2E_TEMP", "E2E_SHARD_INDEX", "E2E_SHARD_TOTAL"]
8282

8383
env = kwargs.pop("env", {})
8484

tests/legacy-cli/e2e_runner.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,18 @@ const argv = yargsParser(process.argv.slice(2), {
6565

6666
'debug': !!process.env.BUILD_WORKSPACE_DIRECTORY,
6767
'glob': process.env.TESTBRIDGE_TEST_ONLY,
68-
'nb-shards': process.env.TEST_TOTAL_SHARDS,
69-
'shard': process.env.TEST_SHARD_INDEX,
68+
'nb-shards':
69+
Number(process.env.E2E_SHARD_TOTAL ?? 1) * Number(process.env.TEST_TOTAL_SHARDS ?? 1) || 1,
70+
'shard':
71+
process.env.E2E_SHARD_INDEX === undefined && process.env.TEST_SHARD_INDEX === undefined
72+
? undefined
73+
: Number(process.env.E2E_SHARD_INDEX ?? 0) * Number(process.env.E2E_SHARD_TOTAL ?? 1) +
74+
Number(process.env.TEST_SHARD_INDEX ?? 0),
7075
},
7176
});
7277

78+
console.log(argv);
79+
7380
/**
7481
* Set the error code of the process to 255. This is to ensure that if something forces node
7582
* to exit without finishing properly, the error code will be 255. Right now that code is not used.
@@ -145,8 +152,8 @@ const allTests = glob
145152
})
146153
.sort();
147154

148-
const shardId = 'shard' in argv ? Number(argv['shard']) : null;;
149-
const nbShards = (shardId === null) ? 1 : Number(argv['nb-shards']);
155+
const shardId = argv['shard'] !== undefined ? Number(argv['shard']) : null;
156+
const nbShards = shardId === null ? 1 : Number(argv['nb-shards']);
150157
const tests = allTests.filter((name) => {
151158
// Check for naming tests on command line.
152159
if (argv._.length == 0) {
@@ -170,7 +177,6 @@ if (testsToRun.length === 0) {
170177
console.log(`No tests to run on shard ${shardId}, exiting.`);
171178
process.exit(0);
172179
} else {
173-
console.log(`No tests would be ran, aborting.`);
174180
process.exit(1);
175181
}
176182
}

0 commit comments

Comments
 (0)