Skip to content

Commit

Permalink
Add duration parameter for the chaos deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
IAvecilla committed Mar 11, 2024
1 parent 478eef8 commit 20b7c4d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion node/tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub async fn delay_test(test_result: Arc<Mutex<u8>>) -> anyhow::Result<()> {
let ip = k8s::get_node_rpc_address_with_name(&client, target_node)
.await
.unwrap();
add_chaos_delay_for_node(&client, target_node)
add_chaos_delay_for_node(&client, target_node, 10)
.await
.unwrap();
let url: String = format!("http://{}", ip);
Expand Down
9 changes: 7 additions & 2 deletions node/tools/src/k8s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use kube::{
core::{ObjectList, ObjectMeta},
Api, Client, ResourceExt,
};
use serde::de::IntoDeserializer;
use std::{
collections::{BTreeMap, HashMap},
net::SocketAddr,
Expand Down Expand Up @@ -351,7 +352,11 @@ pub async fn expose_tester_rpc(client: &Client) -> anyhow::Result<()> {
Ok(())
}

pub async fn add_chaos_delay_for_node(client: &Client, node_name: &str) -> anyhow::Result<()> {
pub async fn add_chaos_delay_for_node(
client: &Client,
node_name: &str,
duration_secs: u8,
) -> anyhow::Result<()> {
let chaos = NetworkChaos::new(
"chaos-delay",
NetworkChaosSpec {
Expand All @@ -365,7 +370,7 @@ pub async fn add_chaos_delay_for_node(client: &Client, node_name: &str) -> anyho
latency: "1000ms".to_string(),
..Default::default()
},
duration: Some("10s".to_string()),
duration: format!("{}s", duration_secs).into(),
},
);

Expand Down

0 comments on commit 20b7c4d

Please sign in to comment.