From 5b8f63e1ef993d0efd8be53e4fa789ec2d142521 Mon Sep 17 00:00:00 2001 From: phracek Date: Fri, 17 Dec 2021 08:43:49 +0000 Subject: [PATCH] Merge pull request #95 from phracek/fix_openshift_tests Fix openshift tests for redis container --- test/test-lib-openshift.sh | 2 ++ test/test-lib-redis.sh | 7 +++++-- test/test-lib.sh | 8 ++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/test/test-lib-openshift.sh b/test/test-lib-openshift.sh index 624a391..b98e628 100644 --- a/test/test-lib-openshift.sh +++ b/test/test-lib-openshift.sh @@ -530,6 +530,8 @@ function ct_os_cluster_up() { # Shuts down the local OpenShift cluster using 'oc cluster down' function ct_os_cluster_down() { if [ ${OS_CLUSTER_STARTED_BY_TEST:-0} -eq 1 ] ; then + echo "Switching user to system:admin before cluster is going down." + oc login -u system:admin echo "Cluster started by the test, shutting down." oc cluster down else diff --git a/test/test-lib-redis.sh b/test/test-lib-redis.sh index 698abe8..8224fdc 100644 --- a/test/test-lib-redis.sh +++ b/test/test-lib-redis.sh @@ -30,8 +30,11 @@ function test_redis_imagestream() { rhel7|centos7) ;; *) echo "Imagestream testing not supported for $OS environment." ; return 0 ;; esac - - ct_os_test_image_stream_template "${THISDIR}/../imagestreams/redis-${OS%[0-9]*}.json" "${THISDIR}/../examples/redis-ephemeral-template.json" redis "-p REDIS_VERSION=${VERSION}" + local tag="-el7" + if [ "${OS}" == "rhel8" ]; then + tag="-el8" + fi + ct_os_test_image_stream_template "${THISDIR}/../imagestreams/redis-${OS%[0-9]*}.json" "${THISDIR}/../examples/redis-ephemeral-template.json" redis "-p REDIS_VERSION=${VERSION}${tag}" } # vim: set tabstop=2:shiftwidth=2:expandtab: diff --git a/test/test-lib.sh b/test/test-lib.sh index 42f22ba..e954053 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -61,9 +61,9 @@ function ct_enable_cleanup() { # Function returns either 0 in case of pull was successful # Or the test suite exit with 1 in case of pull error function ct_pull_image() { - local image_name="$1"; shift - local exit=${1:-"false"}; shift - local loops=${1:-10}; shift + local image_name="$1"; [[ $# -gt 0 ]] && shift + local exit_variable=${1:-"false"}; [[ $# -gt 0 ]] && shift + local loops=${1:-10} local loop=0 # Let's try to pull image. @@ -84,7 +84,7 @@ function ct_pull_image() { echo "Pulling of image $image_name failed $loops times in a row. Giving up." echo "!!! ERROR with pulling image $image_name !!!!" # shellcheck disable=SC2268 - if [[ x"$exit" == x"false" ]]; then + if [[ x"$exit_variable" == x"false" ]]; then return 1 else exit 1