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

zndsl: support multiple networks #796

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
29 changes: 29 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,32 @@ db-snapshot:
retry: 2
tags:
- zombienet-polkadot-integration-test

multiple-networks:
stage: deploy
<<: *kubernetes-env
image: "paritypr/zombienet:${CI_COMMIT_SHORT_SHA}"
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_REF_NAME == "master"
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
# needs:
# - job: publish-docker-pr

variables:
GH_DIR: "https://github.com/paritytech/zombienet/tree/${CI_COMMIT_SHORT_SHA}/tests"

before_script:
- echo "Zombienet multiple networks test"
- echo "paritypr/zombienet:${CI_COMMIT_SHORT_SHA}"
- echo "${GH_DIR}"
- export DEBUG=zombie*

script:
- /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh
--test="0014-multiple-networks.zndsl"
allow_failure: true
retry: 2
tags:
- zombienet-polkadot-integration-test
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/parser-wrapper/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dsl-parser-wrapper"
version = "0.1.7"
version = "0.1.8"
edition = "2021"
description = "Zombienet DSL parser: produces a test definition, in json format, that can be used with the ZombieNet's test-runnner."
license = "GPL-3.0-or-later"
Expand Down
2 changes: 1 addition & 1 deletion crates/parser/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub struct Assertion {
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct TestDefinition {
pub description: Option<String>,
pub network: String,
pub networks: Vec<String>,
pub creds: String,
pub assertions: Vec<Assertion>,
}
Expand Down
11 changes: 7 additions & 4 deletions crates/parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ pub fn parse(unparsed_file: &str) -> Result<ast::TestDefinition, errors::ParserE
Err(e) => return Err(errors::ParserError::ParseError(e.to_string())),
};

let mut network: Option<String> = None;
let mut networks: Vec<String> = vec![];
let mut creds: Option<String> = None;
let mut description: Option<String> = None;
let mut assertions: Vec<Assertion> = vec![];
Expand All @@ -233,7 +233,10 @@ pub fn parse(unparsed_file: &str) -> Result<ast::TestDefinition, errors::ParserE
description = Some(record.into_inner().as_str().to_owned());
}
Rule::network => {
network = Some(record.into_inner().as_str().to_owned());
let mut pairs = record.into_inner();
let file_path = get_pair(&mut pairs, "file_path")?.as_str();

networks.push(file_path.to_owned());
}
Rule::creds => {
let mut pairs = record.into_inner();
Expand Down Expand Up @@ -604,7 +607,7 @@ pub fn parse(unparsed_file: &str) -> Result<ast::TestDefinition, errors::ParserE
}
}

