From 6c26e1c04ad6b00acf2abdeadeaa8cc196031199 Mon Sep 17 00:00:00 2001 From: Brendan Shephard Date: Thu, 6 Jul 2023 12:18:43 +1000 Subject: [PATCH] Add kuttl test assert to check Horizon route This change adds a Kuttl test assertion to ensure the Horizon route is responding to curl requests with the appropriate HTTP status codes. Signed-off-by: Brendan Shephard --- tests/kuttl/common/assert-sample-deployment.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/kuttl/common/assert-sample-deployment.yaml b/tests/kuttl/common/assert-sample-deployment.yaml index 59a5c123..69fc28eb 100644 --- a/tests/kuttl/common/assert-sample-deployment.yaml +++ b/tests/kuttl/common/assert-sample-deployment.yaml @@ -9,3 +9,19 @@ spec: SESSION_TIMEOUT = 3600 status: readyCount: 1 +--- +# Test the status code is correct for each endpoint +# This test is for heat endpoints +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +commands: + - script: | + set -x + RETURN_CODE=0 + PUBLIC_URL=$(oc get route -n $NAMESPACE horizon-public -o jsonpath='{.status.ingress[0].host}') + STATUSCODE=$(curl --silent --output /dev/stderr --head --write-out "%{http_code}" $PUBLIC_URL/dashboard/auth/login/?next=/dashboard/") + if test $STATUSCODE -ne 204; then + RETURN_CODE=1 + echo "${PUBLIC_URL} status code expected is 200 but was ${STATUSCODE}" + fi + exit $RETURN_CODE