Add chaotic run too

This commit is contained in:
Mahmut Bulut 2020-03-08 13:01:08 +01:00
parent a9b43059a7
commit b2eb74fed7
4 changed files with 64 additions and 6 deletions

View File

@ -33,7 +33,6 @@ pretty_env_logger = "0.4.0"
once_cell = "1.3.1"
criterion = "0.3.1"
[[test]]
name = "chaos_tests"
path = "kaos-tests/launcher.rs"

View File

@ -130,6 +130,7 @@ macro_rules! ap_events_check_node_spawn {
}
}
#[macro_export]
macro_rules! ap_sd_check_node_spawn {
($node_handle:ident) => {

View File

@ -0,0 +1,39 @@
extern crate pretty_env_logger;
#[macro_use]
extern crate log;
mod base;
use base::*;
fn main() {
cluster_init!();
kaostest!("epidemic-periodic-index-fp",
{
// What Bastion does is doing this asynchronously. Thanks.
let mut restarts = 0;
loop {
restarts += 1;
ap_events_check_node_spawn!(node1);
ap_events_check_node_spawn!(node2);
ap_events_check_node_spawn!(node3);
run(
async {
future::join_all(
vec![node1, node2, node3]
).await
},
ProcStack::default(),
);
if restarts == 10 {
break;
}
}
}
);
}

View File

@ -14,22 +14,41 @@ fn chaos_tests() {
.into_os_string()
.into_string()
.unwrap()
.contains("launcher")
.contains("launcher") // Filter out itself
&& !path
.clone()
.into_os_string()
.into_string()
.unwrap()
.contains("mod")
.contains("mod") // Filter out module hierarchy
&& !path
.clone()
.into_os_string()
.into_string()
.unwrap()
.contains("base")
.contains("base") // Filter out common code as test
{
// Every service run should be available at least 2 seconds
k.available(path, Duration::from_secs(2));
if path
.clone()
.into_os_string()
.into_string()
.unwrap()
.contains("chaotic") // Chaotic test rather than availability
{
// Let's have 5 varying runs.
let run_count = 5;
// Minimum availability to expect as milliseconds for the runs.
// Which corresponds as maximum surge between service runs.
// Let's have it 10 seconds.
let max_surge = 10 * 1000;
// Run chaotic test.
k.chaotic(path, run_count, max_surge);
} else {
// Every service run should be available at least 2 seconds
k.available(path, Duration::from_secs(2));
}
}
}
}