From 73fdf719eee607f13a6e4ec02d0afb38e3971da8 Mon Sep 17 00:00:00 2001 From: Raymond Khalife Date: Fri, 17 Oct 2025 10:30:48 -0400 Subject: [PATCH 1/2] chore: increase timeout for test network and reduce logs --- crates/icp-cli/tests/common/context.rs | 7 ++++--- crates/icp/src/network/managed/run.rs | 10 ++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/icp-cli/tests/common/context.rs b/crates/icp-cli/tests/common/context.rs index 43197093..58193bea 100644 --- a/crates/icp-cli/tests/common/context.rs +++ b/crates/icp-cli/tests/common/context.rs @@ -229,7 +229,7 @@ impl TestContext { .success(); } - // wait up to 30 seconds for descriptor path to contain valid json + // wait up for descriptor path to contain valid json pub fn wait_for_local_network_descriptor(&self, project_dir: &Path) -> TestNetwork { self.wait_for_network_descriptor(project_dir, "local") } @@ -245,8 +245,9 @@ impl TestContext { .join(network_name) .join("descriptor.json"); let start_time = std::time::Instant::now(); + let timeout = 45; + eprintln!("Waiting for network descriptor at {descriptor_path} - limit {timeout}s"); let network_descriptor = loop { - eprintln!("Checking for network descriptor at {descriptor_path}"); if descriptor_path.exists() && descriptor_path.is_file() { let contents = fs::read_to_string(&descriptor_path) .expect("Failed to read network descriptor"); @@ -260,7 +261,7 @@ impl TestContext { ); } } - if start_time.elapsed().as_secs() > 30 { + if start_time.elapsed().as_secs() > timeout { panic!("Timed out waiting for network descriptor at {descriptor_path}"); } std::thread::sleep(std::time::Duration::from_millis(100)); diff --git a/crates/icp/src/network/managed/run.rs b/crates/icp/src/network/managed/run.rs index 0e1045f5..702a9b3d 100644 --- a/crates/icp/src/network/managed/run.rs +++ b/crates/icp/src/network/managed/run.rs @@ -196,8 +196,9 @@ async fn wait_for_shutdown(child: &mut Child) -> ShutdownReason { } pub async fn wait_for_port_file(path: &Path) -> Result { - let mut retries = 0; - while retries < 3000 { + let start_time = std::time::Instant::now(); + + loop { if let Ok(contents) = read_to_string(path) && contents.ends_with('\n') && let Ok(port) = contents.trim().parse::() @@ -205,10 +206,11 @@ pub async fn wait_for_port_file(path: &Path) -> Result 30 { + return Err(WaitForPortTimeoutError) + } sleep(Duration::from_millis(100)).await; - retries += 1; } - Err(WaitForPortTimeoutError) } #[derive(Debug, Snafu)] From 5411ec520fd9582db6977420abcc4da343470e83 Mon Sep 17 00:00:00 2001 From: Raymond Khalife Date: Fri, 17 Oct 2025 10:35:57 -0400 Subject: [PATCH 2/2] add more info to logs --- crates/icp-cli/tests/common/context.rs | 9 ++++++--- crates/icp/src/network/managed/run.rs | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/icp-cli/tests/common/context.rs b/crates/icp-cli/tests/common/context.rs index 58193bea..5d8c9386 100644 --- a/crates/icp-cli/tests/common/context.rs +++ b/crates/icp-cli/tests/common/context.rs @@ -248,12 +248,13 @@ impl TestContext { let timeout = 45; eprintln!("Waiting for network descriptor at {descriptor_path} - limit {timeout}s"); let network_descriptor = loop { + let elapsed = start_time.elapsed().as_secs(); if descriptor_path.exists() && descriptor_path.is_file() { let contents = fs::read_to_string(&descriptor_path) .expect("Failed to read network descriptor"); let parsed = serde_json::from_str::(&contents); if let Ok(value) = parsed { - eprintln!("Network descriptor found at {descriptor_path}"); + eprintln!("Network descriptor found at {descriptor_path} after {elapsed}s"); break value; } else { eprintln!( @@ -261,8 +262,10 @@ impl TestContext { ); } } - if start_time.elapsed().as_secs() > timeout { - panic!("Timed out waiting for network descriptor at {descriptor_path}"); + if elapsed > timeout { + panic!( + "Timed out waiting for network descriptor at {descriptor_path} after {elapsed}s" + ); } std::thread::sleep(std::time::Duration::from_millis(100)); }; diff --git a/crates/icp/src/network/managed/run.rs b/crates/icp/src/network/managed/run.rs index 702a9b3d..e9a25576 100644 --- a/crates/icp/src/network/managed/run.rs +++ b/crates/icp/src/network/managed/run.rs @@ -207,7 +207,7 @@ pub async fn wait_for_port_file(path: &Path) -> Result 30 { - return Err(WaitForPortTimeoutError) + return Err(WaitForPortTimeoutError); } sleep(Duration::from_millis(100)).await; }