Skip to content

chore(IDX): support bazel-8 for colocated tests & require usage of runtime_deps - #8449

Merged
basvandijk merged 33 commits into
masterfrom
basvandijk/improved-colocated-systest-runfiles-handling
Jan 29, 2026
Merged

basvandijk merged 33 commits into
masterfrom
basvandijk/improved-colocated-systest-runfiles-handling

Conversation

@basvandijk

@basvandijk basvandijk commented Jan 21, 2026 •

Copy link
Copy Markdown
Collaborator

This ensures colocated system-tests will work on Bazel >= 8.

Additionally it enforces that all runtime dependencies of system-tests are specified using the runtime_deps argument of the system_test bazel macro.

Furthermore, we want to make it less likely tests reference their runtime dependencies using hard-coded paths and instead use environment variables defined by runtime_deps.

Finally, in case of colocated tests, we want to ensure that all runtime dependencies can be easily copied to the colocated test-driver VM and that the environment variables specified in runtime_deps keep working for the colocated test.

How?

  1. Execute the test in a different directory than $PWD (we use $TEST_TMPDIR) to ensure hard-coded relative path references to Bazel's standard runfiles don't work and have to be replaced by reading an environment variable specified in runtime_deps.
  2. Create a runtime_deps directory in $TEST_TMPDIR containing symlinks to all runtime dependencies specified via runtime_deps.
  3. Re-export the environment variables from runtime_deps to point (absolutely) to the new location under runtime_deps/.
  4. The names of the symlinks contain the hash of the original path to prevent file name collisions and support bazel >= 8.

