Skip to content

Commit

Permalink
fix script to run tests from local dir (#1148)
Browse files Browse the repository at this point in the history
* fix script to run tests from local dir

* fix getopts for local

* fix script

* fix script

* fix script

* allow default ns to connect zombie namespaces

* refactor ci yml

* refactor ci yml

* refactor ci yml
  • Loading branch information
pepoviola committed Jun 30, 2023
1 parent 33a5f83 commit d84a7c8
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 89 deletions.
125 changes: 50 additions & 75 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ stages:
- test
- check
- publish
- deploy
- zombienet


variables:
Expand Down Expand Up @@ -179,62 +179,62 @@ publish-docker-image-description:
script:
- cd / && sh entrypoint.sh

zombienet-smoke:
stage: deploy
<<: *kubernetes-env
<<: *test-refs
image: "paritypr/zombienet:${CI_COMMIT_SHORT_SHA}"

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

.zombienet-common:
before_script:
- echo "Zombienet Smoke Tests"
- echo "paritypr/zombienet:${CI_COMMIT_SHORT_SHA}"
- echo "Zombienet Tests Config"
- echo "${ZOMBIENET_IMAGE}"
- echo "${GH_DIR}"
- export DEBUG=zombie*
- echo "${LOCAL_DIR}"
- export DEBUG=zombie
- export ZOMBIENET_INTEGRATION_TEST_IMAGE="docker.io/paritypr/polkadot-debug:master"
- export COL_IMAGE="docker.io/paritypr/colander:master"
- echo "relay_image ${ZOMBIENET_INTEGRATION_TEST_IMAGE}"
- echo "col_image ${COL_IMAGE}"
stage: zombienet
image: "paritypr/zombienet:${CI_COMMIT_SHORT_SHA}"
needs:
- job: publish-docker-pr
extends:
- .kubernetes-env
- .test-refs
variables:
LOCAL_DIR: "/builds/parity/mirrors/zombienet/tests"
FF_DISABLE_UMASK_FOR_DOCKER_EXECUTOR: 1
artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
when: always
expire_in: 2 days
paths:
- ./zombienet-logs
after_script:
- mkdir -p ./zombienet-logs
- cp /tmp/zombie*/logs/* ./zombienet-logs/
retry: 2
tags:
- zombienet-polkadot-integration-test

zombienet-smoke:
extends:
- .zombienet-common
script:
- /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh
--local-dir="${LOCAL_DIR}"
--test="0001-smoke.zndsl"
allow_failure: false
retry: 2
tags:
- zombienet-polkadot-integration-test

zombienet-scale-net-config:
stage: deploy
<<: *kubernetes-env
<<: *test-refs
image: "paritypr/zombienet:${CI_COMMIT_SHORT_SHA}"

extends:
- .zombienet-common
variables:
GH_DIR: "https://github.com/paritytech/zombienet/tree/${CI_COMMIT_SHORT_SHA}/tests/scale-net"

before_script:
- echo "Zombienet Tests Scale Net"
- 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:master"

LOCAL_DIR: "/builds/parity/mirrors/zombienet/tests/scale-net"
script:
- /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh
--local-dir="${LOCAL_DIR}"
--test="0001-scale-net.zndsl"
allow_failure: true
retry: 2
tags:
- zombienet-polkadot-integration-test

zombienet-upgrade-node:
stage: deploy
<<: *kubernetes-env
<<: *test-refs
image: "paritypr/zombienet:${CI_COMMIT_SHORT_SHA}"

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

Expand All @@ -245,21 +245,16 @@ zombienet-upgrade-node:
- export DEBUG=zombie*
- export ZOMBIENET_INTEGRATION_TEST_IMAGE="docker.io/paritypr/polkadot-debug:master"
- export COL_IMAGE="docker.io/paritypr/colander:4519"

- echo "relay_image ${ZOMBIENET_INTEGRATION_TEST_IMAGE}"
- echo "col_image ${COL_IMAGE}"
script:
- /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh
--local-dir="${LOCAL_DIR}"
--test="0001-upgrade-node.zndsl"
allow_failure: true
retry: 2
tags:
- zombienet-polkadot-integration-test

paras:
stage: deploy
<<: *kubernetes-env
<<: *test-refs
image: "paritypr/zombienet:${CI_COMMIT_SHORT_SHA}"

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

Expand All @@ -275,33 +270,13 @@ paras:

script:
- /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh
--local-dir="${LOCAL_DIR}"
--test="paras.zndsl"
allow_failure: true
retry: 2
tags:
- zombienet-polkadot-integration-test

db-snapshot:
stage: deploy
<<: *kubernetes-env
<<: *test-refs
image: "paritypr/zombienet:${CI_COMMIT_SHORT_SHA}"

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

before_script:
- echo "Zombienet Db Snapshot"
- 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:master"

extends:
- .zombienet-common
script:
- /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh
--test="0013-db-snapshot.zndsl"
allow_failure: true
retry: 2
tags:
- zombienet-polkadot-integration-test
--local-dir="${LOCAL_DIR}"
--test="0013-db-snapshot.zndsl"
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ spec:
- tempo
- monitoring
- parachain-exporter
- default
policyTypes:
- Ingress
35 changes: 21 additions & 14 deletions scripts/ci/run-test-local-env-manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@ gcloud components install kubectl
Usage: ${SCRIPT_NAME} OPTION
OPTION
-t, --test OPTIONAL Test file to run
-t, --test OPTIONAL Test file to run
If omitted "all" test in the tests directory will be used.
-l, --local-dir Directory where the test/config files lives, can be absolute or
relatives to ${SCRIPT_PATH}
-c, --concurrency OPTIONAL concurrency for spawn nodes
-h, --help OPTIONAL Print this help message
-o, --output-dir OPTIONAL
Path to dir where to save contens of --github-remote-dir
Path to dir where to save contens of --local-dir
Defaults to ${SCRIPT_PATH}
specified, it will be ifered from there.
EXAMPLES
Run tests
${SCRIPT_NAME} -g https://github.com/paritytech/polkadot/tree/master/zombienet_tests
${SCRIPT_NAME} -l https://github.com/paritytech/polkadot/tree/master/zombienet_tests
EOF
}
Expand Down Expand Up @@ -61,8 +64,9 @@ function set_defaults_for_globals {
cd "${SCRIPT_PATH}"

EXIT_STATUS=0
GH_REMOTE_DIR=""
LOCAL_DIR=""
TEST_TO_RUN=""
CONCURRENCY=2


LAUNCH_ARGUMENTS=""
Expand All @@ -78,14 +82,13 @@ function parse_args {
}

function check_args {
if [[ -n "${GH_REMOTE_DIR}" &&
! "${GH_REMOTE_DIR}" =~ https:\/\/github.com\/ ]] ; then
log DIE "Not a github URL"
if [[ ! -n "${LOCAL_DIR}" ]] ; then
log DIE "Not LOCAL_DIR Set"
fi
}

# shellcheck disable=SC2214
while getopts i:t:g:h:uo:-: OPT; do
while getopts i:t:l:h:uo:-: OPT; do
# support long options: https://stackoverflow.com/a/28466267/519360
if [ "$OPT" = "-" ]; then # long option: reformulate OPT and OPTARG
OPT="${OPTARG%%=*}" # extract long option name
Expand All @@ -94,7 +97,8 @@ function parse_args {
fi
case "$OPT" in
t | test) needs_arg ; TEST_TO_RUN="${OPTARG}" ;;
g | github-remote-dir) needs_arg ; GH_REMOTE_DIR="${OPTARG}" ;;
c | concurrency) needs_arg ; CONCURRENCY="${OPTARG}" ;;
l | local-dir) needs_arg ; LOCAL_DIR="${OPTARG}" ;;
h | help ) usage ; exit 0 ;;
o | output-dir) needs_arg ; OUTPUT_DIR="${OPTARG}" ;;
??* ) log DIE "Illegal option --${OPT}" ;;
Expand All @@ -108,9 +112,7 @@ function parse_args {
function copy_to_isolated {
cd "${SCRIPT_PATH}"
echo $(pwd)
echo $(ls)
echo $(ls ../..)
cp -r ../../tests/* "${OUTPUT_DIR}"
cp -r "${LOCAL_DIR}"/* "${OUTPUT_DIR}"
}
function run_test {
# RUN_IN_CONTAINER is env var that is set in the dockerfile
Expand All @@ -121,11 +123,16 @@ function run_test {
cd "${OUTPUT_DIR}"
set -x
set +e
if [[ ! -z $CONCURRENCY ]]; then
C=2
else
C=$CONCURRENCY
fi;
if [[ ! -z $TEST_TO_RUN ]]; then
TEST_FOUND=0
for i in $(find ${OUTPUT_DIR} -name "${TEST_TO_RUN}"| head -1); do
TEST_FOUND=1
zombie test $i
zombie -c $CONCURRENCY test $i
EXIT_STATUS=$?
done;
if [[ $TEST_FOUND -lt 1 ]]; then
Expand All @@ -134,7 +141,7 @@ function run_test {
else
for i in $(find ${OUTPUT_DIR} -name *.zndsl | sort); do
echo "running test: ${i}"
zombie test $i
zombie -c $CONCURRENCY test $i
TEST_EXIT_STATUS=$?
EXIT_STATUS=$((EXIT_STATUS+TEST_EXIT_STATUS))
done;
Expand Down

0 comments on commit d84a7c8

Please sign in to comment.