Skip to content

Commit 933a613

Browse files
committed
Backport fix to kindtest.sh for reusing compute instances
1 parent fff4eab commit 933a613

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

kindtest.sh

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ set -o pipefail
3636
script="${BASH_SOURCE[0]}"
3737
scriptDir="$( cd "$( dirname "${script}" )" && pwd )"
3838

39-
function usage {
39+
usage() {
4040
echo "usage: ${script} [-v <version>] [-n <name>] [-s] [-o <directory>] [-t <tests>] [-c <name>] [-p true|false] [-x <number_of_threads>] [-d <wdt_download_url>] [-i <wit_download_url>] [-l <wle_download_url>] [-m <maven_profile_name>] [-h]"
4141
echo " -v Kubernetes version (optional) "
4242
echo " (default: 1.16, supported values depend on the kind version. See kindversions.properties) "
@@ -65,7 +65,7 @@ function usage {
6565
exit $1
6666
}
6767

68-
function captureLogs {
68+
captureLogs() {
6969
echo "Capture Kind logs..."
7070
mkdir "${RESULT_ROOT}/kubelogs"
7171
kind export logs "${RESULT_ROOT}/kubelogs" --name "${kind_name}" --verbosity 99
@@ -121,7 +121,7 @@ while getopts "v:n:o:t:c:x:p:d:i:l:m:sh" opt; do
121121
esac
122122
done
123123

124-
function versionprop {
124+
versionprop() {
125125
grep "${1}_${2}=" "${scriptDir}/kindversions.properties"|cut -d'=' -f2
126126
}
127127

@@ -201,11 +201,16 @@ esac
201201

202202
echo 'Create registry container unless it already exists'
203203
running="$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)"
204-
if [ "${running}" != 'true' ]; then
205-
docker run \
206-
-d --restart=always -p "127.0.0.1:${reg_port}:5000" --name "${reg_name}" \
207-
registry:2
204+
if [ "${running}" = 'false' ]; then
205+
docker rm --force "${reg_name}"
208206
fi
207+
if [ "${running}" = 'true' ]; then
208+
docker stop "${reg_name}"
209+
docker rm --force "${reg_name}"
210+
fi
211+
docker run \
212+
-d --restart=always -p "127.0.0.1:${reg_port}:5000" --name "${reg_name}" \
213+
registry:2
209214

210215
reg_host="${reg_name}"
211216
if [ "${kind_network}" = "bridge" ]; then
@@ -303,6 +308,7 @@ echo 'Clean up result root...'
303308
rm -rf "${RESULT_ROOT:?}/*"
304309

305310
echo "Run tests..."
311+
306312
if [ "${test_filter}" != "**/It*" ]; then
307313
echo "Running mvn -Dit.test=${test_filter} -Dwdt.download.url=${wdt_download_url} -Dwit.download.url=${wit_download_url} -Dwle.download.url=${wle_download_url} -DPARALLEL_CLASSES=${parallel_run} -DNUMBER_OF_THREADS=${threads} -pl integration-tests -P ${maven_profile_name} verify"
308314
time mvn -Dit.test="${test_filter}" -Dwdt.download.url="${wdt_download_url}" -Dwit.download.url="${wit_download_url}" -Dwle.download.url="${wle_download_url}" -DPARALLEL_CLASSES="${parallel_run}" -DNUMBER_OF_THREADS="${threads}" -pl integration-tests -P ${maven_profile_name} verify 2>&1 | tee "${RESULT_ROOT}/kindtest.log" || captureLogs
@@ -319,3 +325,8 @@ fi
319325
echo "Collect journalctl logs"
320326
docker exec kind-worker journalctl --utc --dmesg --system > "${RESULT_ROOT}/journalctl-kind-worker.out"
321327
docker exec kind-control-plane journalctl --utc --dmesg --system > "${RESULT_ROOT}/journalctl-kind-control-plane.out"
328+
329+
echo "Destroy cluster and registry"
330+
kind delete cluster --name "${kind_name}"
331+
docker stop "${reg_name}"
332+
docker rm --force "${reg_name}"

0 commit comments

Comments
 (0)