@github-actions github-actions Bot added the chore label Jan 21, 2026
Comment thread rs/tests/run_systest.sh Resolved
@basvandijk
basvandijk force-pushed the basvandijk/improved-colocated-systest-runfiles-handling branch from bdcbde4 to 245bd50 Compare January 22, 2026 19:16
@basvandijk basvandijk changed the title chore(IDX): improve handling of runfiles in system-tests chore(IDX): require using runtime_deps in system-tests Jan 23, 2026
@basvandijk basvandijk changed the title chore(IDX): require using runtime_deps in system-tests chore(IDX): require using runtime_deps in system-tests & support bazel-8 for colocated tests Jan 23, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Jan 23, 2026
Using `runtime_deps` will be required after
#8449 to specify runtime dependencies
in system-tests.
github-merge-queue Bot pushed a commit that referenced this pull request Jan 23, 2026
Runtime dependencies should always be retrieved using
`get_dependency_path`. This commit ensures getting
`NODE_OPERATOR_PRIV_KEY_PATH` stays working after
#8449.
@basvandijk
basvandijk force-pushed the basvandijk/improved-colocated-systest-runfiles-handling branch from b175682 to 012fda0 Compare January 23, 2026 12:53
github-merge-queue Bot pushed a commit that referenced this pull request Jan 23, 2026
After #8449 all runtime dependencies
should be specified via `runtime_deps`. This commit ensures the
`//rs/rust_canisters/xnet_test:xnet-test-canister` is provided via
`runtime_deps`.
@basvandijk basvandijk added CI_ALL_BAZEL_TARGETS Runs all bazel targets and removed CI_ALL_BAZEL_TARGETS Runs all bazel targets labels Jan 27, 2026
@basvandijk
basvandijk enabled auto-merge January 27, 2026 15:55
@basvandijk
basvandijk disabled auto-merge January 27, 2026 17:01
github-merge-queue Bot pushed a commit that referenced this pull request Jan 28, 2026
…_workload test (#8554)

After #8449 it's required to specify
runtime dependencies of system-tests using the `runtime_deps` parameter.
This already prepares the
`//rs/tests/execution:fill_execution_rounds_workload` for this
requirement.
github-merge-queue Bot pushed a commit that referenced this pull request Jan 28, 2026
…ility_test (#8552)

After #8449 it's required to specify
runtime dependencies of system-tests using the `runtime_deps` parameter.
This already prepares the
`//rs/tests/message_routing:queues_compatibility_test` for this
requirement.

To make this work the `rust_test_with_binary` bazel macro had to be
rewritten to not symlink to the test binary but to copy it instead.
Otherwise the system-test would use the `no_op` executable as its
dependency.
github-merge-queue Bot pushed a commit that referenced this pull request Jan 28, 2026
…ia env var (#8553)

After #8449 it's required to specify
runtime dependencies of system-tests using the `runtime_deps` parameter.
This already prepares the `
//rs/tests/consensus:consensus_performance_colocate` for this
requirement by referencing `//rs/tests:jaeger_uvm_config_image` via
environment variable.
github-merge-queue Bot pushed a commit that referenced this pull request Jan 28, 2026
…_workload test (#8554)

After #8449 it's required to specify
runtime dependencies of system-tests using the `runtime_deps` parameter.
This already prepares the
`//rs/tests/execution:fill_execution_rounds_workload` for this
requirement.
cgundy pushed a commit that referenced this pull request Jan 28, 2026
…#8555)

After #8449 it's required to specify
runtime dependencies of system-tests using the `runtime_deps` parameter.
This already prepares the `//rs/tests/networking:p2p_performance_test`
for this requirement.
@basvandijk
basvandijk enabled auto-merge January 28, 2026 10:35
@basvandijk basvandijk removed the CI_ALL_BAZEL_TARGETS Runs all bazel targets label Jan 28, 2026
@basvandijk
basvandijk added this pull request to the merge queue Jan 29, 2026
Merged via the queue into master with commit 2cb120f Jan 29, 2026
37 checks passed
@basvandijk
basvandijk deleted the basvandijk/improved-colocated-systest-runfiles-handling branch January 29, 2026 11:52
nmattia added a commit that referenced this pull request Jan 29, 2026
Consensus and IDX agreed on using `IC_ADMIN_PATH` as the environment
variable name for providing `ic-admin`. By using a consistent variable
name and by [only using absolute paths in system
tests](#8449) we can avoid re-setting
environment variables from within the tests.
github-merge-queue Bot pushed a commit that referenced this pull request Jan 29, 2026
Consensus and IDX agreed on using `IC_ADMIN_PATH` as the environment
variable name for providing `ic-admin`. By using a consistent variable
name and by [only using absolute paths in system
tests](#8449) we can avoid re-setting
environment variables from within the tests.
AleDema pushed a commit to AleDema/ic that referenced this pull request Oct 18, 2026
…head_nns_local (dfinity#11848)

## Problem


`//rs/tests/consensus/tecdsa:tschnorr_message_sizes_test_head_nns_local`
flaked on master on 2026-10-13 on RBE (run `18d6da50`): attempt 1 (first
log line 09:33:03 UTC) failed and attempt 2 (started 09:47:59) passed.
In attempt 1 every task passed:

```
Task setup                            PASSED  in 114.87s
Task test_xnet_limit                  PASSED  in 111.76s
Task test_local_limit                 PASSED  in 113.59s
Task assert_no_metrics_errors         PASSED  in   1.51s
Task assert_no_unallowed_log_patterns PASSED  in   5.13s
```

and the driver went on to tear the group down at 09:38:50, yet the
attempt failed: its log ends with the ninth `Stopping QEMU (pid ...) via
SIGTERM` at 09:39:30, and Bazel's summary in the RBE job log (run
38375493843, `Bazel Test All on RBE`) reads `FLAKY, failed in 1 out of 2
in 900.0s`, i.e. attempt 1 ran into the target's `long` (900 s) timeout.


`//rs/tests/message_routing/xnet:xnet_cloud_engine_isolation_test_local`
failed identically in the same run (all tasks passed, five SIGTERMs from
09:36:15 to 09:36:35, log ends there, `FLAKY, failed in 1 out of 2 in
900.1s`).

## Root cause

The worker was slow for the whole run: every task took 1.5-1.8x as long
as in the passed attempt (setup 115 s vs 63 s, the tests 112 s and 114 s
vs 67 s and 78 s), and the nine replica nodes logged 105 `starvation
detected` warnings between 09:34:13 and 09:38:46 (36 in the passed
attempt). Under that load none of the nine QEMUs left `/proc` within the
5 s SIGTERM grace period of `LocalBackend::stop_qemu`
(`rs/tests/driver/src/driver/local_backend.rs`): the SIGTERMs are 5.01 s
apart, while in the passed attempt, on the same worker, they are 0.1 s
apart. (The log cannot distinguish a QEMU still running from one exited
but not yet reaped; the latter is improbable given that the same worker
reaped them within 0.1 s minutes later.)

`stop_qemu` is meant to escalate to SIGKILL in that case, but the
escalation never runs. Before killing, it guards against PID reuse by
checking that `/proc/<pid>/comm` starts with `qemu-`. `comm` is the
basename of the exec'd path, and the backend execs QEMU through the
runfiles symlink that `rs/tests/run_systest.sh` creates,
`<sha256>-qemu-system-x86_64`, so `comm` is the first 15 characters of
the hash (`7f5ccae48c39d1b` in this run; verified on the dev VM by
exec'ing bash through such a symlink). The guard therefore always fails
closed, silently, which "defers to the teardown of the test action's
execution environment", and the VMs are left running; the hash-prefixed
links predate the QEMU backend (dfinity#8449 vs dfinity#10642), so the escalation has
never fired. What held the action for the remaining ~8.5 min is not in
the log; the lingering VMs are the only difference from the passed
attempt. Nothing else in `delete_group` blocks: `ip link del` of a TAP
that a process holds open returns at once (verified).

## Fix

Identify the process by its command line instead: the QEMU that
`start_vm` launched for a VM has the argument pair `-pidfile <that VM's
pid-file>`, which also makes the PID-reuse guard specific to this VM
rather than to any QEMU. With it, a VM that overruns the grace period is
SIGKILLed as intended and teardown completes; a process that overruns it
but is not that QEMU is now logged instead of silently skipped. A unit
test covers the helper.

`delete_group` also stops the group's VMs concurrently (scoped threads)
instead of one after the other: a stop can take the whole 5 s grace
period, so a stalled nine-VM group took 45 s to stop and now takes about
5 s.

Not covered: the stall itself; whether the 5 s grace period should be
longer; and what exactly the RBE executor does with a VM left running,
which the dev VM cannot reproduce because Bazel's linux-sandbox PID
namespace reaps it when the test process exits.

## Verification

- `cargo check --all-targets --all-features -p ic-system-test-driver`,
`cargo fmt` and `./ci/scripts/rust-lint.sh` are clean after every
commit; `bazel build //rs/tests/driver:ic-system-test-driver` and `bazel
test //rs/tests/driver:unit_tests` (46 tests, including the new one)
pass on the final code.
- On the dev VM: a process exec'd through a
`<sha256>-qemu-system-x86_64` symlink to bash has `comm` =
`7f5ccae48c39d1b` while its `cmdline` holds the full argv; `ip link del`
of a TAP that a process holds open returns at once.
- End-to-end on the dev VM, run three times (first commit, the
`-pidfile` pair guard, and the concurrent stop):
`//rs/tests/consensus:max_xnet_payload_size_test_local` with both QEMUs
SIGSTOPped 5 s before teardown, so that they cannot act on SIGTERM (as
the stalled VMs on CI did not). Every time both VMs overran the grace
period and were killed (`QEMU (pid 373) survived the SIGTERM grace
period; sending SIGKILL`, likewise the other VM), teardown completed, no
QEMU process was left behind and the test passed (88.6 s, 78.2 s, 67.2
s). With the concurrent stop both SIGTERMs were logged in the same
millisecond (09:29:15.722) and both SIGKILLs 5.01 s later
(09:29:20.734), where the sequential version took 10 s for the two VMs.
The old guard would not have matched either process (`comm` is the hash
prefix), so neither would have been killed.
- CI: the PR carries `CI_ALL_BAZEL_TARGETS`, so every `_local` system
test exercises the teardown.

This PR was created following the steps in
`.claude/skills/fix-flaky-tests/SKILL.md`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
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.

3 participants