if network.is_none() || creds.is_none() {
if networks.is_empty() || creds.is_none() {
return Err(errors::ParserError::MissingFields(String::from(
"Missing Network/Creds field",
)));
Expand All @@ -613,7 +616,7 @@ pub fn parse(unparsed_file: &str) -> Result<ast::TestDefinition, errors::ParserE
// unwrap here should be face because of the above test.
let test_def = TestDefinition {
description,
network: network.unwrap(),
networks,
creds: creds.unwrap(),
assertions,
};
Expand Down
101 changes: 80 additions & 21 deletions crates/parser/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
use super::*;

const NETWORK: &str = "Network: ./a.toml";
const NETWORK: &str = "Network: ./a.toml\n\
Network: ./b.toml";
const CREDS: &str = "Creds: config";

#[test]
fn restart_parse_ok() {
let line: &str = "alice: restart after 60 seconds";
let data = r#"{
"description": null,
"network": "./a.toml",
"networks": [
"./a.toml",
"./b.toml"
],
"creds": "config",
"assertions": [
{
Expand All @@ -34,7 +38,9 @@ fn is_up_parse_ok() {
let line: &str = "alice: is up within 5 secs";
let data = r#"{
"description": null,
"network": "./a.toml",
"networks": [
"./a.toml",
"./b.toml"],
"creds": "config",
"assertions": [
{
Expand All @@ -60,7 +66,9 @@ fn is_up_without_timeout_parse_ok() {
let line: &str = "alice: is up";
let data = r#"{
"description": null,
"network": "./a.toml",
"networks": [
"./a.toml",
"./b.toml"],
"creds": "config",
"assertions": [
{
Expand All @@ -86,7 +94,10 @@ fn para_is_registered_parse_ok() {
let line: &str = "alice: parachain 100 is registered within 225 seconds";
let data = r#"{
"description": null,
"network": "./a.toml",
"networks": [
"./a.toml",
"./b.toml"
],
"creds": "config",
"assertions": [
{
Expand All @@ -113,7 +124,10 @@ fn histogram_parse_ok() {
let line: &str = r#"alice: reports histogram polkadot_pvf_preparation_time has at least 1 samples in buckets ["0.1", "0.5", "1", "2", "3", "10"] within 10 seconds"#;
let data = r#"{
"description": null,
"network": "./a.toml",
"networks": [
"./a.toml",
"./b.toml"
],
"creds": "config",
"assertions": [
{
Expand Down Expand Up @@ -143,7 +157,10 @@ fn report_parse_ok() {
let line: &str = r#"eve: reports parachain_candidate_dispute_concluded{validity="invalid"} is 0 within 15 seconds"#;
let data = r#"{
"description": null,
"network": "./a.toml",
"networks": [
"./a.toml",
"./b.toml"
],
"creds": "config",
"assertions": [
{
Expand Down Expand Up @@ -172,7 +189,10 @@ fn para_dummy_upgrade_parse_ok() {
let line: &str = r#"alice: parachain 100 perform dummy upgrade within 200 seconds"#;
let data = r#"{
"description": null,
"network": "./a.toml",
"networks": [
"./a.toml",
"./b.toml"
],
"creds": "config",
"assertions": [
{
Expand Down Expand Up @@ -200,7 +220,10 @@ fn para_upgrade_parse_ok() {
r#"alice: parachain 100 perform upgrade with ./some.wasm.compact within 200 seconds"#;
let data = r#"{
"description": null,
"network": "./a.toml",
"networks": [
"./a.toml",
"./b.toml"
],
"creds": "config",
"assertions": [
{
Expand Down Expand Up @@ -228,7 +251,10 @@ fn log_match_parse_ok() {
let line: &str = r#"alice: log line contains "Imported #12" within 20 seconds"#;
let data = r#"{
"description": null,
"network": "./a.toml",
"networks": [
"./a.toml",
"./b.toml"
],
"creds": "config",
"assertions": [
{
Expand Down Expand Up @@ -256,7 +282,10 @@ fn log_match_parse_glob_ok() {
let line: &str = r#"alice: log line contains glob "Imported #12" within 20 seconds"#;
let data = r#"{
"description": null,
"network": "./a.toml",
"networks": [
"./a.toml",
"./b.toml"
],
"creds": "config",
"assertions": [
{
Expand Down Expand Up @@ -284,7 +313,10 @@ fn log_match_glob_parse_ok() {
let line: &str = r#"alice: log line matches glob "*rted #1*" within 10 seconds"#;
let data = r#"{
"description": null,
"network": "./a.toml",
"networks": [
"./a.toml",
"./b.toml"
],
"creds": "config",
"assertions": [
{
Expand Down Expand Up @@ -313,7 +345,10 @@ fn count_log_match_equal_parse_ok() {
r#"alice: count of log lines containing "Imported #12" is 0 within 20 seconds"#;
let data = r#"{
"description": null,
"network": "./a.toml",
"networks": [
"./a.toml",
"./b.toml"
],
"creds": "config",
"assertions": [
{
Expand Down Expand Up @@ -344,7 +379,10 @@ fn count_log_match_is_at_least_parse_ok() {
r#"alice: count of log lines containing "Imported #12" is at least 12 within 20 seconds"#;
let data = r#"{
"description": null,
"network": "./a.toml",
"networks": [
"./a.toml",
"./b.toml"
],
"creds": "config",
"assertions": [
{
Expand Down Expand Up @@ -375,7 +413,10 @@ fn count_log_match_glob_equal_parse_ok() {
r#"alice: count of log lines containing glob "Imported #12" is 10 within 20 seconds"#;
let data = r#"{
"description": null,
"network": "./a.toml",
"networks": [
"./a.toml",
"./b.toml"
],
"creds": "config",
"assertions": [
{
Expand Down Expand Up @@ -406,7 +447,10 @@ fn count_log_match_glob_is_at_least_parse_ok() {
r#"alice: count of log lines matching glob "*rted #1*" is at least 5 within 10 seconds"#;
let data = r#"{
"description": null,
"network": "./a.toml",
"networks": [
"./a.toml",
"./b.toml"
],
"creds": "config",
"assertions": [
{
Expand Down Expand Up @@ -436,7 +480,10 @@ fn trace_parse_ok() {
let line: &str = r#"alice: trace with traceID 94c1501a78a0d83c498cc92deec264d9 contains ["answer-chunk-request", "answer-chunk-request"]"#;
let data = r#"{
"description": null,
"network": "./a.toml",
"networks": [
"./a.toml",
"./b.toml"
],
"creds": "config",
"assertions": [
{
Expand Down Expand Up @@ -464,7 +511,10 @@ fn system_event_parse_ok() {
let line: &str = r#"alice: system event contains "A candidate was included" within 20 seconds"#;
let data = r#"{
"description": null,
"network": "./a.toml",
"networks": [
"./a.toml",
"./b.toml"
],
"creds": "config",
"assertions": [
{
Expand Down Expand Up @@ -492,7 +542,10 @@ fn custom_js_parse_ok() {
let line: &str = r#"alice: js-script ./0008-custom.js within 200 seconds"#;
let data = r#"{
"description": null,
"network": "./a.toml",
"networks": [
"./a.toml",
"./b.toml"
],
"creds": "config",
"assertions": [
{
Expand Down Expand Up @@ -521,7 +574,10 @@ fn custom_js_with_args_parse_ok() {
r#"alice: js-script ./0008-custom.js with "dave,2000-1,eve" within 200 seconds"#;
let data = r#"{
"description": null,
"network": "./a.toml",
"networks": [
"./a.toml",
"./b.toml"
],
"creds": "config",
"assertions": [
{
Expand Down Expand Up @@ -549,7 +605,10 @@ fn custom_sh_parse_ok() {
let line: &str = r#"alice: run ./0008-custom.sh within 200 seconds"#;
let data = r#"{
"description": null,
"network": "./a.toml",
"networks": [
"./a.toml",
"./b.toml"
],
"creds": "config",
"assertions": [
{
Expand Down
2 changes: 1 addition & 1 deletion crates/parser/src/zombienet.pest
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ comment = ${ ("#" | "//") ~ (!NEWLINE ~ ANY)+ }

file = { SOI ~ (
description? ~
network ~
network+ ~
creds
) ~ (
comment |
Expand Down
17 changes: 17 additions & 0 deletions examples/0005-multiple-networks.zndsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Description: Multiple Networks test
Network: ./0000-test-config-small-network.toml
Network: ./0003-big-network.toml
Creds: config

# 0000-test-config-small-network - metrics
alice: reports node_roles is 4
alice: reports sub_libp2p_is_major_syncing is 0

# 0000-test-config-small-network - logs
bob: log line matches glob "*rted #1*" within 10 seconds
bob: log line matches "Imported #[0-9]+" within 10 seconds

# 0003-big-network - metrics
a: reports node_roles is 4
b: reports sub_libp2p_is_major_syncing is 0

Loading