From 044c6e50883ab20753d0e8bad5be67a3397b6a2c Mon Sep 17 00:00:00 2001 From: David Hoese <david.hoese@ssec.wisc.edu> Date: Thu, 12 Nov 2020 16:10:54 -0600 Subject: [PATCH] Fix CI tests since after_script is in a separate environment --- ci_tests/cleanup_basic_grb_test.sh | 22 +++++++++++++++++++++- ci_tests/get_release_names.sh | 4 ++++ ci_tests/gitlab-ci.yaml | 3 +-- ci_tests/run_basic_grb_test.sh | 10 ++++++---- 4 files changed, 32 insertions(+), 7 deletions(-) create mode 100755 ci_tests/get_release_names.sh diff --git a/ci_tests/cleanup_basic_grb_test.sh b/ci_tests/cleanup_basic_grb_test.sh index 52205d1..31dbb28 100755 --- a/ci_tests/cleanup_basic_grb_test.sh +++ b/ci_tests/cleanup_basic_grb_test.sh @@ -1,3 +1,23 @@ #!/usr/bin/env bash -helm uninstall ${GRB_RELEASE_NAME} \ No newline at end of file +debug() { + >&2 echo "DEBUG: $@" +} + +error() { + >&2 echo "ERROR: $@" + exit 1 +} + +check_and_uninstall() { + release_name=$1 + if [[ -z ${release_name} ]]; then + # the chart was never created + return + fi + debug "Uninstalling ${release_name}" + helm uninstall ${release_name} | error "Could not uninstall chart $release_name" +} + +source ./ci_tests/get_release_names.sh +check_and_uninstall ${GRB_RELEASE_NAME} \ No newline at end of file diff --git a/ci_tests/get_release_names.sh b/ci_tests/get_release_names.sh new file mode 100755 index 0000000..35c0c80 --- /dev/null +++ b/ci_tests/get_release_names.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +export RELEASE_PREFIX="${CI_JOB_NAME//_/-}-${CI_JOB_ID//_/-}" +export GRB_RELEASE_NAME="${RELEASE_PREFIX}-cspp-geo-grb" diff --git a/ci_tests/gitlab-ci.yaml b/ci_tests/gitlab-ci.yaml index 6cd9426..1fe1f8e 100644 --- a/ci_tests/gitlab-ci.yaml +++ b/ci_tests/gitlab-ci.yaml @@ -70,8 +70,7 @@ test_basic_grb: extends: .helm_based_job stage: test script: - # need to source to get release name variables for cleanup - - source ./ci_tests/run_basic_grb_test.sh + - ./ci_tests/run_basic_grb_test.sh after_script: - ./ci_tests/cleanup_basic_grb_test.sh dependencies: diff --git a/ci_tests/run_basic_grb_test.sh b/ci_tests/run_basic_grb_test.sh index b509b92..aec9c0e 100755 --- a/ci_tests/run_basic_grb_test.sh +++ b/ci_tests/run_basic_grb_test.sh @@ -12,15 +12,17 @@ error() { set -e ns=$(./helpers/get_namespace.sh) -cd geosphere-grb/chart -export RELEASE_PREFIX="${CI_JOB_NAME//_/-}-${CI_JOB_ID//_/-}" -export GRB_RELEASE_NAME="${RELEASE_PREFIX}-cspp-geo-grb" +pushd geosphere-grb/chart +source ci_tests/get_release_names.sh helm upgrade -v 2 --install --namespace $ns -f ../../ci_tests/values-grb-g16.yaml ${GRB_RELEASE_NAME} cspp-geo-grb/ +popd # give kubernetes a bit to create the pod -sleep 5 +sleep 30 +debug "Getting pod name" GRB_POD_NAME=$(kubectl -n $ns get pods --selector=app.kubernetes.io/instance=${GRB_RELEASE_NAME} -o name) +debug "GRB pod name: ${GRB_POD_NAME}" count=0 while true; do num_files=$(kubectl exec -n $ns ${GRB_POD_NAME} -- ls -1 /dst/products | wc -l) -- GitLab