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
1 change: 0 additions & 1 deletion quest/m1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ disabled rung strands WHEP, HLS, and moq-mux export viewers.
- [Untimed lite-07](/quest/m1/lite-untimed.md) - lite-07 carries an untimed track in both languages; lite-05/06 write send time
- [A watch and publish release ships assets()](/quest/m1/assets-release.md) - the release that lets the sites host the worklets
- [Dogfood hosted worklets](/quest/m1/dogfood-assets.md) - the moq.pro dashboard hosts the worklets and calls `assets()` after the release
- [Initial catalog routing](/quest/m1/initial-catalog-routing.md) - a usable fallback does not strand initial catalog acquisition with a spurious Unroutable
- [Live TS clock validation](/quest/m1/ts-live-clock.md) - resolve the local PCR-rate failure with reproducible timing evidence and CI controls
- [Same-instance TS resume](/quest/m1/ts-same-instance-resume.md) - prove valid continuation and fix the unexpected final exporter failure without weakening identity
- [More tests under load](/quest/m1/test-flakes-2/README.md) - the second round of load-only failures, one quest per flake, fixed at the cause
Expand Down
61 changes: 0 additions & 61 deletions quest/m1/initial-catalog-routing.md

This file was deleted.

80 changes: 80 additions & 0 deletions rs/moq-net/tests/catalog_acquisition.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
//! Initial catalog acquisition while the same publisher gains a second session.

mod support;

use moq_net::{Error, Hop, Version, origin};
use support::harness::{MockConnectOptions, MockPair, connect_mock};

fn origin(hop: u64) -> origin::Producer {
let (producer, driver) = origin::Producer::new(origin::Config::new(Hop::new(hop).unwrap()));
support::harness::spawn(driver);
producer
}

async fn link(version: Version, from: &origin::Producer, to: &origin::Producer, cost: u64) -> MockPair {
let mut options = MockConnectOptions::new(version);
options.server_publish = Some(from.consume());
options.client_subscribe = Some(to.clone());
options.cost = Some(cost);
connect_mock(options).await
}

async fn acquisition(version: &str) {
let version: Version = version.parse().unwrap();
let publisher = origin(1);
let subscriber = origin(2);
let broadcast = publisher.create_broadcast("live").unwrap();
let mut dynamic = broadcast.dynamic();
broadcast
.announce(origin::Route::default().with_epoch(moq_net::Epoch::mint()))
.unwrap();
let _old = link(version, &publisher, &subscriber, 100).await;
let remote = subscriber.consume().routed_broadcast("live").await.unwrap();
let mut announced = subscriber.consume().follow("live").unwrap();
let old_cost = match announced.next().await {
Some(moq_net::announce::Event::Start(announce)) => announce.route.cost,
other => panic!("expected the first route, got {other:?}"),
};
let mut pending = Box::pin(remote.track("catalog.json").unwrap().subscribe(None));
let request = match futures::future::select(Box::pin(dynamic.requested_track()), &mut pending).await {
futures::future::Either::Left((request, _)) => request.unwrap(),
_ => panic!("catalog resolved before the publisher answered"),
};
// The publisher is still available and the old session remains alive. Holding
// TRACK_INFO makes the replacement happen during acquisition without sleeps.
let _new = link(version, &publisher, &subscriber, 1).await;
// An epochless replacement restarts the advertisement; a matching epoch only updates it.
let lite07 = version == "moq-lite-07-wip".parse().unwrap();
let new_cost = match announced.next().await {
Some(moq_net::announce::Event::Update(announce)) if lite07 => announce.route.cost,
Some(moq_net::announce::Event::Restart(announce)) if !lite07 => announce.route.cost,
other => panic!("{version}: unexpected route change {other:?}"),
};
assert!(new_cost < old_cost, "the cheaper session wins the route");
let track = request.accept(None);
let mut group = track.append_group().unwrap();
group.write_frame(None, b"catalog".to_vec()).unwrap();
group.finish().unwrap();
let result = pending.await;
if lite07 {
let mut subscription = result.expect("same epoch must acquire");
let mut group = subscription.recv_group().await.unwrap().unwrap();
assert_eq!(group.read_frame().await.unwrap().unwrap().payload.as_ref(), b"catalog");
} else {
assert!(
matches!(result, Err(Error::Unroutable)),
"epochless replacement: {:?}",
result.err()
);
}
}

#[moq_net_sim::test]
async fn epochless_replacement_refuses_pending_catalog() {
acquisition("moq-lite-06").await;
}

#[moq_net_sim::test]
async fn same_epoch_replacement_acquires_pending_catalog() {
acquisition("moq-lite-07-wip").await;
}
Loading