Skip to content

ci: wire up integration-test sharding, off by default - #3443

Closed
tomassrnka wants to merge 1 commit into
mainfrom
ci/shard-integration-tests
Closed

ci: wire up integration-test sharding, off by default#3443
tomassrnka wants to merge 1 commit into
mainfrom
ci/shard-integration-tests

Conversation

@tomassrnka

@tomassrnka tomassrnka commented Jul 29, 2026

Copy link
Copy Markdown
Member

Each compression config runs the whole suite on one runner, where api/templates alone sets the clock — 853s of the 856s zstd1 test step, because go test caps every package at -parallel=4. This adds the machinery to split a config across jobs: scripts/select-tests.sh enumerates top-level tests from the source tree and bin-packs each package across the shards by recorded runtime, so every shard holds a slice of every package and a newly added test always lands in exactly one shard. update-test-weights.go refreshes those times from a run.

SHARDS defaults to 1, so this is a no-op until someone turns the dial. Measured at 4 shards the slowest job drops 20.1m -> 11.3m (44%), but infra-tests only served ~6 concurrent runners, so the 12 jobs spent their savings queueing and end-to-end regressed (21.5m -> 26.7m). Reducing to 6 jobs did not buy it back either — the queue delay tracks repo-wide pool saturation, not this workflow. So this should merge/raise only alongside more runners (#3352); staying draft until then. The immediate, capacity-neutral win is split out into #3462.

@cla-bot cla-bot Bot added the cla-signed label Jul 29, 2026
@cursor

cursor Bot commented Jul 29, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Changes only how tests are selected and scheduled in CI; default SHARDS=1 preserves full-suite runs, with partition logic designed so shards together cover every test.

Overview
Adds infrastructure to split each compression-matrix integration job across parallel shards that each run a balanced subset of top-level tests, so wall-clock per job can drop once CI raises shard count. The workflow gains a shard matrix axis and passes SHARD into the test step; SHARDS stays at 1 so behavior today matches a single full suite per config. The integration Makefile centralizes gotestsum flags and, when SHARDS > 1, builds a -run regex via select-tests.sh, which discovers tests from sources and bin-packs them per package using test-weights.tsv, with a small tool and make target to refresh weights from JUnit artifacts.

Reviewed by Cursor Bugbot for commit 9f09747. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
3648 1 3647 9
View the top 1 failed test(s) by shortest run time
github.com/e2b-dev/infra/tests/integration/internal/tests/proxies::TestMaskRequestHostAPIParameter
Stack Traces | 4.87s run time
=== RUN   TestMaskRequestHostAPIParameter
=== PAUSE TestMaskRequestHostAPIParameter
=== CONT  TestMaskRequestHostAPIParameter
Executing command python3 in sandbox it6zo56r3w89y76xem59o (user: root)
    mask_request_host_test.go:44: Command [python3] output: event:{start:{pid:1417}}
    mask_request_host_test.go:68: Command [cat] output: event:{start:{pid:1418}}
    mask_request_host_test.go:68: Command [cat] output: event:{data:{stderr:"cat: /tmp/nc_output.txt: No such file or directory\n"}}
    mask_request_host_test.go:68: Command [cat] output: event:{end:{exit_code:1 exited:true status:"exit status 1" error:"exit status 1"}}
    mask_request_host_test.go:69: 
        	Error Trace:	.../tests/proxies/mask_request_host_test.go:69
        	Error:      	Received unexpected error:
        	            	command cat in sandbox it6zo56r3w89y76xem59o failed with exit code 1
        	Test:       	TestMaskRequestHostAPIParameter
--- FAIL: TestMaskRequestHostAPIParameter (4.87s)
View the full list of 5 ❄️ flaky test(s)
github.com/e2b-dev/infra/tests/integration/internal/tests/envd::TestListDir

Flake rate in main: 25.94% (Passed 217 times, Failed 76 times)

Stack Traces | 1.02s run time
=== RUN   TestListDir
=== PAUSE TestListDir
=== CONT  TestListDir
--- FAIL: TestListDir (1.02s)
Executing command tar in sandbox isy94jrug358ctn4t2k2d (user: root)
github.com/e2b-dev/infra/tests/integration/internal/tests/envd::TestListDir/depth_0_lists_only_root_directory

Flake rate in main: 29.33% (Passed 53 times, Failed 22 times)

Stack Traces | 0.01s run time
=== RUN   TestListDir/depth_0_lists_only_root_directory
=== PAUSE TestListDir/depth_0_lists_only_root_directory
=== CONT  TestListDir/depth_0_lists_only_root_directory
    filesystem_test.go:96: 
        	Error Trace:	.../tests/envd/filesystem_test.go:96
        	Error:      	Received unexpected error:
        	            	unavailable: 502 Bad Gateway
        	Test:       	TestListDir/depth_0_lists_only_root_directory
--- FAIL: TestListDir/depth_0_lists_only_root_directory (0.01s)
github.com/e2b-dev/infra/tests/integration/internal/tests/envd::TestListDir/depth_1_lists_root_directory

Flake rate in main: 23.11% (Passed 163 times, Failed 49 times)

Stack Traces | 0.01s run time
=== RUN   TestListDir/depth_1_lists_root_directory
=== PAUSE TestListDir/depth_1_lists_root_directory
=== CONT  TestListDir/depth_1_lists_root_directory
    filesystem_test.go:96: 
        	Error Trace:	.../tests/envd/filesystem_test.go:96
        	Error:      	Received unexpected error:
        	            	unavailable: 502 Bad Gateway
        	Test:       	TestListDir/depth_1_lists_root_directory
--- FAIL: TestListDir/depth_1_lists_root_directory (0.01s)
github.com/e2b-dev/infra/tests/integration/internal/tests/envd::TestListDir/depth_2_lists_first_level_of_subdirectories_(in_this_case_the_root_directory)

Flake rate in main: 50.00% (Passed 1 times, Failed 1 times)

Stack Traces | 0.01s run time
=== RUN   TestListDir/depth_2_lists_first_level_of_subdirectories_(in_this_case_the_root_directory)
=== PAUSE TestListDir/depth_2_lists_first_level_of_subdirectories_(in_this_case_the_root_directory)
=== CONT  TestListDir/depth_2_lists_first_level_of_subdirectories_(in_this_case_the_root_directory)
    filesystem_test.go:96: 
        	Error Trace:	.../tests/envd/filesystem_test.go:96
        	Error:      	Received unexpected error:
        	            	unavailable: 502 Bad Gateway
        	Test:       	TestListDir/depth_2_lists_first_level_of_subdirectories_(in_this_case_the_root_directory)
--- FAIL: TestListDir/depth_2_lists_first_level_of_subdirectories_(in_this_case_the_root_directory) (0.01s)
github.com/e2b-dev/infra/tests/integration/internal/tests/envd::TestListDir/depth_3_lists_all_directories_and_files

Flake rate in main: 23.14% (Passed 93 times, Failed 28 times)

Stack Traces | 0.01s run time
=== RUN   TestListDir/depth_3_lists_all_directories_and_files
=== PAUSE TestListDir/depth_3_lists_all_directories_and_files
=== CONT  TestListDir/depth_3_lists_all_directories_and_files
    filesystem_test.go:96: 
        	Error Trace:	.../tests/envd/filesystem_test.go:96
        	Error:      	Received unexpected error:
        	            	unavailable: 502 Bad Gateway
        	Test:       	TestListDir/depth_3_lists_all_directories_and_files
--- FAIL: TestListDir/depth_3_lists_all_directories_and_files (0.01s)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@tomassrnka
tomassrnka force-pushed the ci/shard-integration-tests branch 4 times, most recently from 1f9dd1f to 794bdf7 Compare July 30, 2026 10:19

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 794bdf7. Configure here.

Comment thread tests/integration/scripts/shard-tests.sh Outdated
Each compression config runs the whole suite on one runner, where
api/templates alone sets the wall clock: 853s of the 856s test step under
zstd1, because go test caps every package at -parallel=4. Splitting a config
across jobs is the only lever that moves that, so this adds the machinery.

scripts/select-tests.sh enumerates the top-level tests from the source tree
and bin-packs each package across the shards using recorded per-test times,
so every shard holds a slice of every package, a newly added test always
lands in exactly one shard, and the shards finish at roughly the same time.
update-test-weights.go refreshes the recorded times from a run's JUnit files.

SHARDS defaults to 1, so this changes nothing until someone turns the dial.
Measured at 4 shards the slowest job drops 20.1m -> 11.3m, but the
infra-tests pool only served ~6 concurrent runners, so the extra jobs spent
their savings queueing and end-to-end got worse. Raise SHARDS alongside more
capacity (#3352), not before.
@tomassrnka
tomassrnka force-pushed the ci/shard-integration-tests branch from 794bdf7 to 9f09747 Compare July 30, 2026 10:39
@tomassrnka tomassrnka changed the title ci: shard the integration suite to cut wall-clock time ci: wire up integration-test sharding, off by default Jul 30, 2026
@tomassrnka

Copy link
Copy Markdown
Member Author

Closing — this only pays off with more concurrent runner capacity, and we're not pursuing that (#3352 closed). Measured for the record: sharding cut per-job time 20.1m → 11.3m but raised runner-minutes 60 → 136, and the pool couldn't place the fan-out (13-17 min of staggering), so end-to-end got worse. The win came from cutting work instead — #3462 takes end-to-end 21.5m → 11.1m at 28 runner-minutes with no extra capacity.

@tomassrnka tomassrnka closed this Jul 30, 2026
@tomassrnka
tomassrnka deleted the ci/shard-integration-tests branch July 30, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant