Skip to content

Commit

Permalink
K8SPG-597 Fixing test case upgrade-minor to work with postures images…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
ptankov authored Jun 25, 2024
1 parent e9ec53b commit 47ea9d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
14 changes: 7 additions & 7 deletions e2e-tests/tests/upgrade-minor/01-create-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
9 changes: 4 additions & 5 deletions e2e-tests/tests/upgrade-minor/05-upgrade-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 47ea9d1

Please sign in to comment.