Skip to content
Snippets Groups Projects
Commit efa8ab3c authored by Julien Leduc's avatar Julien Leduc
Browse files

Cleanup leftover namespaces before launching the kubernetes CI tests

parent 64ff27f3
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment