Skip to content

Commit

Permalink
test: increase timeouts for tests that are flaky on slow CI (#2450)
Browse files Browse the repository at this point in the history
## Description

We have some tests that use timeouts to not wait infinitely for an event
that might not be coming. These tests are flaky if the timeout is too
low, especially on windows and likely if the machines are overworked.
This PR increases these timeouts:

* Increase timeout of `test_node_add_tagged_blob_event` from 1s to 10s
(Fixes #2331)
* Increase timeouts of the `pkarr_publish_dns_resolve_*` tests from 2s
to 10s (Fixes #2221)

## Breaking Changes

<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->

## Notes & open questions

<!-- Any notes, remarks or open questions you have to make about the PR.
-->

## Change checklist

- [x] Self-review.
  • Loading branch information
Frando authored Jul 3, 2024
1 parent b34587f commit cc30743
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 9 additions & 8 deletions iroh-net/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,8 @@ mod test_dns_pkarr {
AddrInfo, Endpoint, NodeAddr,
};

const PUBLISH_TIMEOUT: Duration = Duration::from_secs(10);

#[tokio::test]
async fn dns_resolve() -> Result<()> {
let _logging_guard = iroh_test::logging::setup();
Expand Down Expand Up @@ -605,7 +607,6 @@ mod test_dns_pkarr {
let _logging_guard = iroh_test::logging::setup();

let origin = "testdns.example".to_string();
let timeout = Duration::from_secs(2);

let dns_pkarr_server = DnsPkarrServer::run_with_origin(origin.clone()).await?;

Expand All @@ -622,7 +623,7 @@ mod test_dns_pkarr {
// does not block, update happens in background task
publisher.update_addr_info(&addr_info);
// wait until our shared state received the update from pkarr publishing
dns_pkarr_server.on_node(&node_id, timeout).await?;
dns_pkarr_server.on_node(&node_id, PUBLISH_TIMEOUT).await?;
let resolved = resolver.lookup_by_id(&node_id, &origin).await?;

let expected = NodeAddr {
Expand All @@ -640,16 +641,16 @@ mod test_dns_pkarr {
async fn pkarr_publish_dns_discover() -> Result<()> {
let _logging_guard = iroh_test::logging::setup();

let timeout = Duration::from_secs(2);

let dns_pkarr_server = DnsPkarrServer::run().await?;
let (relay_map, _relay_url, _relay_guard) = run_relay_server().await?;

let ep1 = ep_with_discovery(&relay_map, &dns_pkarr_server).await?;
let ep2 = ep_with_discovery(&relay_map, &dns_pkarr_server).await?;

// wait until our shared state received the update from pkarr publishing
dns_pkarr_server.on_node(&ep1.node_id(), timeout).await?;
dns_pkarr_server
.on_node(&ep1.node_id(), PUBLISH_TIMEOUT)
.await?;

// we connect only by node id!
let res = ep2.connect(ep1.node_id().into(), TEST_ALPN).await;
Expand All @@ -661,16 +662,16 @@ mod test_dns_pkarr {
async fn pkarr_publish_dns_discover_empty_node_addr() -> Result<()> {
let _logging_guard = iroh_test::logging::setup();

let timeout = Duration::from_secs(2);

let dns_pkarr_server = DnsPkarrServer::run().await?;
let (relay_map, _relay_url, _relay_guard) = run_relay_server().await?;

let ep1 = ep_with_discovery(&relay_map, &dns_pkarr_server).await?;
let ep2 = ep_with_discovery(&relay_map, &dns_pkarr_server).await?;

// wait until our shared state received the update from pkarr publishing
dns_pkarr_server.on_node(&ep1.node_id(), timeout).await?;
dns_pkarr_server
.on_node(&ep1.node_id(), PUBLISH_TIMEOUT)
.await?;

// we connect only by node id!
let res = ep2.connect(ep1.node_id().into(), TEST_ALPN).await;
Expand Down
4 changes: 2 additions & 2 deletions iroh/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,15 +533,14 @@ mod tests {
}

#[tokio::test]
#[ignore = "flaky"]
async fn test_node_add_tagged_blob_event() -> Result<()> {
let _guard = iroh_test::logging::setup();

let node = Node::memory().bind_port(0).spawn().await?;

let _drop_guard = node.cancel_token().drop_guard();

let _got_hash = tokio::time::timeout(Duration::from_secs(1), async move {
let _got_hash = tokio::time::timeout(Duration::from_secs(10), async move {
let mut stream = node
.blobs()
.add_from_path(
Expand Down Expand Up @@ -626,6 +625,7 @@ mod tests {
}

#[tokio::test]
#[ignore = "flaky"]
async fn test_download_via_relay_with_discovery() -> Result<()> {
let _guard = iroh_test::logging::setup();
let (relay_map, _relay_url, _guard) = iroh_net::test_utils::run_relay_server().await?;
Expand Down

0 comments on commit cc30743

Please sign in to comment.