diff --git a/rs/moq-net/src/model/clock.rs b/rs/moq-net/src/model/clock.rs index 6159032e181..ef855bcec79 100644 --- a/rs/moq-net/src/model/clock.rs +++ b/rs/moq-net/src/model/clock.rs @@ -21,7 +21,7 @@ pub(crate) fn now() -> crate::time::Instant { /// /// The ambient runtime's clock where there is one, so a paused test runtime pauses /// staleness along with the drivers it supplies time to. -#[cfg(not(test))] +#[cfg(not(any(test, loom)))] pub(crate) fn wall() -> crate::time::Instant { #[cfg(all(feature = "async", not(target_family = "wasm")))] let now = web_async::time::Instant::now().into_std(); @@ -30,6 +30,13 @@ pub(crate) fn wall() -> crate::time::Instant { now } +/// Loom permutes handoffs without advancing time, so scheduling cannot age groups. +#[cfg(all(loom, not(test)))] +pub(crate) fn wall() -> crate::time::Instant { + static FROZEN: LazyLock = LazyLock::new(now); + *FROZEN +} + /// Unit tests freeze the wall clock, so only time a test supplies moves it: the /// simulated clock inside `moq_net_sim`, or a pool stepped by hand outside it. #[cfg(test)] diff --git a/rs/moq-net/tests/loom.rs b/rs/moq-net/tests/loom.rs index dc191dd6917..0cd78410d95 100644 --- a/rs/moq-net/tests/loom.rs +++ b/rs/moq-net/tests/loom.rs @@ -83,8 +83,8 @@ fn frame_reaches_a_parked_subscriber() { /// the path where the producer takes the waiter list for group 1 and wakes outside /// the lock while group 2 is already being written. /// -/// The subscription starts at group 0: an unfloored subscriber on an untimed track -/// starts at the latest group, so one opened after both writes would only see the second. +/// The subscription retains the backlog from group 0: a floor alone does not keep +/// superseded groups within a zero delay budget. #[test] fn back_to_back_groups_arrive_in_order() { model(|| { @@ -101,7 +101,9 @@ fn back_to_back_groups_arrive_in_order() { track.finish().expect("finish track"); }); - let from_start = moq_net::track::Subscription::default().with_start(moq_net::track::Position::group(0)); + let from_start = moq_net::track::Subscription::default() + .with_start(moq_net::track::Position::group(0)) + .with_max_delay(std::time::Duration::MAX); let mut subscriber = block_on(track_consumer.subscribe(from_start)).expect("subscribe"); let first = block_on(subscriber.recv_group()).expect("recv").expect("first group"); let second = block_on(subscriber.recv_group()).expect("recv").expect("second group"); diff --git a/rs/moq-relay/tests/drills.rs b/rs/moq-relay/tests/drills.rs index ea3621ed202..e699dc9c4e4 100644 --- a/rs/moq-relay/tests/drills.rs +++ b/rs/moq-relay/tests/drills.rs @@ -714,23 +714,20 @@ async fn interrupted_publisher_republishes_new_content(lane: Lane) { let (_, payload) = read_group(&mut reader, "before the interrupt").await; assert_eq!(payload, b"original", "delivery is broken before the drill even starts"); - // The interrupt: the session goes first, so the relay loses the publisher - // with no finish and no unannounce, which is what a crashed publisher looks - // like. Dropping the broadcast while the session was still up would send a - // clean unannounce instead and never reach the crash path. The rest goes - // after, including the subscriber's handles, so nothing local keeps the dead - // broadcast alive for the assertions below. + // Dropping the connection cancels its task asynchronously. Keep the broadcast + // alive until the relay withdraws it, so a clean unannounce cannot race the + // session loss and satisfy the assertion without testing crash recovery. drop(first_session); drop(reader); - drop(track); - drop(broadcast); - drop(first); // Terminal result: the name stops being announced. Nothing told the relay // the broadcast ended, so this is the proof that losing the publisher's // session withdraws what it announced rather than parking subscribers on it. expect_announce(&mut announced, "live", false, "the interrupted publisher").await; println!("fault activated: the interrupted publisher's broadcast was withdrawn"); + drop(track); + drop(broadcast); + drop(first); // Restore: the same name, a new publisher, different content. let second = moq_tokio::origin::spawn(); diff --git a/sh/rs/select.test.py b/sh/rs/select.test.py index 71efcd099de..8c6e634b144 100644 --- a/sh/rs/select.test.py +++ b/sh/rs/select.test.py @@ -85,7 +85,8 @@ def test_unexecuted_bench_is_not_compiled(self): (scratch / "benches/unexecuted.rs").write_text( 'compile_error!("nextest must not compile a benchmark it never runs");\nfn main() {}\n' ) - env = dict(os.environ, BASH_ENV=os.devnull, TMPDIR="/tmp") + env = dict(os.environ, BASH_ENV=os.devnull, TMPDIR="/tmp", + NEXTEST_PROFILE="default") result = subprocess.run( ["just", "rs", "test", "--manifest-path", str(scratch / "Cargo.toml")], cwd=ROOT, env=env, capture_output=True, text=True, diff --git a/sh/rs/test-lints.test.py b/sh/rs/test-lints.test.py index 81d5085f5b5..e9c16c0802b 100644 --- a/sh/rs/test-lints.test.py +++ b/sh/rs/test-lints.test.py @@ -30,7 +30,8 @@ def test_clippy_warning_fails_test_build(self): ) toolchain = Path(shutil.which("clippy-driver")).parent env = dict(os.environ, CARGO_TARGET_DIR=str(root / "target"), - PATH=f"{toolchain}:{os.environ['PATH']}") + PATH=f"{toolchain}:{os.environ['PATH']}", + NEXTEST_PROFILE="default") subprocess.run(["cargo", "generate-lockfile", "--offline"], cwd=root, env=env, check=True, capture_output=True) result = subprocess.run(["just", "rs", "test"], cwd=root, env=env, diff --git a/test/drain/run.sh b/test/drain/run.sh index d70344cb4ac..e15615f1c6c 100755 --- a/test/drain/run.sh +++ b/test/drain/run.sh @@ -119,7 +119,7 @@ if [[ $status -eq 0 ]]; then elif ! harness_wait "$A_PID"; then echo "error: relay A exited with a failure" >&2 status=1 - elif ! grep -q "drain complete: every session left" "$HARNESS_RUN/relay-a.log"; then + elif ! grep -q "drain ended with no established sessions; exiting" "$HARNESS_RUN/relay-a.log"; then echo "error: relay A did not report that every session left on its own" >&2 status=1 else