Skip to content

Commit

Permalink
chore(bors): merge pull request #611
Browse files Browse the repository at this point in the history
611: ci(jenkins): cleanup on test failure r=tiagolobocastro a=tiagolobocastro

Also ensures Jenkins does the cleanup always.

Co-authored-by: Tiago Castro <[email protected]>
  • Loading branch information
mayastor-bors and tiagolobocastro committed Jul 3, 2023
2 parents 9885fb1 + 23d8bda commit e6349f4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 42 deletions.
13 changes: 2 additions & 11 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ pipeline {
beforeAgent true
not {
anyOf {
branch 'master'
branch 'release/*'
expression { run_linter == false }
}
Expand All @@ -132,11 +131,6 @@ pipeline {
stage('test') {
when {
beforeAgent true
not {
anyOf {
branch 'master'
}
}
expression { run_tests == true }
}
parallel {
Expand All @@ -154,8 +148,7 @@ pipeline {
}
post {
always {
// in case of abnormal termination of any nvmf test
sh 'sudo nvme disconnect-all'
sh 'nix-shell --run "./scripts/rust/deployer-cleanup.sh"'
}
}
}
Expand All @@ -174,8 +167,7 @@ pipeline {
}
post {
always {
// in case of abnormal termination of any nvmf test
sh 'sudo nvme disconnect-all'
sh 'nix-shell --run "./scripts/python/test-residue-cleanup.sh"'
}
}
}
Expand All @@ -198,7 +190,6 @@ pipeline {
anyOf {
expression { build_images == true }
anyOf {
branch 'master'
branch 'release/*'
branch 'develop'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

set -euo pipefail

echo "Cleaning leftover nvme devices..."
sudo nvme disconnect-all

echo "Cleaning all IPTABLE rules added by tests..."

# First backup the iptables rules
Expand Down
17 changes: 3 additions & 14 deletions scripts/python/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,8 @@ SCRIPT_DIR="$(dirname "$0")"
export ROOT_DIR="$SCRIPT_DIR/../.."

cleanup_handler() {
sudo nvme disconnect-all || true

"$ROOT_DIR"/scripts/python/test_residue_cleanup.sh || true
"$ROOT_DIR"/target/debug/deployer stop || true

for c in $(docker ps -a --filter "label=io.composer.test.name" --format '{{.ID}}') ; do
docker kill "$c" || true
docker rm -v "$c" || true
done

for n in $(docker network ls --filter "label=io.composer.test.name" --format '{{.ID}}') ; do
docker network rm "$n" || ( sudo systemctl restart docker && docker network rm "$n" )
done
"$SCRIPT_DIR"/test-residue-cleanup.sh || true
"$SCRIPT_DIR"/../rust/deployer-cleanup.sh || true
}

# FAST mode to avoid rebuilding certain dependencies
Expand All @@ -37,7 +26,7 @@ fi
# shellcheck source=/dev/null
. "$ROOT_DIR"/tests/bdd/setup.sh

trap cleanup_handler ERR INT QUIT TERM HUP
trap cleanup_handler ERR INT QUIT TERM HUP EXIT
cleanup_handler

# Extra arguments will be provided directly to pytest, otherwise the bdd folder will be tested with default arguments
Expand Down
18 changes: 18 additions & 0 deletions scripts/rust/deployer-cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

SCRIPT_DIR="$(dirname "$0")"
export ROOT_DIR="$SCRIPT_DIR/../.."

sudo nvme disconnect-all
"$ROOT_DIR"/target/debug/deployer stop

for c in $(docker ps -a --filter "label=io.composer.test.name" --format '{{.ID}}') ; do
docker kill "$c"
docker rm -v "$c"
done

for n in $(docker network ls --filter "label=io.composer.test.name" --format '{{.ID}}') ; do
docker network rm "$n" || ( sudo systemctl restart docker && docker network rm "$n" )
done

exit 0
16 changes: 2 additions & 14 deletions scripts/rust/test.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
#!/usr/bin/env bash

SCRIPT_DIR="$(dirname "$0")"
export ROOT_DIR="$SCRIPT_DIR/../.."

cleanup_handler() {
sudo nvme disconnect-all || true
"$ROOT_DIR"/target/debug/deployer stop || true

for c in $(docker ps -a --filter "label=io.composer.test.name" --format '{{.ID}}') ; do
docker kill "$c" || true
docker rm -v "$c" || true
done

for n in $(docker network ls --filter "label=io.composer.test.name" --format '{{.ID}}') ; do
docker network rm "$n" || ( sudo systemctl restart docker && docker network rm "$n" )
done
"$SCRIPT_DIR"/rust/deployer-cleanup.sh || true
}

trap cleanup_handler ERR INT QUIT TERM HUP
trap cleanup_handler ERR INT QUIT TERM HUP EXIT
cleanup_handler

set -euxo pipefail
Expand All @@ -26,4 +15,3 @@ cargo build --bins
for test in deployer-cluster grpc agents rest io-engine-tests shutdown csi-driver; do
cargo test -p ${test} -- --test-threads=1
done
cleanup_handler

0 comments on commit e6349f4

Please sign in to comment.