diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f0cc60ebc86a0361b0a11a6a38577d7a8b05d3dd..9cd5d16ae51b858c0d02433879d07744142e98c0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -237,7 +237,7 @@ archiveretrieve: retry: 1 script: - export NAMESPACE="archiveretrieve-${CTA_BUILD_ID}-$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 4 | head -n 1)" - - cd continuousintegration/orchestration/; ./run_systemtest.sh -n ${NAMESPACE} -p ${CI_PIPELINE_ID} -s tests/archive_retrieve.sh -O -D -t 2400 + - cd continuousintegration/orchestration/; ./run_systemtest.sh -n ${NAMESPACE} -p ${CI_PIPELINE_ID} -s tests/archive_retrieve.sh -O -D -t 2400 -C artifacts: when: always expire_in: 30 days @@ -254,7 +254,7 @@ repack: retry: 1 script: - export NAMESPACE="repack-${CTA_BUILD_ID}-$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 4 | head -n 1)" - - cd continuousintegration/orchestration/; ./run_systemtest.sh -n ${NAMESPACE} -p ${CI_PIPELINE_ID} -s tests/repack_systemtest_wrapper.sh -O -D -t 2400 + - cd continuousintegration/orchestration/; ./run_systemtest.sh -n ${NAMESPACE} -p ${CI_PIPELINE_ID} -s tests/repack_systemtest_wrapper.sh -O -D -t 2400 -C artifacts: when: always expire_in: 30 days @@ -271,7 +271,7 @@ dbunittests_oracle: retry: 1 script: - export NAMESPACE="dbunittestsoracle-${CTA_BUILD_ID}-$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 4 | head -n 1)" - - cd continuousintegration/orchestration/; ./run_systemtest.sh -n ${NAMESPACE} -p ${CI_PIPELINE_ID} -s /usr/bin/true -O -D -U -t 600 + - cd continuousintegration/orchestration/; ./run_systemtest.sh -n ${NAMESPACE} -p ${CI_PIPELINE_ID} -s /usr/bin/true -O -D -U -t 600 -C artifacts: when: always expire_in: 30 days diff --git a/continuousintegration/orchestration/run_systemtest.sh b/continuousintegration/orchestration/run_systemtest.sh index 1d3cc7ea9209391ca1c886e499c5e5374f64da32..149b3238006367862fd0fbee4e7e07761571b166 100755 --- a/continuousintegration/orchestration/run_systemtest.sh +++ b/continuousintegration/orchestration/run_systemtest.sh @@ -26,7 +26,8 @@ PREFLIGHTTEST_SCRIPT='tests/preflighttest.sh' PREFLIGHTTEST_TIMEOUT=60 # default systemtest timeout is 1 hour SYSTEMTEST_TIMEOUT=3600 - +# by default do not cleanup leftover namespaces +cleanup_namespaces=0 die() { echo "$@" 1>&2 ; exit 1; } @@ -43,7 +44,7 @@ Options: -S Use systemd to manage services inside containers -a additional kubernetes resources added to the kubernetes namespace -U Run database unit test only - + -C Cleanup leftover kubernetes namespaces Create a kubernetes instance and launch the system test script specified. Makes sure the created instance is cleaned up at the end and return the status of the system test. @@ -56,7 +57,7 @@ exit 1 # always delete DB and OBJECTSTORE for tests CREATE_OPTS="-D -O" -while getopts "n:d:s:p:b:e:a:B:t:kDOSU" o; do +while getopts "n:d:s:p:b:e:a:B:t:kDOSUC" o; do case "${o}" in s) systemtest_script=${OPTARG} @@ -103,6 +104,9 @@ while getopts "n:d:s:p:b:e:a:B:t:kDOSU" o; do CREATE_OPTS="${CREATE_OPTS} -U" PREFLIGHTTEST_SCRIPT='/usr/bin/true' # we do not run preflight test in the context of unit tests ;; + C) + cleanup_namespaces=1 + ;; *) usage ;; @@ -155,6 +159,12 @@ fi log_dir="${orchestration_dir}/../../pod_logs/${namespace}" mkdir -p ${log_dir} +if [ $cleanup_namespaces == 1 ]; then + echo "Cleaning up old namespaces:" + kubectl get namespace -o json | jq '.items[].metadata | select(.name != "default" and .name != "kube-system") | .name' | egrep '\-[0-9]+git' + kubectl get namespace -o json | jq '.items[].metadata | select(.name != "default" and .name != "kube-system") | .name' | egrep '\-[0-9]+git' | xargs -itoto ./delete_instance.sh -n toto -D + echo DONE +fi function execute_log { mycmd=$1