Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion rs/moq-net/src/model/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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<crate::time::Instant> = 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)]
Expand Down
8 changes: 5 additions & 3 deletions rs/moq-net/tests/loom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(|| {
Expand All @@ -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");
Expand Down
15 changes: 6 additions & 9 deletions rs/moq-relay/tests/drills.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion sh/rs/select.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion sh/rs/test-lints.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion test/drain/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading