Skip to content
Merged
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
20 changes: 19 additions & 1 deletion crates/tinydocs-module/tests/module_e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async fn the_built_module_serves_every_format_over_a_real_broker() {
extracts_and_renders_document_intake(&client, &target, &proxy).await;
refuses_a_stream_that_contradicts_the_spec(&client, &target).await;

assert!(matches!(modules.list()[0].state, ModuleState::Ready));
wait_until_idle(&modules).await;
broker_task.abort();
}

Expand Down Expand Up @@ -129,6 +129,24 @@ async fn wait_until_serving(client: &Connection) {
.expect("module should become ready");
}

/// A call reply can reach its caller just before the host retires its in-flight
/// count. Accept that valid `Serving` snapshot briefly, but fail immediately if
/// the module faulted or stopped and require it to settle back to `Ready`.
async fn wait_until_idle(modules: &ModuleHost) {
tokio::time::timeout(Duration::from_secs(5), async {
loop {
let state = modules.list()[0].state.clone();
match state {
ModuleState::Ready => return,
ModuleState::Serving => tokio::task::yield_now().await,
other => panic!("module left service after E2E calls: {other:?}"),
}
}
})
.await
.expect("module should finish serving the final call");
}

/// No inbound payload, a held document out.
async fn generates_a_docx(proxy: &tinybus::Proxy) {
let handle: OutputRef = proxy
Expand Down
Loading