Skip to content

Commit

Permalink
fix pause/resume and add test case (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
pepoviola authored Aug 8, 2022
1 parent c1b56aa commit 2dd7564
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 56 deletions.
25 changes: 25 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,31 @@ zombienet-tests-integration:
# tags:
# - zombienet-polkadot-integration-test

zombienet-restart-pause-resume:
stage: deploy
<<: *kubernetes-env
image: "paritypr/zombienet:${CI_COMMIT_SHORT_SHA}"
<<: *common-refs

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

before_script:
- echo "Zombienet Tests Logs"
- echo "paritypr/zombienet:${CI_COMMIT_SHORT_SHA}"
- echo "${GH_DIR}"
- export DEBUG=zombie*
- export ZOMBIENET_INTEGRATION_TEST_IMAGE="docker.io/paritypr/polkadot-debug:master"
- export COL_IMAGE="docker.io/paritypr/colander:4519"

script:
- /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh
--test="0002-restart-pause-resume-node.feature"
allow_failure: true
retry: 2
tags:
- zombienet-polkadot-integration-test

zombienet-logs-assertion:
stage: deploy
<<: *kubernetes-env
Expand Down
9 changes: 6 additions & 3 deletions src/networkNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export class NetworkNode implements NetworkNodeInterface {
: `echo restart > /tmp/zombiepipe`;
args.push(cmd);

await client.runCommand(args, undefined, true);
const result = await client.runCommand(args, undefined, true);
return result.exitCode === 0;
}

async pause() {
Expand All @@ -82,7 +83,8 @@ export class NetworkNode implements NetworkNodeInterface {
"-c",
"echo pause > /tmp/zombiepipe",
];
await client.runCommand(args, undefined, true);
const result = await client.runCommand(args, undefined, true);
return result.exitCode === 0;
}

async resume() {
Expand All @@ -95,7 +97,8 @@ export class NetworkNode implements NetworkNodeInterface {
"-c",
"echo pause > /tmp/zombiepipe",
];
await client.runCommand(args, undefined, true);
const result = await client.runCommand(args, undefined, true);
return result.exitCode === 0;
}

async isUp(timeout = DEFAULT_INDIVIDUAL_TEST_TIMEOUT): Promise<boolean> {
Expand Down
26 changes: 16 additions & 10 deletions src/test-runner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,29 +607,35 @@ function parseAssertionLine(assertion: string) {
const nodes = network.getNodes(nodeName);
const results = await Promise.all(nodes.map(node => node.restart(timeout)));

const restarted = results.every(Boolean);
expect(restarted).to.be.ok;
for(const value of results) {
expect(value).to.be.ok;
}
};
}

m = pauseRegex.exec(assertion);
if (m && m[2]) {
const nodeName = m[2];
if (m && m[1]) {
const nodeName = m[1];
return async (network: Network, backchannelMap: BackchannelMap) => {
const nodes = network.getNodes(nodeName);
const results = await Promise.all(nodes.map(node => node.pause()));

const paused = results.every(Boolean);
expect(paused).to.be.ok;
for(const value of results) {
expect(value).to.be.ok;
}
};
}

m = resumeRegex.exec(assertion);
if (m && m[2]) {
const nodeName = m[2];
if (m && m[1]) {
const nodeName = m[1];
return async (network: Network, backchannelMap: BackchannelMap) => {
await network.node(nodeName).resume();
expect(true).to.be.ok;
const nodes = network.getNodes(nodeName);
const results = await Promise.all(nodes.map(node => node.resume()));

for(const value of results) {
expect(value).to.be.ok;
}
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Description: Restart
Network: ./0002-test-restart-node.toml
Creds: config.gcloud
Network: ./0002-restart-pause-resume-node.toml
Creds: config


alice: is up
Expand All @@ -9,4 +9,7 @@ alice: reports sub_libp2p_is_major_syncing is 0
alice: restart after 60 seconds
sleep 65 seconds
alice: is up

alice: pause
alice: is up
alice: resume
alice: is up
12 changes: 12 additions & 0 deletions tests/0002-restart-pause-resume-node.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[settings]
timeout = 1000

[relaychain]
default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}"
chain = "rococo-local"
command = "polkadot"

[[relaychain.nodes]]
name = "alice"
validator = true
extra_args = ["-lparachain=debug"]
40 changes: 0 additions & 40 deletions tests/0002-test-restart-node.toml

This file was deleted.

0 comments on commit 2dd7564

Please sign in to comment.