test(broker): stop racing the kill of a program a confined worker leaves

Merged
KI
24d ago
+5-2

Problem

kernel::a_program_a_confined_worker_leaves_running_ends_with_it (RFC 0010, from #75) fails now and then with "the program never ran":

  • check on #81's 10ba3e2 (job), on code that change does not touch. It passed on a rerun.
  • Once in #80's Linux mutation run, under a mutant that builds the same code. That made the mutant look caught and failed the run's comparison with the list.

Root cause

The scenario's worker starts a program, prints worker ready <worker> <program>, and exits with 3 straight away. The broker's supervisor then kills the worker's process group, which is the behavior under test. The test read that line and then asserted is_running(program), so it raced the kill. When the kill came first, the program was already a zombie or gone, and the assertion failed.

The assertion was meant to show the program ran at all, so the test could not pass with no program. The worker already shows that: start_lingering_program returns only after the program prints program ready, and the worker prints its own line only after that. If the program never ran, the worker panics, never reports, and ready_pids fails with "the worker exited before it was ready".

Change

Drop the is_running(program) check from this one test, with a comment on why. The rest stays: the broker must exit with the worker's code, 3, and assert_all_exit must see every holder of the broker's stderr close it, the program included, while the test still holds the program's stdin open.

The other is_running checks are not racy and stay. In two of them the program is meant to survive (setsid, --unconfined). In the third, the worker waits on stdin until the test signals the broker.

Verification

Locally, on macOS 26.2 with Rust 1.99.1:

  • cargo fmt --all --check: clean.
  • cargo clippy --all-targets --locked -- -D warnings: clean.
  • cargo clippy --locked --target x86_64-unknown-linux-gnu -p fsgate --test broker_confined -- -D warnings: clean. This is a type-check, not a run.
  • cargo test --locked: 121 passed. The test is Linux-only, so it runs only in CI here.

Not verified:

  • A deterministic reproduction. I did not force the race, for example by delaying the old check, so the evidence is the two CI failures and the reading above. A flake can only be shown fixed by its absence over time.

Documentation and release

Test only. No docs, changelog, or release.


Summary by cubic

Removes a racy is_running check from crates/fsgate/tests/broker_confined.rs. The worker exits right after reporting its program is ready, and the broker kills the group, so the assertion raced the kill and failed intermittently. The worker's ready handshake already proves the program ran, so the extra check was unnecessary.