Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 6e73c85

Browse files
michalkucharczykrcnypepoviola
authored
zombienet: warp-sync integration test added (#12675)
* zombienet: warp-sync integration test added * spelling * Readme corrected * dir name updated * Check second phase of warp sync * zombienet pipeline enable + naive test network * zombienet stage added * paritypr/substrate-debug image added for zombienet testing * debugs added * debugs added * buildah problem fixed * rollback * runner tag * test name corrected * dir renamed (regex problem) * common code clean up * common code clean up * fix * warp sync test improvements * full sha used as short is too short (https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/2051228#L38) * disable tracing for nodes * COMMON_USER -> DOCKERIO_USER * refs reworked * paritypr/substrate image used * DOCKERIO -> DOCKER * generate-ws-db toml cleanup * improvements * fix * raw chain spec used * zombienet v1.3.18 used * zombienet: warp sync test enabled * chain-spec path corrected * log parsing improved Checking if log does not container error or verification failed messages * warp sync test: removed validators * fix * review remarks applied * dir test name changed: 0000_block_building -> 0000-block-building * transaction finalized test added * transaction finalized test: error handling improved * trigger CI job * trigger CI job * trigger CI job * trigger CI job * Explicitly touch `version.rs` to invalidate the related cache * zombienet add logs as artifacts * Revert "Explicitly touch `version.rs` to invalidate the related cache" This reverts commit 9d00ccf. * file naming changed Co-authored-by: parity-processbot <> Co-authored-by: Vladimir Istyufeev <[email protected]> Co-authored-by: Javier Viola <[email protected]>
1 parent b99f2bc commit 6e73c85

14 files changed

+587
-12
lines changed

.gitlab-ci.yml

+18
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ stages:
3333
- test
3434
- build
3535
- publish
36+
- zombienet
3637
- deploy
3738
- notify
3839

@@ -52,6 +53,7 @@ variables:
5253
BUILDAH_IMAGE: "quay.io/buildah/stable:v1.27"
5354
RUSTY_CACHIER_SINGLE_BRANCH: master
5455
RUSTY_CACHIER_DONT_OPERATE_ON_MAIN_BRANCH: "true"
56+
ZOMBIENET_IMAGE: "docker.io/paritytech/zombienet:v1.3.22"
5557

5658
default:
5759
retry:
@@ -166,14 +168,28 @@ default:
166168
- if: $CI_PIPELINE_SOURCE == "schedule"
167169
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
168170

171+
.publish-refs:
172+
rules:
173+
- if: $CI_PIPELINE_SOURCE == "pipeline"
174+
when: never
175+
- if: $CI_PIPELINE_SOURCE == "web"
176+
- if: $CI_PIPELINE_SOURCE == "schedule"
177+
- if: $CI_COMMIT_REF_NAME == "master"
178+
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
179+
169180
.build-refs:
181+
# publish-refs + PRs
170182
rules:
171183
- if: $CI_PIPELINE_SOURCE == "pipeline"
172184
when: never
173185
- if: $CI_PIPELINE_SOURCE == "web"
174186
- if: $CI_PIPELINE_SOURCE == "schedule"
175187
- if: $CI_COMMIT_REF_NAME == "master"
176188
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
189+
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
190+
191+
.zombienet-refs:
192+
extends: .build-refs
177193

178194
.nightly-pipeline:
179195
rules:
@@ -224,6 +240,8 @@ include:
224240
- scripts/ci/gitlab/pipeline/build.yml
225241
# publish jobs
226242
- scripts/ci/gitlab/pipeline/publish.yml
243+
# zombienet jobs
244+
- scripts/ci/gitlab/pipeline/zombienet.yml
227245

228246
#### stage: deploy
229247

scripts/ci/docker/subkey.Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ FROM docker.io/library/ubuntu:20.04
33
# metadata
44
ARG VCS_REF
55
ARG BUILD_DATE
6+
ARG IMAGE_NAME
67

78
LABEL io.parity.image.authors="[email protected]" \
89
io.parity.image.vendor="Parity Technologies" \
9-
io.parity.image.title="parity/subkey" \
10+
io.parity.image.title="${IMAGE_NAME}" \
1011
io.parity.image.description="Subkey: key generating utility for Substrate." \
1112
io.parity.image.source="https://github.com/paritytech/substrate/blob/${VCS_REF}/scripts/ci/docker/subkey.Dockerfile" \
1213
io.parity.image.revision="${VCS_REF}" \

scripts/ci/docker/substrate.Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ FROM docker.io/library/ubuntu:20.04
33
# metadata
44
ARG VCS_REF
55
ARG BUILD_DATE
6+
ARG IMAGE_NAME
67

78
LABEL io.parity.image.authors="[email protected]" \
89
io.parity.image.vendor="Parity Technologies" \
9-
io.parity.image.title="parity/substrate" \
10+
io.parity.image.title="${IMAGE_NAME}" \
1011
io.parity.image.description="Substrate: The platform for blockchain innovators." \
1112
io.parity.image.source="https://github.com/paritytech/substrate/blob/${VCS_REF}/scripts/ci/docker/Dockerfile" \
1213
io.parity.image.revision="${VCS_REF}" \

scripts/ci/gitlab/pipeline/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ build-linux-substrate:
8686
extends:
8787
- .collect-artifacts
8888
- .docker-env
89-
- .build-refs
89+
- .publish-refs
9090
variables:
9191
# this variable gets overriden by "rusty-cachier environment inject", use the value as default
9292
CARGO_TARGET_DIR: "$CI_PROJECT_DIR/target"

scripts/ci/gitlab/pipeline/publish.yml

+42-9
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,33 @@
22
# This file is part of .gitlab-ci.yml
33
# Here are all jobs that are executed during "publish" stage
44

5-
.build-push-docker-image:
5+
.build-push-docker-image-common:
66
extends:
7-
- .build-refs
87
- .kubernetes-env
8+
stage: publish
99
variables:
1010
CI_IMAGE: $BUILDAH_IMAGE
1111
GIT_STRATEGY: none
1212
DOCKERFILE: $PRODUCT.Dockerfile
13-
IMAGE_NAME: docker.io/parity/$PRODUCT
13+
IMAGE_NAME: docker.io/$IMAGE_PATH
1414
before_script:
1515
- cd ./artifacts/$PRODUCT/
1616
- VERSION="$(cat ./VERSION)"
1717
- echo "${PRODUCT} version = ${VERSION}"
1818
- test -z "${VERSION}" && exit 1
1919
script:
20-
- test "$Docker_Hub_User_Parity" -a "$Docker_Hub_Pass_Parity" ||
20+
- test "$DOCKER_USER" -a "$DOCKER_PASS" ||
2121
( echo "no docker credentials provided"; exit 1 )
2222
- buildah bud
2323
--format=docker
2424
--build-arg VCS_REF="${CI_COMMIT_SHA}"
2525
--build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
26+
--build-arg IMAGE_NAME="${IMAGE_PATH}"
2627
--tag "$IMAGE_NAME:$VERSION"
2728
--tag "$IMAGE_NAME:latest"
2829
--file "$DOCKERFILE" .
29-
- echo "$Docker_Hub_Pass_Parity" |
30-
buildah login --username "$Docker_Hub_User_Parity" --password-stdin docker.io
30+
- echo "$DOCKER_PASS" |
31+
buildah login --username "$DOCKER_USER" --password-stdin docker.io
3132
- buildah info
3233
- buildah push --format=v2s2 "$IMAGE_NAME:$VERSION"
3334
- buildah push --format=v2s2 "$IMAGE_NAME:latest"
@@ -38,17 +39,49 @@
3839
- echo "SUBSTRATE_IMAGE_TAG=${IMAGE_TAG}" | tee -a ./artifacts/$PRODUCT/build.env
3940
- cat ./artifacts/$PRODUCT/build.env
4041

42+
.build-push-docker-image:
43+
extends:
44+
- .publish-refs
45+
- .build-push-docker-image-common
46+
variables:
47+
IMAGE_PATH: parity/$PRODUCT
48+
DOCKER_USER: $Docker_Hub_User_Parity
49+
DOCKER_PASS: $Docker_Hub_Pass_Parity
50+
51+
52+
# publish image to docker.io/paritypr, (e.g. for later use in zombienet testing)
53+
.build-push-image-temporary:
54+
extends:
55+
- .build-refs
56+
- .build-push-docker-image-common
57+
variables:
58+
IMAGE_PATH: paritypr/$PRODUCT
59+
DOCKER_USER: $PARITYPR_USER
60+
DOCKER_PASS: $PARITYPR_PASS
61+
4162
publish-docker-substrate:
42-
stage: publish
4363
extends: .build-push-docker-image
4464
needs:
4565
- job: build-linux-substrate
4666
artifacts: true
4767
variables:
4868
PRODUCT: substrate
4969

70+
publish-docker-substrate-temporary:
71+
extends: .build-push-image-temporary
72+
needs:
73+
- job: build-linux-substrate
74+
artifacts: true
75+
variables:
76+
PRODUCT: substrate
77+
artifacts:
78+
reports:
79+
# this artifact is used in zombienet-tests job
80+
# https://docs.gitlab.com/ee/ci/multi_project_pipelines.html#with-variable-inheritance
81+
dotenv: ./artifacts/$PRODUCT/build.env
82+
expire_in: 24h
83+
5084
publish-docker-subkey:
51-
stage: publish
5285
extends: .build-push-docker-image
5386
needs:
5487
- job: build-subkey-linux
@@ -59,7 +92,7 @@ publish-docker-subkey:
5992
publish-s3-release:
6093
stage: publish
6194
extends:
62-
- .build-refs
95+
- .publish-refs
6396
- .kubernetes-env
6497
needs:
6598
- job: build-linux-substrate
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# This file is part of .gitlab-ci.yml
2+
# Here are all jobs that are executed during "zombienet" stage
3+
4+
# common settings for all zombienet jobs
5+
.zombienet-common:
6+
before_script:
7+
- echo "Zombie-net Tests Config"
8+
- echo "${ZOMBIENET_IMAGE}"
9+
- echo "${SUBSTRATE_IMAGE_NAME} ${SUBSTRATE_IMAGE_TAG}"
10+
- echo "${GH_DIR}"
11+
- export DEBUG=zombie,zombie::network-node
12+
- export ZOMBIENET_INTEGRATION_TEST_IMAGE=${SUBSTRATE_IMAGE_NAME}:${SUBSTRATE_IMAGE_TAG}
13+
- echo "${ZOMBIENET_INTEGRATION_TEST_IMAGE}"
14+
stage: zombienet
15+
image: "${ZOMBIENET_IMAGE}"
16+
needs:
17+
- job: publish-docker-substrate-temporary
18+
extends:
19+
- .kubernetes-env
20+
- .zombienet-refs
21+
variables:
22+
GH_DIR: "https://github.com/paritytech/substrate/tree/${CI_COMMIT_SHA}/zombienet"
23+
FF_DISABLE_UMASK_FOR_DOCKER_EXECUTOR: 1
24+
artifacts:
25+
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
26+
when: always
27+
expire_in: 2 days
28+
paths:
29+
- ./zombienet-logs
30+
after_script:
31+
- mkdir -p ./zombienet-logs
32+
- cp /tmp/zombie*/logs/* ./zombienet-logs/
33+
allow_failure: true
34+
retry: 2
35+
tags:
36+
- zombienet-polkadot-integration-test
37+
38+
zombienet-0000-block-building:
39+
extends:
40+
- .zombienet-common
41+
script:
42+
- /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh
43+
--github-remote-dir="${GH_DIR}/0000-block-building"
44+
--test="block-building.zndsl"
45+
46+
47+
zombienet-0001-basic-warp-sync:
48+
extends:
49+
- .zombienet-common
50+
script:
51+
- /home/nonroot/zombie-net/scripts/ci/run-test-env-manager.sh
52+
--github-remote-dir="${GH_DIR}/0001-basic-warp-sync"
53+
--test="test-warp-sync.zndsl"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[settings]
2+
enable_tracing = false
3+
4+
[relaychain]
5+
default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}"
6+
default_command = "substrate"
7+
chain = "local"
8+
9+
[[relaychain.nodes]]
10+
name = "alice"
11+
validator = true
12+
13+
[[relaychain.nodes]]
14+
name = "bob"
15+
validator = true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Description: Block building
2+
Network: ./block-building.toml
3+
Creds: config
4+
5+
alice: is up
6+
bob: is up
7+
8+
alice: reports node_roles is 4
9+
bob: reports node_roles is 4
10+
11+
alice: reports peers count is at least 1
12+
bob: reports peers count is at least 1
13+
14+
alice: reports block height is at least 5 within 20 seconds
15+
bob: reports block height is at least 5 within 20 seconds
16+
17+
alice: count of log lines containing "error" is 0 within 2 seconds
18+
bob: count of log lines containing "error" is 0 within 2 seconds
19+
20+
alice: js-script ./transaction-gets-finalized.js within 30 seconds
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//based on: https://polkadot.js.org/docs/api/examples/promise/transfer-events
2+
3+
const assert = require("assert");
4+
5+
async function run(nodeName, networkInfo, args) {
6+
const {wsUri, userDefinedTypes} = networkInfo.nodesByName[nodeName];
7+
const api = await zombie.connect(wsUri, userDefinedTypes);
8+
9+
// Construct the keyring after the API (crypto has an async init)
10+
const keyring = new zombie.Keyring({ type: "sr25519" });
11+
12+
// Add Alice to our keyring with a hard-derivation path (empty phrase, so uses dev)
13+
const alice = keyring.addFromUri('//Alice');
14+
const bob = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';
15+
16+
// Create a extrinsic, transferring 10^20 units to Bob
17+
const transfer = api.tx.balances.transfer(bob, 10n**20n);
18+
19+
let transaction_success_event = false;
20+
try {
21+
await new Promise( async (resolve, reject) => {
22+
const unsubscribe = await transfer
23+
.signAndSend(alice, { nonce: -1 }, ({ events = [], status }) => {
24+
console.log('Transaction status:', status.type);
25+
26+
if (status.isInBlock) {
27+
console.log('Included at block hash', status.asInBlock.toHex());
28+
console.log('Events:');
29+
30+
events.forEach(({ event: { data, method, section }, phase }) => {
31+
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString());
32+
33+
if (section=="system" && method =="ExtrinsicSuccess") {
34+
transaction_success_event = true;
35+
}
36+
});
37+
} else if (status.isFinalized) {
38+
console.log('Finalized block hash', status.asFinalized.toHex());
39+
unsubscribe();
40+
if (transaction_success_event) {
41+
resolve();
42+
} else {
43+
reject("ExtrinsicSuccess has not been seen");
44+
}
45+
} else if (status.isError) {
46+
unsubscribe();
47+
reject("Transaction status.isError");
48+
}
49+
50+
});
51+
});
52+
} catch (error) {
53+
assert.fail("Transfer promise failed, error: " + error);
54+
}
55+
56+
assert.ok("test passed");
57+
}
58+
59+
module.exports = { run }

0 commit comments

Comments
 (0)