From b1ffed0572488e661ded3a2d46e83dce5b7c2660 Mon Sep 17 00:00:00 2001 From: Zuzana Miklankova Date: Mon, 6 Jun 2022 14:25:06 +0200 Subject: [PATCH 1/2] run all openshift4 tests even when one fails --- test/run-openshift-remote-cluster | 15 +++++++-------- test/test-lib-postgresql.sh | 3 +-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/test/run-openshift-remote-cluster b/test/run-openshift-remote-cluster index 32614ee0..303bba85 100755 --- a/test/run-openshift-remote-cluster +++ b/test/run-openshift-remote-cluster @@ -11,8 +11,12 @@ THISDIR=$(dirname ${BASH_SOURCE[0]}) source ${THISDIR}/test-lib-postgresql.sh +TEST_LIST="\ +test_postgresql_integration +test_postgresql_imagestream +" -set -eo nounset +set -u trap ct_os_cleanup EXIT SIGINT @@ -25,13 +29,8 @@ oc status || false "It looks like oc is not properly logged in." # For testing on OpenShift 4 we use internal registry export CT_OCP4_TEST=true -# Check the template -test_postgresql_integration "${IMAGE_NAME}" - -# Check the imagestream -test_postgresql_imagestream - -OS_TESTSUITE_RESULT=0 +TEST_SUMMARY='' +TEST_SET=${TESTS:-$TEST_LIST} ct_run_tests_from_testset "openshift-remote-cluster" # vim: set tabstop=2:shiftwidth=2:expandtab: diff --git a/test/test-lib-postgresql.sh b/test/test-lib-postgresql.sh index 19ca08bd..0b12c0f4 100644 --- a/test/test-lib-postgresql.sh +++ b/test/test-lib-postgresql.sh @@ -13,10 +13,9 @@ source "${THISDIR}"/test-lib-openshift.sh source "${THISDIR}"/test-lib-remote-openshift.sh function test_postgresql_integration() { - local image_name=$1 local service_name=postgresql ct_os_template_exists postgresql-ephemeral && t=postgresql-ephemeral || t=postgresql-persistent - ct_os_test_template_app_func "${image_name}" \ + ct_os_test_template_app_func "${IMAGE_NAME}" \ "${t}" \ "${service_name}" \ "ct_os_check_cmd_internal '' '${service_name}-testing' 'PGPASSWORD=testp pg_isready -t 15 -h -U testu -d testdb' 'accepting connections' 120" \ From 4ab07f2f4add6040df2838d115588d697564f34b Mon Sep 17 00:00:00 2001 From: Zuzana Miklankova Date: Tue, 7 Jun 2022 16:42:31 +0200 Subject: [PATCH 2/2] exit testsuite gracefully, when oc setup fails The nounset shell option needs to be set after the OC login attempt, because (from man shopt): -u If expansion is attempted on an unset variable or parameter, the shell prints an error message, and, if not interactive exits with a non-zero status. That is in this matter inconvenient, as we do not really know from log what has happened if the oc login fails and moreover the test suite ends with success, as only the first failed test sets TESTSUITE_RESULT to 1. If we check login with the ct_os_check_login function, it handles the situation conveniently. --- test/run-openshift-remote-cluster | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/run-openshift-remote-cluster b/test/run-openshift-remote-cluster index 303bba85..9bb67139 100755 --- a/test/run-openshift-remote-cluster +++ b/test/run-openshift-remote-cluster @@ -16,15 +16,15 @@ test_postgresql_integration test_postgresql_imagestream " -set -u - trap ct_os_cleanup EXIT SIGINT ct_os_set_ocp4 ct_os_check_compulsory_vars -oc status || false "It looks like oc is not properly logged in." +ct_os_check_login || exit 1 + +set -u # For testing on OpenShift 4 we use internal registry export CT_OCP4_TEST=true