From 9a8503cdb0f1be8e06b3d343ee5a6ca1c051655a Mon Sep 17 00:00:00 2001 From: TJ Moore Date: Wed, 25 Oct 2023 12:50:25 -0400 Subject: [PATCH] Update 'backup' KUTTL test Improve error printing behavior and ensure a backup annotation race condition won't happen in faster test environments. --- testing/kuttl/e2e/backup/08--backup-with-just-trigger.yaml | 6 ++++-- testing/kuttl/e2e/backup/11--backup-with-new-flag.yaml | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/testing/kuttl/e2e/backup/08--backup-with-just-trigger.yaml b/testing/kuttl/e2e/backup/08--backup-with-just-trigger.yaml index 9eb4bf1a..687f22b4 100644 --- a/testing/kuttl/e2e/backup/08--backup-with-just-trigger.yaml +++ b/testing/kuttl/e2e/backup/08--backup-with-just-trigger.yaml @@ -1,18 +1,20 @@ apiVersion: kuttl.dev/v1beta1 kind: TestStep commands: -- script: | +- script: | pgbackrest_backup_annotation() { kubectl get --namespace "${NAMESPACE}" postgrescluster/backup-cluster \ --output 'go-template={{ index .metadata.annotations "postgres-operator.crunchydata.com/pgbackrest-backup" }}' } PRIOR=$(pgbackrest_backup_annotation) + # ensure annotation timestamp will be different + sleep 1 RESULT=$(kubectl-pgo --namespace "${NAMESPACE}" backup backup-cluster) CURRENT=$(pgbackrest_backup_annotation) if [ "${CURRENT}" = "${PRIOR}" ]; then - printf 'Expected annotation to change, got %q' "${CURRENT}" + printf 'Expected annotation to change, got %q\n' "${CURRENT}" exit 1 fi diff --git a/testing/kuttl/e2e/backup/11--backup-with-new-flag.yaml b/testing/kuttl/e2e/backup/11--backup-with-new-flag.yaml index 5c418a92..43f61904 100644 --- a/testing/kuttl/e2e/backup/11--backup-with-new-flag.yaml +++ b/testing/kuttl/e2e/backup/11--backup-with-new-flag.yaml @@ -8,11 +8,11 @@ commands: echo "RESULT from taking backup: ${RESULT}" if [ "${STATUS-0}" -eq 0 ]; then - printf 'Expected error, got none' + printf 'Expected error, got none\n' exit 1 fi if [[ "${RESULT,,}" != *conflict* || "${RESULT}" != *repoName* ]]; then - printf 'Expected conflict on repoName, got %q' "${RESULT}" + printf 'Expected conflict on repoName, got %q\n' "${RESULT}" exit 1 fi