diff --git a/hack/e2e/run-e2e.sh b/hack/e2e/run-e2e.sh index fb0b28709b..1c280d8e6f 100755 --- a/hack/e2e/run-e2e.sh +++ b/hack/e2e/run-e2e.sh @@ -39,22 +39,23 @@ notinpath () { esac } +ensure_image_pull_secret() { + if [ -n "${DOCKER_SERVER-}" ] && [ -n "${DOCKER_USERNAME-}" ] && [ -n "${DOCKER_PASSWORD-}" ]; then + if ! kubectl get secret cnpg-pull-secret -n cnpg-system >/dev/null 2>&1; then + kubectl create secret docker-registry \ + -n cnpg-system \ + cnpg-pull-secret \ + --docker-server="${DOCKER_SERVER}" \ + --docker-username="${DOCKER_USERNAME}" \ + --docker-password="${DOCKER_PASSWORD}" + fi + fi +} + # Process the e2e templates export E2E_PRE_ROLLING_UPDATE_IMG=${E2E_PRE_ROLLING_UPDATE_IMG:-${POSTGRES_IMG%.*}} export AZURE_STORAGE_ACCOUNT=${AZURE_STORAGE_ACCOUNT:-''} -# Getting the operator images need a pull secret -kubectl delete namespace cnpg-system || : -kubectl create namespace cnpg-system -if [ -n "${DOCKER_SERVER-}" ] && [ -n "${DOCKER_USERNAME-}" ] && [ -n "${DOCKER_PASSWORD-}" ]; then - kubectl create secret docker-registry \ - -n cnpg-system \ - cnpg-pull-secret \ - --docker-server="${DOCKER_SERVER}" \ - --docker-username="${DOCKER_USERNAME}" \ - --docker-password="${DOCKER_PASSWORD}" -fi - go_bin="$(go env GOPATH)/bin" if notinpath "${go_bin}"; then export PATH="${go_bin}:${PATH}" @@ -74,6 +75,10 @@ echo "E2E tests are running with the following filters: ${LABEL_FILTERS}" RC=0 RC_GINKGO1=0 if [[ "${TEST_UPGRADE_TO_V1}" != "false" ]]; then + # Getting the operator images need a pull secret + kubectl delete namespace cnpg-system || : + kubectl create namespace cnpg-system + ensure_image_pull_secret # Generate a manifest for the operator after the api upgrade # TODO: this is almost a "make deploy". Refactor. make manifests kustomize @@ -103,6 +108,11 @@ if [[ "${TEST_UPGRADE_TO_V1}" != "false" ]]; then jq -e -c -f "${ROOT_DIR}/hack/e2e/test-report.jq" "${ROOT_DIR}/tests/e2e/out/upgrade_report.json" || RC=$? fi +# Getting the operator images need a pull secret +kubectl delete namespace cnpg-system || : +kubectl create namespace cnpg-system +ensure_image_pull_secret + CONTROLLER_IMG="${CONTROLLER_IMG}" \ POSTGRES_IMAGE_NAME="${POSTGRES_IMG}" \ make -C "${ROOT_DIR}" deploy diff --git a/tests/e2e/volume_snapshot_test.go b/tests/e2e/volume_snapshot_test.go index 020c6a9c88..1abc761be6 100644 --- a/tests/e2e/volume_snapshot_test.go +++ b/tests/e2e/volume_snapshot_test.go @@ -20,6 +20,7 @@ import ( "encoding/json" "os" "strings" + "time" volumesnapshot "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1" "k8s.io/apimachinery/pkg/types" @@ -240,6 +241,10 @@ var _ = Describe("Verify Volume Snapshot", // Create a "test" table with values 1,2 AssertCreateTestData(namespace, clusterToSnapshotName, tableName, psqlClientPod) + // Because GetCurrentTimestamp() rounds down to the second and is executed + // right after the creation of the test data, we wait for 1s to avoid not + // including the newly created data within the recovery_target_time + time.Sleep(1 * time.Second) // Get the recovery_target_time and pass it to the template engine recoveryTargetTime, err := testUtils.GetCurrentTimestamp(namespace, clusterToSnapshotName, env, psqlClientPod) Expect(err).ToNot(HaveOccurred())