From 09191d601196785179adc12fa8459b2dfd4d35eb Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Fri, 20 Sep 2024 15:00:59 +0530 Subject: [PATCH] Fix basic-deployment kuttl assert Currently the way kuttl test is written , it will still pass if no status code is returned as script doesn't have proper exit mechanism to handle that . This PR fixes that and introduce proper error message . Also fixes the command to run in required namespace --- tests/kuttl/common/assert-sample-deployment.yaml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/kuttl/common/assert-sample-deployment.yaml b/tests/kuttl/common/assert-sample-deployment.yaml index dbd5d8c2..d2a53fd0 100644 --- a/tests/kuttl/common/assert-sample-deployment.yaml +++ b/tests/kuttl/common/assert-sample-deployment.yaml @@ -19,9 +19,14 @@ commands: set -x RETURN_CODE=0 PUBLIC_URL=$(oc get -n $NAMESPACE horizon horizon -o jsonpath='{.status.endpoint}') - STATUSCODE=$(oc exec -it deployment/horizon -- curl --silent --output /dev/stderr --head --write-out "%{http_code}" "$PUBLIC_URL/dashboard/auth/login/?next=/dashboard/" -k) - if test $STATUSCODE -ne 200; then + STATUSCODE=$(oc -n $NAMESPACE exec -it deployment/horizon -- curl --silent --output /dev/stderr --head --write-out "%{http_code}" "$PUBLIC_URL/dashboard/auth/login/?next=/dashboard/" -k) + if [${STATUSCODE} ]; then + if test $STATUSCODE -ne 200; then + RETURN_CODE=1 + echo "${PUBLIC_URL} status code expected is 200 but was ${STATUSCODE}" + fi + else RETURN_CODE=1 - echo "${PUBLIC_URL} status code expected is 200 but was ${STATUSCODE}" - fi + echo "No status code returned, pls check if horizon is available" + fi exit $RETURN_CODE