Skip to content

Commit 28ce8cf

Browse files
authored
test: reduce macOS integration flakiness (#5135)
### What problem does this PR solve? Problem Summary: Reduce flaky macOS integration failures in `TransactionRelayConflict` and `SyncChurn`. ### What is changed and how it works? What's Changed: - use tx status checks in `TransactionRelayConflict` - use a longer non-Linux sync timeout in `SyncChurn` ### Related changes ### Check List Tests - Integration test - Manual test (add detailed scripts or steps below) Manual test: - `TransactionRelayConflict` - `SyncChurn`
1 parent c165f40 commit 28ce8cf

3 files changed

Lines changed: 19 additions & 12 deletions

File tree

test/src/node.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -992,10 +992,14 @@ pub fn disconnect_all<N: Borrow<Node>>(nodes: &[N]) {
992992

993993
// TODO it will be removed out later, in another PR
994994
pub fn waiting_for_sync<N: Borrow<Node>>(nodes: &[N]) {
995+
waiting_for_sync_with_timeout(nodes, 120);
996+
}
997+
998+
// TODO it will be removed out later, in another PR
999+
pub fn waiting_for_sync_with_timeout<N: Borrow<Node>>(nodes: &[N], timeout_secs: u64) {
9951000
let mut tip_headers: HashSet<ckb_jsonrpc_types::HeaderView> =
9961001
HashSet::with_capacity(nodes.len());
997-
// 60 seconds is a reasonable timeout to sync, even for poor CI server
998-
let synced = wait_until(120, || {
1002+
let synced = wait_until(timeout_secs, || {
9991003
tip_headers = nodes
10001004
.as_ref()
10011005
.iter()

test/src/specs/relay/transaction_relay.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ impl Spec for TransactionRelayConflict {
265265
.contains("TransactionFailedToResolve: Resolve failed Dead")
266266
);
267267

268-
let relayed = wait_until(20, || {
268+
let relayed = wait_until(60, || {
269269
[tx1.hash()].iter().all(|hash| {
270270
node1
271271
.rpc_client()
@@ -317,7 +317,7 @@ impl Spec for TransactionRelayConflict {
317317
});
318318
assert!(result, "remove txs from node1");
319319

320-
let relayed = wait_until(10, || {
320+
let relayed = wait_until(60, || {
321321
// re-broadcast
322322
let _ = node1
323323
.rpc_client()

test/src/specs/sync/sync_churn.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::node::{make_bootnodes_for_all, waiting_for_sync};
1+
use crate::node::{make_bootnodes_for_all, waiting_for_sync_with_timeout};
22
use crate::util::mining::out_ibd_mode;
33
use crate::{Node, Spec};
44
use ckb_logger::info;
@@ -40,22 +40,25 @@ impl Spec for SyncChurn {
4040
const NUM_MINED_BLOCKS: usize = 10000;
4141
#[cfg(target_os = "linux")]
4242
const NUM_RESTART: usize = 100;
43+
#[cfg(target_os = "linux")]
44+
const SYNC_TIMEOUT_SECS: u64 = 120;
4345

4446
#[cfg(not(target_os = "linux"))]
4547
const NUM_MINED_BLOCKS: usize = 1000;
4648
#[cfg(not(target_os = "linux"))]
4749
const NUM_RESTART: usize = 20;
50+
#[cfg(not(target_os = "linux"))]
51+
const SYNC_TIMEOUT_SECS: u64 = 240;
4852

4953
let mining_thread = thread::spawn(move || {
5054
let mut rng = rand::thread_rng();
5155
loop {
5256
let mining_node = select_random_node(&mut rng, &mut mining_nodes);
5357
mining_node.mine(1);
54-
// Because the test that waiting for nodes to sync has a implicit maximum waiting time
55-
// (currently 60 seconds, we can sync about 200 blocks per second, so a maximum blocks of 10000 is reasonable)
56-
// and the implicit waiting time is not long enough when there are too many blocks to sync,
57-
// so we stop mining when the tip block number is greater than 15000.
58-
// Otherwise nodes may not be able to sync within the implicit waiting time.
58+
// `waiting_for_sync_with_timeout` only waits up to `SYNC_TIMEOUT_SECS`, and we
59+
// can sync about 200 blocks per second, so `NUM_MINED_BLOCKS` should stay within
60+
// that budget for each platform. Otherwise nodes may not be able to sync within
61+
// the configured timeout.
5962
let too_many_blocks = mining_node.get_tip_block_number() > NUM_MINED_BLOCKS as u64;
6063
if too_many_blocks || restart_stopped_rx.try_recv().is_ok() {
6164
break;
@@ -65,7 +68,7 @@ impl Spec for SyncChurn {
6568
mining_node.node_id(),
6669
mining_node.get_tip_block_number()
6770
);
68-
waiting_for_sync(&mining_nodes);
71+
waiting_for_sync_with_timeout(&mining_nodes, SYNC_TIMEOUT_SECS);
6972
}
7073
});
7174

@@ -87,6 +90,6 @@ impl Spec for SyncChurn {
8790
restart_thread.join().unwrap();
8891

8992
info!("Waiting for all nodes sync");
90-
waiting_for_sync(nodes);
93+
waiting_for_sync_with_timeout(nodes, SYNC_TIMEOUT_SECS);
9194
}
9295
}

0 commit comments

Comments
 (0)