Skip to content

Commit e0d964c

Browse files
szuendDevtools-frontend LUCI CQ
authored andcommitted
[testing] Make sharding deterministic
The current sharding logic hashes the absolute file path to a test file. This makes sharding more or less non-deterministic across different machines given that it depends on the build output directory location on disk. This makes debugging bot failures with shards impossible. This CL makes the sharding deterministic by hashing the test file name relative to the directory and uses '/' consistently for the hashed string so sharding stays the same on all platforms. R=kimanh@chromium.org Bug: None No-Tree-Checks: True Change-Id: I58dea4ff79eb9135ef60bb861884cf2765a6f336 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7660459 Reviewed-by: Danil Somsikov <dsv@chromium.org> Auto-Submit: Simon Zünd <szuend@chromium.org> Reviewed-by: Kim-Anh Tran <kimanh@chromium.org> Commit-Queue: Kim-Anh Tran <kimanh@chromium.org>
1 parent 48f9650 commit e0d964c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

test/conductor/test_config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,10 @@ export function loadTests(testDirectory: string, filename = 'tests.txt') {
143143
.filter(t => t.length > 0)
144144
.map(t => path.normalize(path.join(testDirectory, t)))
145145
.filter(t => TestConfig.tests.some((spec: string) => t.startsWith(spec)))
146-
.filter(t => shardFilter(TestConfig, t));
146+
// To keep sharding deterministic, use the relative path from the test directory, NOT the
147+
// absolute file path on disk. Also replace backward slashes with forward slashes so sharding stays
148+
// the same across windows, linux and mac.
149+
.filter(t => shardFilter(TestConfig, path.relative(testDirectory, t).replaceAll('\\', '/')));
147150

148151
if (TestConfig.shuffle) {
149152
for (let i = tests.length - 1; i > 0; i--) {

0 commit comments

Comments
 (0)