Skip to content

Commit

Permalink
Merge pull request #4584 from eval-exec/exec/fix-ci
Browse files Browse the repository at this point in the history
Integration Test: decrease restart times and mined blocks count on windows and macos
  • Loading branch information
chenyukang authored Aug 13, 2024
2 parents acdc48f + adf40bb commit 7d0da60
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ fn all_specs() -> Vec<Box<dyn Spec>> {
Box::new(RandomlyKill),
];
specs.shuffle(&mut thread_rng());
specs.append(&mut vec![Box::new(SyncChurn) as Box<dyn Spec>]);
specs.insert(0, Box::new(SyncChurn) as Box<dyn Spec>);
specs
}

Expand Down
15 changes: 12 additions & 3 deletions test/src/specs/sync/sync_churn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ impl Spec for SyncChurn {

let (restart_stopped_tx, restart_stopped_rx) = mpsc::channel();

#[cfg(target_os = "linux")]
const NUM_MINED_BLOCKS: usize = 10000;
#[cfg(target_os = "linux")]
const NUM_RESTART: usize = 100;

#[cfg(not(target_os = "linux"))]
const NUM_MINED_BLOCKS: usize = 1000;
#[cfg(not(target_os = "linux"))]
const NUM_RESTART: usize = 20;

let mining_thread = thread::spawn(move || {
let mut rng = rand::thread_rng();
loop {
Expand All @@ -46,7 +56,7 @@ impl Spec for SyncChurn {
// and the implicit waiting time is not long enough when there are too many blocks to sync,
// so we stop mining when the tip block number is greater than 15000.
// Otherwise nodes may not be able to sync within the implicit waiting time.
let too_many_blocks = mining_node.get_tip_block_number() > 10000;
let too_many_blocks = mining_node.get_tip_block_number() > NUM_MINED_BLOCKS as u64;
if too_many_blocks || restart_stopped_rx.try_recv().is_ok() {
break;
}
Expand All @@ -57,8 +67,7 @@ impl Spec for SyncChurn {
let restart_thread = thread::spawn(move || {
let mut rng = rand::thread_rng();
// It takes about 1 second to restart a node. So restarting nodes 100 times takes about 100 seconds.
let num_restarts = 100;
for _ in 0..num_restarts {
for _ in 0..NUM_RESTART {
let node = select_random_node(&mut rng, &mut churn_nodes);
info!("Restarting node {}", node.node_id());
node.stop();
Expand Down

0 comments on commit 7d0da60

Please sign in to comment.