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

Add Chaos support to CLI #1507

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 6 additions & 0 deletions crates/parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,12 @@ pub fn parse(unparsed_file: &str) -> Result<ast::TestDefinition, errors::ParserE
assertions.push(assertion);
}
Rule::EOI | Rule::comment => (),
Rule::setter => {
println!("Setter!!");
}
Rule::remover => {
println!("Remover!!");
}
_ => {
return Err(errors::ParserError::InvalidRule(record.as_str().to_owned()));
}
Expand Down
10 changes: 9 additions & 1 deletion crates/parser/src/zombienet.pest
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ span_id = { ASCII_HEX_DIGIT{32} }
block_height = { "blockheight" | "block height" | "best block" }
finalized_height = { "finalised height" | "finalised block" }
peers_count = { "peers count" | "peers" }
chaos_type = { "latency" | "jitter" | "correlation" }
wirednkod marked this conversation as resolved.
Show resolved Hide resolved

metric_name = @{ (block_height | finalized_height | peers_count | (ASCII_ALPHANUMERIC | "_" )+) ~ ("{" ~ metric_key_value ~ "}")? }
square_brackets_strings = {
Expand All @@ -51,6 +52,7 @@ math_ops = { plus | minus }
// commons
node_name = { name ~ colon }
seconds = _{ "seconds"|"secs"|"s" }
miliseconds = _{ "miliseconds"|"ms"|"msecs" }
within = { "within" ~ int+ ~ seconds }
parachain = { "parachain" ~ int+ }

Expand Down Expand Up @@ -83,6 +85,10 @@ pause = { node_name ~ "pause" }
resume = { node_name ~ "resume" }
restart = { node_name ~ "restart" ~ ("after" ~ int+ ~ seconds)? }

// CHAOS COMMANDS
setter = { node_name ~ "set" ~ chaos_type ~ "by" ~ int+ ~ (seconds | miliseconds)}
remover = { node_name ~ "remove" ~ chaos_type }
wirednkod marked this conversation as resolved.
Show resolved Hide resolved

/// COMMENTS
comment = ${ ("#" | "//") ~ (!NEWLINE ~ ANY)* }

Expand Down Expand Up @@ -111,5 +117,7 @@ file = { SOI ~ (
sleep |
pause |
resume |
restart
restart |
setter |
remover
)* ~ NEWLINE* ~ EOI }
3 changes: 2 additions & 1 deletion tests/chaos/0001-delay.zndsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ Creds: config
# alice to bob take at least 2s
alice: run ./delay_check.sh with "bob,9615,2" within 30 seconds
# bob to alice take at least 1s
bob: run ./delay_check.sh within 30 seconds
bob: run ./delay_check.sh within 30 seconds
bob: remove latency
3 changes: 2 additions & 1 deletion tests/chaos/delay_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
POD=$1
PORT=$2 # 9615 for prometheus
DELAY=$3
TAKE=$(/cfg/curl -w "%{time_connect}" -so /dev/null http://$POD:$PORT/ |awk -F "." '{print $1}')
## For mac the `confi/curl` needs to be replaced with `curl`
TAKE=$(curl -w "%{time_connect}" -so /dev/null http://$POD:$PORT/ |awk -F "." '{print $1}')
if [[ $TAKE -ge $DELAY ]]; then
exit 0;
fi
Expand Down