Skip to content

Commit

Permalink
warm up script / Merge remote-tracking branch 'origin/ci/zombietests-…
Browse files Browse the repository at this point in the history
…warm-up' into test/polkadot-functional-zombietests
  • Loading branch information
qdrvm-ci committed May 17, 2024
2 parents 604dc2f + 60a953f commit b1bd6b6
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/zombie-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: "Test we are producing blocks at 6 seconds clip"
test: "test-polkadot-functional-0011-async-backing-6-seconds-rate"
runs-on: [ actions-runner-controller ]
timeout-minutes: 60
timeout-minutes: 120
steps:
- name: Set owner of working dir recurively
run: sudo chown -R $(whoami) .
Expand Down
22 changes: 11 additions & 11 deletions zombienet/docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,34 +87,34 @@ test0011:
docker run qdrvm/zombie-tester:latest zombienet-linux-x64 test -p native kagome/zombienet/0011-block-building-warp-sync/0011-block-building-warp-sync.zndsl

test-polkadot-functional-0001-parachains-pvf:
docker run qdrvm/zombie-tester:latest zombienet-linux-x64 test -p native kagome/zombienet/polkadot/functional/0001-parachains-pvf.zndsl
python3 test_runner.py qdrvm/zombie-tester:latest kagome/zombienet/polkadot/functional/0001-parachains-pvf.zndsl

test-polkadot-functional-0002-parachains-disputes:
docker run qdrvm/zombie-tester:latest zombienet-linux-x64 test -p native kagome/zombienet/polkadot/functional/0002-parachains-disputes.zndsl
python3 test_runner.py qdrvm/zombie-tester:latest kagome/zombienet/polkadot/functional/0002-parachains-disputes.zndsl

test-polkadot-functional-0003-beefy-and-mmr:
docker run qdrvm/zombie-tester:latest zombienet-linux-x64 test -p native kagome/zombienet/polkadot/functional/0003-beefy-and-mmr.zndsl
python3 test_runner.py qdrvm/zombie-tester:latest kagome/zombienet/polkadot/functional/0003-beefy-and-mmr.zndsl

test-polkadot-functional-0004-parachains-garbage-candidate:
docker run qdrvm/zombie-tester:latest zombienet-linux-x64 test -p native kagome/zombienet/polkadot/functional/0004-parachains-garbage-candidate.zndsl
python3 test_runner.py qdrvm/zombie-tester:latest kagome/zombienet/polkadot/functional/0004-parachains-garbage-candidate.zndsl

test-polkadot-functional-0005-parachains-disputes-past-session:
docker run qdrvm/zombie-tester:latest zombienet-linux-x64 test -p native kagome/zombienet/polkadot/functional/0005-parachains-disputes-past-session.zndsl
python3 test_runner.py qdrvm/zombie-tester:latest kagome/zombienet/polkadot/functional/0005-parachains-disputes-past-session.zndsl

test-polkadot-functional-0006-parachains-max-tranche0:
docker run qdrvm/zombie-tester:latest zombienet-linux-x64 test -p native kagome/zombienet/polkadot/functional/0006-parachains-max-tranche0.zndsl
python3 test_runner.py qdrvm/zombie-tester:latest kagome/zombienet/polkadot/functional/0006-parachains-max-tranche0.zndsl

test-polkadot-functional-0007-dispute-freshly-finalized:
docker run qdrvm/zombie-tester:latest zombienet-linux-x64 test -p native kagome/zombienet/polkadot/functional/0007-dispute-freshly-finalized.zndsl
python3 test_runner.py qdrvm/zombie-tester:latest kagome/zombienet/polkadot/functional/0007-dispute-freshly-finalized.zndsl

test-polkadot-functional-0008-dispute-old-finalized:
docker run qdrvm/zombie-tester:latest zombienet-linux-x64 test -p native kagome/zombienet/polkadot/functional/0008-dispute-old-finalized.zndsl
python3 test_runner.py qdrvm/zombie-tester:latest kagome/zombienet/polkadot/functional/0008-dispute-old-finalized.zndsl

test-polkadot-functional-0009-approval-voting-coalescing:
docker run qdrvm/zombie-tester:latest zombienet-linux-x64 test -p native kagome/zombienet/polkadot/functional/0009-approval-voting-coalescing.zndsl
python3 test_runner.py qdrvm/zombie-tester:latest kagome/zombienet/polkadot/functional/0009-approval-voting-coalescing.zndsl

test-polkadot-functional-0010-validator-disabling:
docker run qdrvm/zombie-tester:latest zombienet-linux-x64 test -p native kagome/zombienet/polkadot/functional/0010-validator-disabling.zndsl
python3 test_runner.py qdrvm/zombie-tester:latest kagome/zombienet/polkadot/functional/0010-validator-disabling.zndsl

test-polkadot-functional-0011-async-backing-6-seconds-rate:
docker run qdrvm/zombie-tester:latest zombienet-linux-x64 test -p native kagome/zombienet/polkadot/functional/0011-async-backing-6-seconds-rate.zndsl
python3 test_runner.py qdrvm/zombie-tester:latest kagome/zombienet/polkadot/functional/0011-async-backing-6-seconds-rate.zndsl
67 changes: 67 additions & 0 deletions zombienet/docker/test_runner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import subprocess
import sys

def run_test(container_name, test_command):
command = f"docker exec {container_name} sh -c 'zombienet-linux-x64 test -p native {test_command}'"
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

while True:
output = process.stdout.readline()
if output == b'' and process.poll() is not None:
break
if output:
print(output.strip().decode())

rc = process.poll()

if rc != 0:
stderr_output = process.stderr.read().decode()
print(stderr_output)

return rc

def stop_container(container_name):
subprocess.run(f"docker stop {container_name}", shell=True)
subprocess.run(f"docker rm {container_name}", shell=True)

def print_with_flush(message):
print(message)
sys.stdout.flush()

def main():
if len(sys.argv) != 3:
print_with_flush("Usage: python test_runner.py <image_name> <test_command>")
sys.exit(1)

image_name = sys.argv[1]
test_command = sys.argv[2]

container_name = "zombie-tester-container"
print_with_flush("Starting the tester container...")
subprocess.run(f"docker run -d --name {container_name} {image_name} tail -f /dev/null", shell=True, check=True)
print_with_flush(f"Container started with name: {container_name}")

print_with_flush(f"Running test: {test_command} (warm-up)")
first_attempt = run_test(container_name, test_command)

if first_attempt == 0:
print_with_flush("Test passed on the first attempt (warm-up).")
stop_container(container_name)
sys.exit(0)

print_with_flush("Warm-up test failed, running test again...")

print_with_flush(f"Running test: {test_command} (second attempt)")
second_attempt = run_test(container_name, test_command)

if second_attempt == 0:
print_with_flush("Test passed on the second attempt.")
stop_container(container_name)
sys.exit(0)
else:
print_with_flush("Test failed on the second attempt.")
stop_container(container_name)
sys.exit(1)

if __name__ == "__main__":
main()

0 comments on commit b1bd6b6

Please sign in to comment.