Skip to content

Commit dcf3f91

Browse files
[e2e-tests][flaky test] bump network start timeout (#564)
1 parent ea5c09d commit dcf3f91

3 files changed

Lines changed: 34 additions & 23 deletions

File tree

crates/e2e-tests/src/bitcoin_node.rs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -145,28 +145,11 @@ impl BitcoinNodeHandle {
145145
}
146146

147147
fn startup_diagnostics(&self) -> String {
148-
let mut diagnostics = Vec::new();
149-
150-
for (label, path) in [
148+
crate::tail_logs(&[
151149
("stderr", &self.stderr_path),
152150
("stdout", &self.stdout_path),
153151
("debug.log", &self.data_dir.join("regtest/debug.log")),
154-
] {
155-
let contents = std::fs::read_to_string(path)
156-
.ok()
157-
.and_then(|contents| {
158-
let lines: Vec<_> = contents.lines().rev().take(20).collect();
159-
if lines.is_empty() {
160-
None
161-
} else {
162-
Some(lines.into_iter().rev().collect::<Vec<_>>().join(" | "))
163-
}
164-
})
165-
.unwrap_or_else(|| format!("<empty or unavailable at {}>", path.display()));
166-
diagnostics.push(format!("{label}: {contents}"));
167-
}
168-
169-
diagnostics.join("; ")
152+
])
170153
}
171154

172155
pub fn generate_blocks(&self, count: u64) -> Result<Vec<BlockHash>> {

crates/e2e-tests/src/lib.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,26 @@ use tempfile::TempDir;
4040
use crate::publish::publish;
4141
use crate::sui_network::sui_binary;
4242

43+
/// Tail the last 20 lines of each named log file, joined into a one-line diagnostic.
44+
pub(crate) fn tail_logs(files: &[(&str, &Path)]) -> String {
45+
let mut diagnostics = Vec::new();
46+
for (label, path) in files {
47+
let contents = std::fs::read_to_string(path)
48+
.ok()
49+
.and_then(|contents| {
50+
let lines: Vec<_> = contents.lines().rev().take(20).collect();
51+
if lines.is_empty() {
52+
None
53+
} else {
54+
Some(lines.into_iter().rev().collect::<Vec<_>>().join(" | "))
55+
}
56+
})
57+
.unwrap_or_else(|| format!("<empty or unavailable at {}>", path.display()));
58+
diagnostics.push(format!("{label}: {contents}"));
59+
}
60+
diagnostics.join("; ")
61+
}
62+
4363
pub struct TestNetworks {
4464
#[allow(unused)]
4565
dir: TempDir,

crates/e2e-tests/src/sui_network.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use tokio::time::sleep;
3636

3737
const DEFAULT_NUM_VALIDATORS: usize = 4;
3838
const DEFAULT_EPOCH_DURATION_MS: u64 = 86_400_000; // 24 hours; tests that need epoch changes should set a shorter duration
39-
const NETWORK_STARTUP_TIMEOUT_SECS: u64 = 60;
39+
const NETWORK_STARTUP_TIMEOUT_SECS: u64 = 120;
4040
const NETWORK_STARTUP_POLL_INTERVAL_SECS: u64 = 1;
4141

4242
pub fn sui_binary() -> &'static Path {
@@ -60,7 +60,7 @@ pub fn sui_binary() -> &'static Path {
6060
.as_path()
6161
}
6262

63-
async fn wait_for_ready(client: &mut Client) -> Result<()> {
63+
async fn wait_for_ready(client: &mut Client, dir: &Path) -> Result<()> {
6464
// Wait till the network has started up and at least one checkpoint has been produced
6565
for _ in 0..NETWORK_STARTUP_TIMEOUT_SECS {
6666
if let Ok(resp) = client
@@ -74,11 +74,19 @@ async fn wait_for_ready(client: &mut Client) -> Result<()> {
7474
sleep(Duration::from_secs(NETWORK_STARTUP_POLL_INTERVAL_SECS)).await;
7575
}
7676
anyhow::bail!(
77-
"Network failed to start within {}s timeout",
77+
"Network failed to start within {}s timeout. {}",
7878
NETWORK_STARTUP_TIMEOUT_SECS,
79+
startup_diagnostics(dir),
7980
)
8081
}
8182

83+
fn startup_diagnostics(dir: &Path) -> String {
84+
crate::tail_logs(&[
85+
("stderr", &dir.join("out.stderr")),
86+
("stdout", &dir.join("out.stdout")),
87+
])
88+
}
89+
8290
/// Handle for a Sui network running via pre-compiled binary
8391
pub struct SuiNetworkHandle {
8492
/// Child process running sui
@@ -172,7 +180,7 @@ impl SuiNetworkBuilder {
172180
let rpc_url = format!("http://127.0.0.1:{rpc_port}");
173181

174182
let mut client = sui_rpc::Client::new(&rpc_url)?;
175-
wait_for_ready(&mut client).await?;
183+
wait_for_ready(&mut client, &dir).await?;
176184
let mut sui = SuiNetworkHandle {
177185
process,
178186
dir,

0 commit comments

Comments
 (0)