From 47ea9d13fc0d0478aa0900f36f34d3aa46358ca4 Mon Sep 17 00:00:00 2001 From: Pavel Tankov <4014969+ptankov@users.noreply.github.com> Date: Tue, 25 Jun 2024 19:58:39 +0300 Subject: [PATCH] K8SPG-597 Fixing test case upgrade-minor to work with postures images which have minor numbers in the image name (#821) * We now have env var PG_VER so no need to calculate the version from the image name, also, the calculation was buggy when the version contains a dot and a minor number, e.g. 16.3 * Refactor upgrade-cluster.yaml to use PG_VER environment variable instead of calculating version from image name --- .../tests/upgrade-minor/01-create-cluster.yaml | 14 +++++++------- .../tests/upgrade-minor/05-upgrade-cluster.yaml | 9 ++++----- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/e2e-tests/tests/upgrade-minor/01-create-cluster.yaml b/e2e-tests/tests/upgrade-minor/01-create-cluster.yaml index b48048cb9a..ac31b4a330 100644 --- a/e2e-tests/tests/upgrade-minor/01-create-cluster.yaml +++ b/e2e-tests/tests/upgrade-minor/01-create-cluster.yaml @@ -13,25 +13,25 @@ commands: curl -s "https://raw.githubusercontent.com/percona/percona-postgresql-operator/v${lower_ver}/deploy/cr.yaml" >"${TEMP_DIR}/cr_lower.yaml" # get PG version which we want to test - pg_ver=$(echo "$IMAGE_POSTGRESQL" | cut -d':' -f2 | grep -oE '\-ppg[0-9]+-' | grep -oE '[0-9]+' | tr -d '-') + pg_ver=$PG_VER pg_exists=0 - pg_exists=$(curl -s https://check.percona.com/versions/v1/pg-operator/${lower_ver} | jq '.versions[].matrix.postgresql | with_entries(select(.key | startswith("'${pg_ver}'"))) | length') + pg_exists=$(curl -s https://check.percona.com/versions/v1/pg-operator/${lower_ver} | jq '.versions[].matrix.postgresql | with_entries(select(.key | startswith("'$pg_ver'"))) | length') # if the lower version of operator doesn't have new PG version we will use lower PG version # but in that case not the intended targer PG database image will be tested # (this should happen once a year on major PG version release, but only for this latest version) if [ $pg_exists -eq 0 ]; then pg_ver=$((pg_ver - 1)) fi - echo "${pg_ver}" >"${TEMP_DIR}/pg_ver.txt" + echo $pg_ver >"${TEMP_DIR}/pg_ver.txt" yq -i eval ' .metadata.name = "'${test_name}'" | .metadata.labels = {"e2e":"'${test_name}'"} | - .spec.image = "percona/percona-postgresql-operator:'${lower_ver}'-ppg'${pg_ver}'-postgres" | - .spec.postgresVersion = '${pg_ver}' | - .spec.proxy.pgBouncer.image = "percona/percona-postgresql-operator:'${lower_ver}'-ppg'${pg_ver}'-pgbouncer" | + .spec.image = "percona/percona-postgresql-operator:'${lower_ver}'-ppg'$pg_ver'-postgres" | + .spec.postgresVersion = '$pg_ver' | + .spec.proxy.pgBouncer.image = "percona/percona-postgresql-operator:'${lower_ver}'-ppg'$pg_ver'-pgbouncer" | .spec.backups.pgbackrest.repos[0].schedules = null | - .spec.backups.pgbackrest.image = "percona/percona-postgresql-operator:'${lower_ver}'-ppg'${pg_ver}'-pgbackrest" | + .spec.backups.pgbackrest.image = "percona/percona-postgresql-operator:'${lower_ver}'-ppg'$pg_ver'-pgbackrest" | .spec.users += [{"name":"postgres","password":{"type":"AlphaNumeric"}}] | .spec.users += [{"name":"'${test_name}'","password":{"type":"AlphaNumeric"}}]' "${TEMP_DIR}/cr_lower.yaml" kubectl -n "${NAMESPACE}" apply -f "${TEMP_DIR}/cr_lower.yaml" diff --git a/e2e-tests/tests/upgrade-minor/05-upgrade-cluster.yaml b/e2e-tests/tests/upgrade-minor/05-upgrade-cluster.yaml index 6b3ff43155..f43220c9ed 100644 --- a/e2e-tests/tests/upgrade-minor/05-upgrade-cluster.yaml +++ b/e2e-tests/tests/upgrade-minor/05-upgrade-cluster.yaml @@ -8,15 +8,14 @@ commands: source ../../functions pg_ver_lower="$(cat ${TEMP_DIR}/pg_ver.txt)" - pg_ver_upper=$(echo "$IMAGE_POSTGRESQL" | cut -d':' -f2 | grep -oE '\-ppg[0-9]+-' | grep -oE '[0-9]+' | tr -d '-') target_image_postgresql=$IMAGE_POSTGRESQL target_image_pgbouncer=$IMAGE_PGBOUNCER target_image_backrest=$IMAGE_BACKREST - if [ "${pg_ver_lower}" != "${pg_ver_upper}" ]; then - target_image_postgresql="perconalab/percona-postgresql-operator:main-ppg${pg_ver_lower}-postgres" - target_image_pgbouncer="perconalab/percona-postgresql-operator:main-ppg${pg_ver_lower}-pgbouncer" - target_image_backrest="perconalab/percona-postgresql-operator:main-ppg${pg_ver_lower}-pgbackrest" + if [ "$pg_ver_lower" != "$PG_VER" ]; then + target_image_postgresql="perconalab/percona-postgresql-operator:main-ppg$pg_ver_lower-postgres" + target_image_pgbouncer="perconalab/percona-postgresql-operator:main-ppg$pg_ver_lower-pgbouncer" + target_image_backrest="perconalab/percona-postgresql-operator:main-ppg$pg_ver_lower-pgbackrest" fi cr_ver=$(yq '.spec.crVersion' $DEPLOY_DIR/cr.yaml)