diff --git a/testsuite/forge-cli/src/main.rs b/testsuite/forge-cli/src/main.rs index 3deb5ebfa71c4..637128f75b23f 100644 --- a/testsuite/forge-cli/src/main.rs +++ b/testsuite/forge-cli/src/main.rs @@ -800,9 +800,12 @@ fn get_multi_region_test(test_name: &str) -> Option { Some(test) } -fn wrap_with_realistic_env(test: T) -> CompositeNetworkTest { +fn wrap_with_realistic_env( + num_validators: usize, + test: T, +) -> CompositeNetworkTest { CompositeNetworkTest::new_with_two_wrappers( - MultiRegionNetworkEmulationTest::default(), + MultiRegionNetworkEmulationTest::default_for_validator_count(num_validators), CpuChaosTest::default(), test, ) @@ -847,8 +850,9 @@ fn wrap_with_two_region_env(test: T) -> CompositeNetwo } fn run_consensus_only_realistic_env_max_tps() -> ForgeConfig { + let num_validators = 20; ForgeConfig::default() - .with_initial_validator_count(NonZeroUsize::new(20).unwrap()) + .with_initial_validator_count(NonZeroUsize::new(num_validators).unwrap()) .with_emit_job( EmitJobRequest::default() .mode(EmitJobMode::MaxLoad { @@ -857,7 +861,7 @@ fn run_consensus_only_realistic_env_max_tps() -> ForgeConfig { .txn_expiration_time_secs(5 * 60), ) .add_network_test(CompositeNetworkTest::new( - MultiRegionNetworkEmulationTest::default(), + MultiRegionNetworkEmulationTest::default_for_validator_count(num_validators), CpuChaosTest::default(), )) .with_genesis_helm_config_fn(Arc::new(|helm_values| { @@ -1108,7 +1112,7 @@ fn realistic_env_sweep_wrap( .with_validator_override_node_config_fn(Arc::new(|config, _| { config.execution.processed_transactions_detailed_counters = true; })) - .add_network_test(wrap_with_realistic_env(test)) + .add_network_test(wrap_with_realistic_env(num_validators, test)) // Test inherits the main EmitJobRequest, so update here for more precise latency measurements .with_emit_job( EmitJobRequest::default().latency_polling_interval(Duration::from_millis(100)), @@ -1377,10 +1381,11 @@ fn workload_vs_perf_benchmark() -> ForgeConfig { } fn realistic_env_graceful_overload(duration: Duration) -> ForgeConfig { + let num_validators = 20; ForgeConfig::default() - .with_initial_validator_count(NonZeroUsize::new(20).unwrap()) + .with_initial_validator_count(NonZeroUsize::new(num_validators).unwrap()) .with_initial_fullnode_count(20) - .add_network_test(wrap_with_realistic_env(TwoTrafficsTest { + .add_network_test(wrap_with_realistic_env(num_validators, TwoTrafficsTest { inner_traffic: EmitJobRequest::default() .mode(EmitJobMode::ConstTps { tps: 15000 }) .init_gas_price_multiplier(20), @@ -1941,7 +1946,7 @@ fn realistic_env_max_load_test( ForgeConfig::default() .with_initial_validator_count(NonZeroUsize::new(num_validators).unwrap()) .with_initial_fullnode_count(num_fullnodes) - .add_network_test(wrap_with_realistic_env(TwoTrafficsTest { + .add_network_test(wrap_with_realistic_env(num_validators, TwoTrafficsTest { inner_traffic: EmitJobRequest::default() .mode(EmitJobMode::MaxLoad { mempool_backlog }) .init_gas_price_multiplier(20), @@ -2002,7 +2007,7 @@ fn realistic_network_tuned_for_throughput_test() -> ForgeConfig { let mut forge_config = ForgeConfig::default() .with_initial_validator_count(NonZeroUsize::new(VALIDATOR_COUNT).unwrap()) - .add_network_test(MultiRegionNetworkEmulationTest::default()) + .add_network_test(MultiRegionNetworkEmulationTest::default_for_validator_count(VALIDATOR_COUNT)) .with_emit_job(EmitJobRequest::default().mode(EmitJobMode::MaxLoad { mempool_backlog: (TARGET_TPS as f64 * VFN_LATENCY_S) as usize, })) @@ -2315,8 +2320,9 @@ fn quorum_store_reconfig_enable_test() -> ForgeConfig { } fn mainnet_like_simulation_test() -> ForgeConfig { + let num_validators = 20; ForgeConfig::default() - .with_initial_validator_count(NonZeroUsize::new(20).unwrap()) + .with_initial_validator_count(NonZeroUsize::new(num_validators).unwrap()) .with_emit_job( EmitJobRequest::default() .mode(EmitJobMode::MaxLoad { @@ -2325,7 +2331,7 @@ fn mainnet_like_simulation_test() -> ForgeConfig { .txn_expiration_time_secs(5 * 60), ) .add_network_test(CompositeNetworkTest::new( - MultiRegionNetworkEmulationTest::default(), + MultiRegionNetworkEmulationTest::default_for_validator_count(num_validators), CpuChaosTest::default(), )) .with_genesis_helm_config_fn(Arc::new(|helm_values| { diff --git a/testsuite/forge-cli/src/suites/dag.rs b/testsuite/forge-cli/src/suites/dag.rs index f309c6403cba1..1e0848db8d307 100644 --- a/testsuite/forge-cli/src/suites/dag.rs +++ b/testsuite/forge-cli/src/suites/dag.rs @@ -60,7 +60,7 @@ fn dag_realistic_env_max_load_test( ForgeConfig::default() .with_initial_validator_count(NonZeroUsize::new(num_validators).unwrap()) .with_initial_fullnode_count(num_fullnodes) - .add_network_test(wrap_with_realistic_env(TwoTrafficsTest { + .add_network_test(wrap_with_realistic_env(num_validators, TwoTrafficsTest { inner_traffic: EmitJobRequest::default() .mode(EmitJobMode::MaxLoad { mempool_backlog: 50000, diff --git a/testsuite/testcases/src/data/six_region_link_stats.csv b/testsuite/testcases/src/data/six_region_link_stats.csv new file mode 100644 index 0000000000000..d8c2d6c6766a3 --- /dev/null +++ b/testsuite/testcases/src/data/six_region_link_stats.csv @@ -0,0 +1,31 @@ +sending_region,receiving_region,bitrate_bps,avgrtt +gcp--us-central1,aws--eu-west-1,300000000,103.435 +gcp--us-central1,aws--ap-northeast-1,300000000,133.996 +gcp--us-central1,aws--sa-east-1,300000000,145.483 +gcp--us-central1,gcp--as-southeast-1,300000000,195.763 +gcp--us-central1,gcp--australia-southeast1,300000000,175.426 +aws--sa-east-1,gcp--us-central1,300000000,145.703 +aws--sa-east-1,aws--eu-west-1,300000000,176.894 +aws--sa-east-1,aws--ap-northeast-1,300000000,255.289 +aws--sa-east-1,gcp--as-southeast-1,300000000,329.213 +aws--sa-east-1,gcp--australia-southeast1,300000000,305.157 +aws--eu-west-1,gcp--us-central1,300000000,104.169 +aws--eu-west-1,aws--sa-east-1,300000000,176.813 +aws--eu-west-1,aws--ap-northeast-1,300000000,198.555 +aws--eu-west-1,gcp--as-southeast-1,300000000,211.419 +aws--eu-west-1,gcp--australia-southeast1,300000000,271.738 +aws--ap-northeast-1,gcp--us-central1,300000000,128.999 +aws--ap-northeast-1,aws--eu-west-1,300000000,198.539 +aws--ap-northeast-1,aws--sa-east-1,300000000,255.323 +aws--ap-northeast-1,gcp--as-southeast-1,300000000,72.837 +aws--ap-northeast-1,gcp--australia-southeast1,300000000,144.842 +gcp--as-southeast-1,gcp--us-central1,300000000,195.763 +gcp--as-southeast-1,aws--sa-east-1,300000000,329.213 +gcp--as-southeast-1,aws--eu-west-1,300000000,211.419 +gcp--as-southeast-1,aws--ap-northeast-1,300000000,72.837 +gcp--as-southeast-1,gcp--australia-southeast1,300000000,94.512 +gcp--australia-southeast1,gcp--us-central1,300000000,175.426 +gcp--australia-southeast1,aws--sa-east-1,300000000,305.157 +gcp--australia-southeast1,aws--eu-west-1,300000000,271.738 +gcp--australia-southeast1,aws--ap-northeast-1,300000000,144.842 +gcp--australia-southeast1,gcp--as-southeast-1,300000000,94.512 \ No newline at end of file diff --git a/testsuite/testcases/src/multi_region_network_test.rs b/testsuite/testcases/src/multi_region_network_test.rs index 840d37699152e..06b491ccdcbd0 100644 --- a/testsuite/testcases/src/multi_region_network_test.rs +++ b/testsuite/testcases/src/multi_region_network_test.rs @@ -19,6 +19,7 @@ use std::{collections::BTreeMap, sync::Arc}; /// is measuring TCP bandwidth only which is primarily affected by RTT, and not the actual bandwidth /// across the regions, which would vary according to competing traffic, etc. const FOUR_REGION_LINK_STATS: &[u8] = include_bytes!("data/four_region_link_stats.csv"); +const SIX_REGION_LINK_STATS: &[u8] = include_bytes!("data/six_region_link_stats.csv"); /// The two regions were chosen as the most distant regions among the four regions set. const TWO_REGION_LINK_STATS: &[u8] = include_bytes!("data/two_region_link_stats.csv"); @@ -79,8 +80,8 @@ fn create_link_stats_table_with_peer_groups( "At least 2 regions are required for inter-region network chaos." ); assert!( - number_of_regions <= 4, - "ChaosMesh only supports simulating up to 4 regions." + number_of_regions <= 6, + "ChaosMesh only supports simulating up to 6 regions." ); // Create the link stats table with peer groups @@ -223,7 +224,7 @@ pub struct MultiRegionNetworkEmulationConfig { impl Default for MultiRegionNetworkEmulationConfig { fn default() -> Self { Self { - link_stats_table: get_link_stats_table(FOUR_REGION_LINK_STATS), + link_stats_table: get_link_stats_table(SIX_REGION_LINK_STATS), inter_region_config: InterRegionNetEmConfig::default(), intra_region_config: Some(IntraRegionNetEmConfig::default()), } @@ -237,10 +238,23 @@ impl MultiRegionNetworkEmulationConfig { ..Default::default() } } + + pub fn four_region() -> Self { + Self { + link_stats_table: get_link_stats_table(FOUR_REGION_LINK_STATS), + ..Default::default() + } + } + + pub fn six_region() -> Self { + Self { + link_stats_table: get_link_stats_table(SIX_REGION_LINK_STATS), + ..Default::default() + } + } } /// A test to emulate network conditions for a multi-region setup. -#[derive(Default)] pub struct MultiRegionNetworkEmulationTest { network_emulation_config: MultiRegionNetworkEmulationConfig, } @@ -252,6 +266,18 @@ impl MultiRegionNetworkEmulationTest { } } + pub fn default_for_validator_count(num_validators: usize) -> Self { + if num_validators < 20 { + Self { + network_emulation_config: MultiRegionNetworkEmulationConfig::four_region(), + } + } else { + Self { + network_emulation_config: MultiRegionNetworkEmulationConfig::six_region(), + } + } + } + /// Creates a new SwarmNetEm to be injected via chaos. Note: network /// emulation is only done for the validators in the swarm (and not /// the fullnodes).