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
18 changes: 11 additions & 7 deletions iroh/src/magicsock/transports/relay/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,6 @@ mod tests {

#[tokio::test]
#[traced_test]
#[ignore = "flaky"]
async fn test_active_relay_inactive() -> Result {
let (_relay_map, relay_url, _server) = test_utils::run_relay_server().await?;

Expand All @@ -1481,11 +1480,11 @@ mod tests {
);

// Wait until the actor is connected to the relay server.
tokio::time::timeout(Duration::from_millis(200), async {
tokio::time::timeout(Duration::from_secs(5), async {
loop {
let (tx, rx) = oneshot::channel();
inbox_tx.send(ActiveRelayMessage::PingServer(tx)).await.ok();
if tokio::time::timeout(Duration::from_millis(100), rx)
if tokio::time::timeout(Duration::from_millis(200), rx)
.await
.map(|resp| resp.is_ok())
.unwrap_or_default()
Expand All @@ -1497,12 +1496,12 @@ mod tests {
.await
.std_context("timeout")?;

// From now on, we pause time
tokio::time::pause();
// We now have an idling ActiveRelayActor. If we advance time just a little it
// should stay alive.
info!("Stepping time forwards by RELAY_INACTIVE_CLEANUP_TIME / 2");
tokio::time::pause();
tokio::time::advance(RELAY_INACTIVE_CLEANUP_TIME / 2).await;
tokio::time::resume();

assert!(
tokio::time::timeout(Duration::from_millis(100), &mut task)
Expand All @@ -1513,15 +1512,20 @@ mod tests {

// If we advance time a lot it should finish.
info!("Stepping time forwards by RELAY_INACTIVE_CLEANUP_TIME");
tokio::time::pause();
tokio::time::advance(RELAY_INACTIVE_CLEANUP_TIME).await;
tokio::time::resume();

// We resume time for these timeouts, as there's actual I/O happening,
// for example closing the TCP stream, so we actually need the tokio
// runtime to idle a bit while the kernel is doing its thing.
assert!(
tokio::time::timeout(Duration::from_millis(1000), task)
tokio::time::timeout(Duration::from_secs(1), task)
.await
.is_ok(),
"actor task still running"
);

tokio::time::resume();
cancel_token.cancel();
Ok(())
}
Expand Down
Loading