Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration Test: decrease restart times and mined blocks count on windows and macos #4584

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading