From d773fbea47b506e5e0b24e27bd366099a368fda2 Mon Sep 17 00:00:00 2001 From: Rohith Jayawardene Date: Thu, 11 May 2023 18:40:40 +0100 Subject: [PATCH] [E2E] - Waiting Longer for Creation At present you can have false positives on this unit test as its not waiting long enough for the job to be created. I've added a check to ensure the pod is available so we don't end up with a null here --- test/e2e/integration/error-handler.bats | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/e2e/integration/error-handler.bats b/test/e2e/integration/error-handler.bats index ad9a50e2b..82ebd527f 100644 --- a/test/e2e/integration/error-handler.bats +++ b/test/e2e/integration/error-handler.bats @@ -59,7 +59,11 @@ EOF @test "We should be able to see the logs from the failing resource" { NAMESPACE="error-handling" - POD=$(kubectl -n ${NAMESPACE} get pod -l terraform.appvia.io/configuration=${RESOURCE_NAME} -l terraform.appvia.io/stage=plan -o json | jq -r '.items[0].metadata.name') + LABELS="-l terraform.appvia.io/configuration=${RESOURCE_NAME} -l terraform.appvia.io/stage=plan" + + retry 10 "kubectl -n ${NAMESPACE} get po --no-headers ${LABELS} -o json | wc -l | grep -v 0" + [[ "$status" -eq 0 ]] + POD=$(kubectl -n ${NAMESPACE} get pod ${LABELS} -o json | jq -r '.items[0].metadata.name') [[ "$status" -eq 0 ]] runit "kubectl -n ${NAMESPACE} logs ${POD} 2>&1" "grep -q 'failed to download the source'" [[ "$status" -eq 0 ]]