Skip to content

Commit 2b6c258

Browse files
authored
chore(iroh-relay): Make QAD test non-flaky by using tokio's paused time (#3341)
## Description Use `tokio`'s paused time to make the QAD test non-flaky. We've experienced occasional slowdowns recently every now and then, causing our timeout test to get out of the "acceptable" range. Instead, this test now pauses the time, and will assert that the time that we sleep before considering the datagrams lost forever to be *exactly* 999ms. ## Notes & open questions Doesn't "real world" test the code, but honestly, this is testing that a timeout is set fairly low, so I think this should be acceptable? ## Change checklist <!-- Remove any that are not relevant. --> - [x] Self-review.
1 parent b8b5bc3 commit 2b6c258

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

iroh-relay/src/quic.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl QuicClient {
276276
// we're sacrificing initial throughput, which is fine for
277277
// QAD, which doesn't require us to have good initial throughput.
278278
// It also implies a 999ms probe timeout, which means that
279-
// if the packet gets lots (e.g. because we're probing ipv6, but
279+
// if the packet gets lost (e.g. because we're probing ipv6, but
280280
// ipv6 packets always get lost in our network configuration) we
281281
// time out *closing the connection* after only 999ms.
282282
// Even if the round trip time is bigger than 999ms, this doesn't
@@ -391,7 +391,7 @@ mod tests {
391391
Ok(())
392392
}
393393

394-
#[tokio::test]
394+
#[tokio::test(start_paused = true)]
395395
#[traced_test]
396396
async fn test_qad_client_closes_unresponsive_fast() -> Result {
397397
// create a client-side endpoint
@@ -430,9 +430,7 @@ mod tests {
430430
client_endpoint.wait_idle().await;
431431
let time = Instant::now().duration_since(before);
432432

433-
println!("Closed in {time:?}");
434-
assert!(Duration::from_millis(900) < time);
435-
assert!(time < Duration::from_millis(1800)); // give it some lee-way. Apparently github actions ubuntu runners can be slow?
433+
assert_eq!(time, Duration::from_millis(999));
436434

437435
Ok(())
438436
}

0 commit comments

Comments
 (0)