Skip to content

Commit 3ffeabf

Browse files
committed
zombienet smoke test
1 parent e2d0aae commit 3ffeabf

File tree

5 files changed

+160
-7
lines changed

5 files changed

+160
-7
lines changed

.devcontainer/devcontainer.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Rust",
3+
"image": "mcr.microsoft.com/devcontainers/rust:latest",
4+
"runArgs": ["--platform=linux/amd64"]
5+
}

.github/workflows/release.yml

+29-2
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ jobs:
536536
asset_name: evm-tracing-artifacts-${{ github.ref_name }}.tar.gz
537537
asset_content_type: application/gzip
538538

539-
chain-sync:
539+
chain-sync-smoke:
540540
needs: native-linux
541541
runs-on: ubuntu-latest
542542
strategy:
@@ -556,4 +556,31 @@ jobs:
556556
- name: Sync chain ${{ matrix.chain }}
557557
run: |
558558
chmod +x target/release/astar-collator
559-
./scripts/sync.sh ${{ matrix.chain }}
559+
./scripts/sync-smoke.sh ${{ matrix.chain }}
560+
561+
zombienet-smoke:
562+
needs: native-linux
563+
runs-on: ubuntu-latest
564+
strategy:
565+
matrix:
566+
chain: [ "astar-dev", "shiden-dev", "shibuya-dev" ]
567+
568+
steps:
569+
- name: Checkout the source code
570+
uses: actions/checkout@v4
571+
572+
- name: Download pre-built collator binary
573+
uses: actions/download-artifact@v3
574+
with:
575+
name: astar-ubuntu-latest-x86_64
576+
path: target/release
577+
578+
- name: Setup
579+
run: |
580+
chmod +x target/release/astar-collator
581+
mv target/release/astar-collator third-party/zombienet
582+
583+
- name: Sync chain ${{ matrix.chain }}
584+
env:
585+
- CHAIN: ${{ matrix.chain }}
586+
run: ./third-party/zombienet/smoke.sh

scripts/sync.sh scripts/sync-smoke.sh

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ chain="$@"
88
# run node
99
./target/release/astar-collator --chain $chain --no-telemetry --no-prometheus --tmp -- --no-telemetry --no-prometheus & CHAIN_PID=$!
1010

11-
printf "Waiting for RPC to be ready"
11+
trap "kill $CHAIN_PID" EXIT
12+
13+
echo "Waiting for RPC to be ready"
1214
attempts=12 # 1 minutes
1315
until nc -z localhost 9944; do
1416
attempts=$((attempts - 1))
@@ -19,10 +21,11 @@ until nc -z localhost 9944; do
1921
sleep 5
2022
done
2123

22-
printf "Waiting for 30 seconds to sync at least 1000 blocks"
24+
echo "Waiting for 30 seconds to sync at least 1000 blocks"
2325
sleep 30
2426

25-
number=$(curl --location http://localhost:9944 \
27+
number=$(curl --silent \
28+
--location http://localhost:9944 \
2629
--header 'Content-Type: application/json' \
2730
--data '{
2831
"jsonrpc": "2.0",
@@ -35,5 +38,3 @@ if [ "$number" -lt 1000 ]; then
3538
echo "ERROR: Chain failed to sync 1000 blocks in 30 seconds"
3639
exit 1
3740
fi
38-
39-
kill $CHAIN_PID

third-party/zombienet/smoke.sh

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if [ $(arch) != "x86_64" ]
6+
then
7+
echo "Runs only on x86_64 architecture"
8+
exit 1
9+
fi
10+
11+
if ! command -v ./astar-collator &> /dev/null
12+
then
13+
echo "No executable astar-collator binary in zombienet directory"
14+
exit 1
15+
fi
16+
17+
if ! command -v zombienet &> /dev/null
18+
then
19+
mkdir -p $HOME/.local/bin
20+
wget -O $HOME/.local/bin/zombienet https://github.com/paritytech/zombienet/releases/download/v1.3.106/zombienet-linux-x64
21+
chmod a+x $HOME/.local/bin/zombienet
22+
PATH=$HOME/.local/bin:$PATH
23+
zombienet version
24+
fi
25+
26+
echo "Pull polkadot binaries"
27+
zombienet setup polkadot -y & SETUP_PID=$!
28+
while ps $SETUP_PID > /dev/null ; do
29+
sleep 1
30+
done
31+
chmod +x polkadot polkadot-execute-worker polkadot-prepare-worker
32+
33+
# default to shibuya-dev
34+
if [[ ! -v CHAIN ]]; then
35+
export CHAIN="shibuya-dev"
36+
fi
37+
38+
echo "Start zombienet for $CHAIN"
39+
echo "NOTE: Select chain using environmental variable CHAIN=<shibuya-dev|shiden-dev|astar-dev> to change it."
40+
nohup zombienet -p native spawn smoke.toml & ZOMBIENET_PID=$!
41+
42+
# kill zombienet before exit
43+
trap "kill $ZOMBIENET_PID" EXIT
44+
45+
echo "Waiting for RPC to be ready"
46+
attempts=12 # 2 minutes
47+
until nc -z localhost 9944; do
48+
attempts=$((attempts - 1))
49+
if [ $attempts -eq 0 ]; then
50+
echo "ERROR: Chain RPC failed to start"
51+
exit 1
52+
fi
53+
printf "."
54+
sleep 10
55+
done
56+
57+
echo "RPC is ready"
58+
59+
number=0
60+
attempts=20 # 200s
61+
while [ $number -lt 5 ]; do
62+
attempts=$((attempts - 1))
63+
if [ $attempts -eq 0 ]; then
64+
echo "ERROR: Parachain failed to build 5 blocks in 200s"
65+
exit 1
66+
fi
67+
68+
sleep 10
69+
70+
number=$(curl --silent \
71+
--location http://localhost:9944 \
72+
--header 'Content-Type: application/json' \
73+
--data '{
74+
"jsonrpc": "2.0",
75+
"method": "chain_getHeader",
76+
"params": [],
77+
"id": 1
78+
}' | jq '.result.number' | xargs printf "%d")
79+
80+
echo "Parachain block number $number"
81+
done

third-party/zombienet/smoke.toml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[settings]
2+
timeout = 1000
3+
4+
# Used to start 4 validator nodes and 2 collator nodes for a single parachain.
5+
6+
[relaychain]
7+
default_command = "./polkadot"
8+
chain = "rococo-local"
9+
10+
[[relaychain.nodes]]
11+
name = "alice"
12+
validator = true
13+
14+
[[relaychain.nodes]]
15+
name = "bob"
16+
validator = true
17+
18+
[[relaychain.nodes]]
19+
name = "charlie"
20+
validator = true
21+
22+
[[relaychain.nodes]]
23+
name = "dave"
24+
validator = true
25+
26+
[[parachains]]
27+
# Right now this has to be 2000 but soon we might be able to use arbitrary para-id
28+
id = 2000
29+
chain = "{{CHAIN}}"
30+
cumulus_based = true
31+
32+
[[parachains.collators]]
33+
name = "collator1"
34+
command = "./astar-collator"
35+
ws_port=9944
36+
37+
[[parachains.collators]]
38+
name = "collator2"
39+
command = "./astar-collator"

0 commit comments

Comments
 (0)