1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#![forbid(unsafe_code)]
use std::{cmp::min, env};
use crate::{
cluster::Cluster,
experiments::{
CompatiblityTestParams, CpuFlamegraphParams, Experiment, ExperimentParam,
PerformanceBenchmarkParams, PerformanceBenchmarkThreeRegionSimulationParams,
RebootRandomValidatorsParams, ReconfigurationParams, RecoveryTimeParams,
StateSyncPerformanceParams, TwinValidatorsParams, ValidatorVersioningParams,
},
};
use anyhow::{format_err, Result};
pub struct ExperimentSuite {
pub experiments: Vec<Box<dyn Experiment>>,
}
impl ExperimentSuite {
fn new_pre_release(cluster: &Cluster) -> Self {
let mut experiments: Vec<Box<dyn Experiment>> = vec![];
if env::var("RECOVERY_EXP").is_ok() {
experiments.push(Box::new(
RecoveryTimeParams {
num_accounts_to_mint: 100_000,
}
.build(cluster),
));
}
let count = min(3, cluster.validator_instances().len() / 3);
for _ in 0..10 {
let b = Box::new(RebootRandomValidatorsParams::new(count, 0).build(cluster));
experiments.push(b);
}
experiments.push(Box::new(
PerformanceBenchmarkParams::non_zero_gas_price(0, 1)
.enable_db_backup()
.build(cluster),
));
experiments.push(Box::new(
PerformanceBenchmarkParams::new_nodes_down(0)
.enable_db_backup()
.build(cluster),
));
experiments.push(Box::new(
PerformanceBenchmarkParams::new_nodes_down(10)
.enable_db_backup()
.build(cluster),
));
experiments.push(Box::new(
PerformanceBenchmarkThreeRegionSimulationParams {}.build(cluster),
));
experiments.push(Box::new(
PerformanceBenchmarkParams::new_fixed_tps(0, 10)
.enable_db_backup()
.build(cluster),
));
experiments.push(Box::new(StateSyncPerformanceParams::new(60).build(cluster)));
experiments.push(Box::new(TwinValidatorsParams { pair: 1 }.build(cluster)));
experiments.push(Box::new(
ReconfigurationParams {
count: 101,
emit_txn: false,
}
.build(cluster),
));
experiments.push(Box::new(
CpuFlamegraphParams { duration_secs: 60 }.build(cluster),
));
Self { experiments }
}
fn new_twin_suite(cluster: &Cluster) -> Self {
let experiments: Vec<Box<dyn Experiment>> = vec![
Box::new(TwinValidatorsParams { pair: 1 }.build(cluster)),
Box::new(CpuFlamegraphParams { duration_secs: 60 }.build(cluster)),
];
Self { experiments }
}
fn new_perf_suite(cluster: &Cluster) -> Self {
let experiments: Vec<Box<dyn Experiment>> = vec![
Box::new(PerformanceBenchmarkParams::new_nodes_down(0).build(cluster)),
Box::new(PerformanceBenchmarkParams::new_nodes_down(10).build(cluster)),
Box::new(PerformanceBenchmarkThreeRegionSimulationParams {}.build(cluster)),
Box::new(PerformanceBenchmarkParams::new_fixed_tps(0, 10).build(cluster)),
];
Self { experiments }
}
fn new_land_blocking_suite(cluster: &Cluster) -> Self {
let experiments: Vec<Box<dyn Experiment>> = vec![Box::new(
PerformanceBenchmarkParams::new_nodes_down(0).build(cluster),
)];
Self { experiments }
}
fn new_land_blocking_compat_suite(cluster: &Cluster) -> Result<Self> {
let count: usize = match env::var("BATCH_SIZE") {
Ok(val) => val
.parse()
.map_err(|e| format_err!("Failed to parse BATCH_SIZE {}: {}", val, e))?,
Err(_) => cluster.validator_instances().len() / 2,
};
let updated_image_tag = env::var("UPDATE_TO_TAG")
.map_err(|_| format_err!("Expected environment variable UPDATE_TO_TAG"))?;
let mut experiments: Vec<Box<dyn Experiment>> = vec![Box::new(
CompatiblityTestParams {
count,
updated_image_tag,
}
.build(cluster),
)];
experiments.extend(Self::new_land_blocking_suite(cluster).experiments);
Ok(Self { experiments })
}
fn new_versioning_suite(cluster: &Cluster) -> Result<Self> {
let count: usize = match env::var("BATCH_SIZE") {
Ok(val) => val
.parse()
.map_err(|e| format_err!("Failed to parse BATCH_SIZE {}: {}", val, e))?,
Err(_) => cluster.validator_instances().len() / 2,
};
let updated_image_tag = env::var("UPDATE_TO_TAG")
.map_err(|_| format_err!("Expected environment variable UPDATE_TO_TAG"))?;
let experiments: Vec<Box<dyn Experiment>> = vec![Box::new(
ValidatorVersioningParams {
count,
updated_image_tag,
}
.build(cluster),
)];
Ok(Self { experiments })
}
fn new_invalid_tx_suite(cluster: &Cluster) -> Self {
let experiments: Vec<Box<dyn Experiment>> = vec![
Box::new(PerformanceBenchmarkParams::new_nodes_down(0).build(cluster)),
Box::new(PerformanceBenchmarkParams::mix_invalid_tx(0, 10).build(cluster)),
];
Self { experiments }
}
fn new_state_sync_suite(cluster: &Cluster) -> Self {
let experiments: Vec<Box<dyn Experiment>> =
vec![Box::new(StateSyncPerformanceParams::new(60).build(cluster))];
Self { experiments }
}
pub fn new_by_name(cluster: &Cluster, name: &str) -> Result<Self> {
match name {
"perf" => Ok(Self::new_perf_suite(cluster)),
"pre_release" => Ok(Self::new_pre_release(cluster)),
"twin" => Ok(Self::new_twin_suite(cluster)),
"land_blocking" => Ok(Self::new_land_blocking_suite(cluster)),
"land_blocking_compat" => Self::new_land_blocking_compat_suite(cluster),
"versioning" => Self::new_versioning_suite(cluster),
"invalid" => Ok(Self::new_invalid_tx_suite(cluster)),
"state_sync" => Ok(Self::new_state_sync_suite(cluster)),
other => Err(format_err!("Unknown suite: {}", other)),
}
}
}