From 1adceac9a621dd16d401d413fa70c6787a855f2e Mon Sep 17 00:00:00 2001 From: Jonathan West Date: Mon, 3 Feb 2025 14:31:43 -0500 Subject: [PATCH] Fix intermittent failures of E2E tests 1-045 and 1-069 Signed-off-by: Jonathan West --- .../04-check-workload-env.yaml | 32 ++++++++++--- .../03-check_secret.yaml | 46 +++++++++++++------ 2 files changed, 58 insertions(+), 20 deletions(-) diff --git a/test/openshift/e2e/parallel/1-045_validate_repo_exec_timeout/04-check-workload-env.yaml b/test/openshift/e2e/parallel/1-045_validate_repo_exec_timeout/04-check-workload-env.yaml index f3e44f7f5..0bbb4aeec 100644 --- a/test/openshift/e2e/parallel/1-045_validate_repo_exec_timeout/04-check-workload-env.yaml +++ b/test/openshift/e2e/parallel/1-045_validate_repo_exec_timeout/04-check-workload-env.yaml @@ -1,11 +1,29 @@ apiVersion: kuttl.dev/v1beta1 kind: TestStep commands: -- script: sleep 10 -- script: | - timeout=$(oc get -n $NAMESPACE deployment argocd-repo-server -o json \ - | jq -r '.spec.template.spec.containers[0].env[]|select(.name=="ARGOCD_EXEC_TIMEOUT").value') - if test "$timeout" != "300s"; then - echo "Assertion failed. Timeout should be 300s, is '$timeout'" + - script: | + function check_timeout() { + timeout=$(oc get -n $NAMESPACE deployment argocd-repo-server -o json \ + | jq -r '.spec.template.spec.containers[0].env[]|select(.name=="ARGOCD_EXEC_TIMEOUT").value') + if test "$timeout" != "300s"; then + echo "Waiting for timeout to be 300s, is '$timeout'" + return 1 + fi + return 0 + } + + echo -n "Waiting until timeout has expected value" + for i in {1..150}; do # timeout after 5 minutes + + if check_timeout; then + # success + echo ".spec.template.spec.containers[0].env had expected env var" + exit 0 + else + echo "Still waiting for 'spec.template.spec.containers[0].env' to have expected env var" + fi + sleep 2 + done + + echo ".spec.template.spec.containers[0].env never had expected env var" exit 1 - fi \ No newline at end of file diff --git a/test/openshift/e2e/parallel/1-069_validate_redis_secure_comm_autotls_ha/03-check_secret.yaml b/test/openshift/e2e/parallel/1-069_validate_redis_secure_comm_autotls_ha/03-check_secret.yaml index bdace720d..200ecc303 100644 --- a/test/openshift/e2e/parallel/1-069_validate_redis_secure_comm_autotls_ha/03-check_secret.yaml +++ b/test/openshift/e2e/parallel/1-069_validate_redis_secure_comm_autotls_ha/03-check_secret.yaml @@ -2,17 +2,37 @@ apiVersion: kuttl.dev/v1beta1 kind: TestStep commands: - script: | - set -e - secret_type="$(oc get secrets argocd-operator-redis-tls -n $NAMESPACE --template '{{.type}}')" - secret_len="$(oc get secrets argocd-operator-redis-tls -n $NAMESPACE --template '{{len .data}}')" - expected_secret_type="kubernetes.io/tls" - expected_secret_len=2 + function check_secret() { + secret_type="$(oc get secrets argocd-operator-redis-tls -n $NAMESPACE --template '{{.type}}')" + secret_len="$(oc get secrets argocd-operator-redis-tls -n $NAMESPACE --template '{{len .data}}')" + expected_secret_type="kubernetes.io/tls" + expected_secret_len=2 - if test ${secret_type} != ${expected_secret_type}; then - echo "argocd-operator-redis-tls secret type is ${secret_type} and should be ${expected_secret_type}" - exit 1 - fi - if test ${secret_len} != ${expected_secret_len}; then - echo "argocd-operator-redis-tls secret length is ${secret_len} and should be ${expected_secret_len}" - exit 1 - fi \ No newline at end of file + if test ${secret_type} != ${expected_secret_type}; then + echo "argocd-operator-redis-tls secret type is ${secret_type} and should be ${expected_secret_type}" + return 1 + fi + if test ${secret_len} != ${expected_secret_len}; then + echo "argocd-operator-redis-tls secret length is ${secret_len} and should be ${expected_secret_len}" + return 1 + fi + + return 0 + } + + echo -n "Waiting until secret has expected type and .data length" + for i in {1..150}; do # timeout after 5 minutes + + if check_secret; then + # success + echo "Secret has expected length and type." + exit 0 + else + echo "Still waiting for Secret to have expected length and type." + fi + sleep 2 + done + + echo "Secret never had expected length and type" + exit 1 + \ No newline at end of file