Skip to content

fix(test): make watcher close and relay path prerequisites explicit - #25

Merged
CommaBot merged 2 commits into
stillfailfrom
ember/paths-watcher-test
Nov 20, 2026
Merged

CommaBot merged 2 commits into
stillfailfrom
ember/paths-watcher-test

Conversation

@CommaBot

@CommaBot CommaBot commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Three path tests depend on uncontrolled timing: the peer-close watcher races real socket delivery against a paused clock, and two relay-policy tests expect the default RTT selector to choose direct traffic on loopback. This PR makes those prerequisites explicit while retaining every policy assertion. It does not change production selection or timeouts.

The server watcher assertion can time out before a CONNECTION_CLOSE packet arrives over a real socket. Tokio time is paused at that point. Its automatic clock advance races the packet against a one-nanosecond deadline.

Wait up to one real second for conn_server.closed() and check ApplicationClosed. Then pause time again and keep the one-nanosecond watcher assertion. The client watcher assertion stays in place. No sleeps, retries, production changes, or setup deadline changes.

Linux x86_64 results (gt2, Rust 1.100.0, GCC/BFD, dev debug information disabled):

Experiment 36cd14e 0e1ba28 Fixed
Original test, isolated 0/50 failures 0/50 failures See setup failure below
Real-clock diagnostic, isolated 0/50 failures 0/50 failures N/A
Same CPU as two busy processes, interleaved N/A 5/50 failures 0/50 failures
Same CPU as two busy processes, consecutive fixed runs N/A N/A 200/200 passed

All five reproduced failures were the server watcher timeout at connection.rs:1660, matching Ubuntu CI job 136432133137. The failed rounds were 20, 24, 30, 36, and 42. Both versions used CPU 0, two Python busy loops on CPU 0, and the exact test filter with --nocapture.

The diagnostic used std::time::Instant from client close to server watcher completion. Each revision ran 50 times.

Revision Minimum Median p95 Maximum
36cd14e 1.354 ms 1.499 ms 2.749 ms 18.803 ms
0e1ba28 1.356 ms 1.508 ms 2.172 ms 2.573 ms

These samples show no server shutdown slowdown in the newer revision.

Validation limitations remain visible:

  • The first isolated fixed run stopped at repetition 77 after 76 passes. The unchanged setup wait at line 1640 timed out before client close. This PR does not fix or hide that separate failure.
  • cargo test --locked -p iroh --lib endpoint::connection fails to compile an existing test in remote_state.rs. It imports test_transport and calls add_custom_transport without the required feature gate.
  • With CI features, cargo test --locked -p iroh --lib endpoint::connection --features test-utils,unstable-custom-transports passes all four tests. All repeated experiments used those features.
  • No other test in connection.rs has the same paused-clock, one-nanosecond pattern.

Two relay-policy test builders now use relay_last(). The default selector can retain an already selected relay when direct RTT improves by less than max(5 ms, current RTT / 4). A captured failure ended with IP 1.562 ms versus selected relay 2.586 ms, so the original 20-second selected-direct prerequisite never completed.

The tests still require both relay backup paths, disabled-path retirement, zero sends through the disabled relay, increasing keepalive counters through the other relay, connection/direct-path survival, and relay use after re-enabling it. No assertion or deadline changed.

Matched Linux CPU-contention comparison (CPU 0, two busy processes on CPU 0, original/fixed interleaved, 50 executions of each test/version):

Test Original failures Fixed failures
remote_relays_narrowed_send_nothing_through_the_one_left_out 14/50 0/50
disabled_relays_hold_a_connection_kept 12/50 0/50

All 26 original failures occurred at the selected-direct prerequisite, before relay-policy assertions. Five sequential batches used the same binary hashes and conditions; no failed fixed run was discarded or retried. The earlier revision diagnostic ran each test three times: old revision both 3/3 passed; current narrowed 2/3 and kept 3/3. RTT sampling and initial selection timing differed, but this does not isolate the noq pin change as the cause. The default selector source is identical in both revisions.

Scope: monoid products install their own mesh_transport::selection::Selector. Its thresholds are separate; this PR changes only iroh tests. Ubuntu and macOS CI on the updated head remain to be checked.

Base: stillfail at 0e1ba28b1d436e6b367f14a6ba146d1fed56c3f1. Please leave this PR unmerged for maintainer review and Ubuntu/macOS CI.

Model: OpenAI Codex. Tests: Rust libtest and Tokio, with a Python repetition harness.

@CommaBot CommaBot changed the title fix(test): wait for peer close before checking paths watcher fix(test): make watcher close and relay path prerequisites explicit Nov 20, 2026
@CommaBot
CommaBot merged commit d7ede64 into stillfail Nov 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant