Skip to content

Commit 8b57cc5

Browse files
authored
Merge branch 'main' into dependabot/go_modules/opentelemetry-975b07ac31
2 parents d1aaecd + d602b3c commit 8b57cc5

11 files changed

Lines changed: 153 additions & 81 deletions
Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,12 @@
11
apiVersion: kuttl.dev/v1beta1
22
kind: TestAssert
3-
timeout: 900
3+
timeout: 660
44
commands:
55
- script: |-
66
set -o errexit
77
set -o xtrace
88
99
source ../../functions
1010
11-
retry 30 5 bash -c '
12-
status=$(kubectl -n "'"${NAMESPACE}"'" get pg major-upgrade-logical-replica \
13-
-o jsonpath="{.status.conditions[?(@.type==\"ReadyForLogicalReplication\")].status}")
14-
echo "ReadyForLogicalReplication: ${status}"
15-
[[ ${status} == "True" ]]
16-
'
17-
18-
retry 60 10 bash -c '
19-
state=$(kubectl -n "'"${NAMESPACE}"'" get pg major-upgrade-logical-replica \
20-
-o jsonpath="{.status.logicalReplicas[?(@.name==\"analytics\")].state}")
21-
echo "logical replica analytics state: ${state}"
22-
[[ ${state} == "ready" ]]
23-
'
24-
25-
kubectl -n "${NAMESPACE}" wait --for=condition=Ready pod \
26-
-l "pgv2.percona.com/logical-replica=analytics" --timeout=120s
27-
28-
# The version the replica was seeded at is what the operator later compares
29-
# against spec.postgresVersion to notice it was left behind by pg_upgrade.
30-
seeded=$(kubectl -n "${NAMESPACE}" get pg major-upgrade-logical-replica \
31-
-o jsonpath='{.status.logicalReplicas[?(@.name=="analytics")].postgresVersion}')
32-
echo "seeded at PostgreSQL: ${seeded}"
33-
[[ ${seeded} == "17" ]]
34-
35-
PASS=$(get_psql_user_pass major-upgrade-logical-replica-pguser-postgres)
36-
REPLICA="major-upgrade-logical-replica-lr-analytics.${NAMESPACE}.svc"
37-
38-
rows=$(run_psql \
39-
'\c myapp \\\ SELECT count(*) FROM myApp WHERE id = 100500;' \
40-
"postgres://postgres:${PASS}@${REPLICA}" | xargs)
41-
42-
if [[ ${rows} != "1" ]]; then
43-
echo "ERROR: expected the seeded row on the logical replica, got: ${rows}"
44-
exit 1
45-
fi
11+
kubectl -n "${NAMESPACE}" wait --for=jsonpath='{.status.state}'=Succeeded \
12+
--timeout=560s pg-backup/major-upgrade-logical-replica-seed-repo1
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestStep
3+
commands:
4+
- timeout: 30
5+
script: |-
6+
set -o errexit
7+
set -o xtrace
8+
9+
source ../../functions
10+
11+
# The pgbackrest bootstrap Job restores the latest full backup, and the
12+
# one taken at cluster creation predates the rows written above. Take a
13+
# new one so the seeded data is actually in the backup being restored.
14+
cat <<EOF | kubectl -n "${NAMESPACE}" apply -f -
15+
apiVersion: pgv2.percona.com/v2
16+
kind: PerconaPGBackup
17+
metadata:
18+
name: major-upgrade-logical-replica-seed-repo1
19+
spec:
20+
pgCluster: major-upgrade-logical-replica
21+
repoName: repo1
22+
options:
23+
- --type=full
24+
EOF

e2e-tests/tests/major-upgrade-logical-replica/03-add-logical-replica.yaml renamed to e2e-tests/tests/major-upgrade-logical-replica/04-add-logical-replica.yaml

File renamed without changes.
Lines changed: 36 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,45 @@
11
apiVersion: kuttl.dev/v1beta1
22
kind: TestAssert
3-
timeout: 600
3+
timeout: 900
44
commands:
5-
# K8SPG-1114: the regression this suite exists for. initdb gives the new data
6-
# directory a default postgresql.conf, so without the wal_level and
7-
# max_replication_slots carried over in Step 4b the upgrade dies in the Step 5
8-
# check with: "wal_level" must be "logical" but is set to "replica".
95
- script: |-
106
set -o errexit
7+
set -o xtrace
118
12-
job=$(kubectl -n "${NAMESPACE}" get job \
13-
-l postgres-operator.crunchydata.com/cluster=major-upgrade-logical-replica \
14-
-l postgres-operator.crunchydata.com/role=pgupgrade \
15-
-o name | head -1)
9+
source ../../functions
1610
17-
if [[ -n ${job} ]]; then
18-
echo "--- pg_upgrade job log ---"
19-
kubectl -n "${NAMESPACE}" logs "${job}" --tail=100 || true
11+
retry 30 5 bash -c '
12+
status=$(kubectl -n "'"${NAMESPACE}"'" get pg major-upgrade-logical-replica \
13+
-o jsonpath="{.status.conditions[?(@.type==\"ReadyForLogicalReplication\")].status}")
14+
echo "ReadyForLogicalReplication: ${status}"
15+
[[ ${status} == "True" ]]
16+
'
2017
21-
if kubectl -n "${NAMESPACE}" logs "${job}" 2>/dev/null | grep -q 'must be "logical"'; then
22-
echo 'ERROR: pg_upgrade rejected the new cluster over wal_level'
23-
exit 1
24-
fi
18+
retry 60 10 bash -c '
19+
state=$(kubectl -n "'"${NAMESPACE}"'" get pg major-upgrade-logical-replica \
20+
-o jsonpath="{.status.logicalReplicas[?(@.name==\"analytics\")].state}")
21+
echo "logical replica analytics state: ${state}"
22+
[[ ${state} == "ready" ]]
23+
'
24+
25+
kubectl -n "${NAMESPACE}" wait --for=condition=Ready pod \
26+
-l "pgv2.percona.com/logical-replica=analytics" --timeout=120s
27+
28+
# The version the replica was seeded at is what the operator later compares
29+
# against spec.postgresVersion to notice it was left behind by pg_upgrade.
30+
seeded=$(kubectl -n "${NAMESPACE}" get pg major-upgrade-logical-replica \
31+
-o jsonpath='{.status.logicalReplicas[?(@.name=="analytics")].postgresVersion}')
32+
echo "seeded at PostgreSQL: ${seeded}"
33+
[[ ${seeded} == "17" ]]
34+
35+
PASS=$(get_psql_user_pass major-upgrade-logical-replica-pguser-postgres)
36+
REPLICA="major-upgrade-logical-replica-lr-analytics.${NAMESPACE}.svc"
37+
38+
rows=$(run_psql \
39+
'\c myapp \\\ SELECT count(*) FROM myApp WHERE id = 100500;' \
40+
"postgres://postgres:${PASS}@${REPLICA}" | xargs)
41+
42+
if [[ ${rows} != "1" ]]; then
43+
echo "ERROR: expected the seeded row on the logical replica, got: ${rows}"
44+
exit 1
2545
fi
26-
---
27-
apiVersion: pgv2.percona.com/v2
28-
kind: PerconaPGUpgrade
29-
metadata:
30-
name: 17-to-18
31-
status:
32-
conditions:
33-
- type: Progressing
34-
reason: PGUpgradeCompleted
35-
status: "False"
36-
- type: Succeeded
37-
reason: PGUpgradeSucceeded
38-
status: "True"
39-
---
40-
apiVersion: pgv2.percona.com/v2
41-
kind: PerconaPGCluster
42-
metadata:
43-
name: major-upgrade-logical-replica
44-
spec:
45-
postgresVersion: 18
46-
status:
47-
postgres:
48-
instances:
49-
- name: instance1
50-
ready: 2
51-
size: 2
52-
ready: 2
53-
size: 2
54-
state: ready
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestAssert
3+
timeout: 600
4+
commands:
5+
# K8SPG-1114: the regression this suite exists for. initdb gives the new data
6+
# directory a default postgresql.conf, so without the wal_level and
7+
# max_replication_slots carried over in Step 4b the upgrade dies in the Step 5
8+
# check with: "wal_level" must be "logical" but is set to "replica".
9+
- script: |-
10+
set -o errexit
11+
12+
job=$(kubectl -n "${NAMESPACE}" get job \
13+
-l postgres-operator.crunchydata.com/cluster=major-upgrade-logical-replica \
14+
-l postgres-operator.crunchydata.com/role=pgupgrade \
15+
-o name | head -1)
16+
17+
if [[ -n ${job} ]]; then
18+
echo "--- pg_upgrade job log ---"
19+
kubectl -n "${NAMESPACE}" logs "${job}" --tail=100 || true
20+
21+
if kubectl -n "${NAMESPACE}" logs "${job}" 2>/dev/null | grep -q 'must be "logical"'; then
22+
echo 'ERROR: pg_upgrade rejected the new cluster over wal_level'
23+
exit 1
24+
fi
25+
fi
26+
---
27+
apiVersion: pgv2.percona.com/v2
28+
kind: PerconaPGUpgrade
29+
metadata:
30+
name: 17-to-18
31+
status:
32+
conditions:
33+
- type: Progressing
34+
reason: PGUpgradeCompleted
35+
status: "False"
36+
- type: Succeeded
37+
reason: PGUpgradeSucceeded
38+
status: "True"
39+
---
40+
apiVersion: pgv2.percona.com/v2
41+
kind: PerconaPGCluster
42+
metadata:
43+
name: major-upgrade-logical-replica
44+
spec:
45+
postgresVersion: 18
46+
status:
47+
postgres:
48+
instances:
49+
- name: instance1
50+
ready: 2
51+
size: 2
52+
ready: 2
53+
size: 2
54+
state: ready

e2e-tests/tests/major-upgrade-logical-replica/04-upgrade.yaml renamed to e2e-tests/tests/major-upgrade-logical-replica/05-upgrade.yaml

File renamed without changes.

e2e-tests/tests/major-upgrade-logical-replica/05-verify-replica-invalidated.yaml renamed to e2e-tests/tests/major-upgrade-logical-replica/06-verify-replica-invalidated.yaml

File renamed without changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestAssert
3+
timeout: 660
4+
commands:
5+
- script: |-
6+
set -o errexit
7+
set -o xtrace
8+
9+
source ../../functions
10+
11+
kubectl -n "${NAMESPACE}" wait --for=jsonpath='{.status.state}'=Succeeded \
12+
--timeout=560s pg-backup/major-upgrade-logical-replica-reseed-repo1
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestStep
3+
commands:
4+
- timeout: 30
5+
script: |-
6+
set -o errexit
7+
set -o xtrace
8+
9+
source ../../functions
10+
11+
# pg_upgrade left the repository holding only pre-upgrade backups, so the
12+
# bootstrap Job of the reseed below would restore a PostgreSQL 17 data
13+
# directory. Take a full backup of the upgraded cluster first.
14+
cat <<EOF | kubectl -n "${NAMESPACE}" apply -f -
15+
apiVersion: pgv2.percona.com/v2
16+
kind: PerconaPGBackup
17+
metadata:
18+
name: major-upgrade-logical-replica-reseed-repo1
19+
spec:
20+
pgCluster: major-upgrade-logical-replica
21+
repoName: repo1
22+
options:
23+
- --type=full
24+
EOF

e2e-tests/tests/major-upgrade-logical-replica/06-assert.yaml renamed to e2e-tests/tests/major-upgrade-logical-replica/08-assert.yaml

File renamed without changes.

0 commit comments

Comments
 (0)