Skip to content

Commit dd3e6be

Browse files
committed
Replace KUTTL 'empty-image-upgrade' with 'major-upgrade-missing-image'
Now that the bug fix is in place, move 'major-upgrade-missing-image' back to the main testing folder in place of the subset test, 'empty-image-upgrade' Issue: PGO-190
1 parent a557bf2 commit dd3e6be

19 files changed

+216
-20
lines changed

testing/kuttl/e2e/empty-image-upgrade/README.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

testing/kuttl/e2e/empty-image-upgrade/01--valid-upgrade.yaml renamed to testing/kuttl/e2e/major-upgrade-missing-image/01--valid-upgrade.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ spec:
88
# postgres version that is no longer available
99
fromPostgresVersion: 10
1010
toPostgresVersion: ${KUTTL_PG_UPGRADE_TO_VERSION}
11-
postgresClusterName: missing-primary-status
11+
postgresClusterName: major-upgrade-empty-image

testing/kuttl/e2e/empty-image-upgrade/10--cluster.yaml renamed to testing/kuttl/e2e/major-upgrade-missing-image/10--cluster.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
apiVersion: postgres-operator.crunchydata.com/v1beta1
55
kind: PostgresCluster
66
metadata:
7-
name: missing-primary-status
7+
name: major-upgrade-empty-image
88
spec:
99
# postgres version that is no longer available
1010
postgresVersion: 10

testing/kuttl/e2e/empty-image-upgrade/11--shutdown-cluster.yaml renamed to testing/kuttl/e2e/major-upgrade-missing-image/11--shutdown-cluster.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
apiVersion: postgres-operator.crunchydata.com/v1beta1
44
kind: PostgresCluster
55
metadata:
6-
name: missing-primary-status
6+
name: major-upgrade-empty-image
77
spec:
88
shutdown: true
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
# Update the postgres version and restart the cluster.
3+
apiVersion: postgres-operator.crunchydata.com/v1beta1
4+
kind: PostgresCluster
5+
metadata:
6+
name: major-upgrade-empty-image
7+
spec:
8+
shutdown: false
9+
postgresVersion: ${KUTTL_PG_UPGRADE_FROM_VERSION}
10+
---
11+
apiVersion: postgres-operator.crunchydata.com/v1beta1
12+
kind: PGUpgrade
13+
metadata:
14+
name: empty-image-upgrade
15+
spec:
16+
# update postgres version
17+
fromPostgresVersion: ${KUTTL_PG_UPGRADE_FROM_VERSION}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
# Wait for the instances to be ready and the replica backup to complete
3+
# by waiting for the status to signal pods ready and pgbackrest stanza created
4+
apiVersion: postgres-operator.crunchydata.com/v1beta1
5+
kind: PostgresCluster
6+
metadata:
7+
name: major-upgrade-empty-image
8+
spec:
9+
postgresVersion: ${KUTTL_PG_UPGRADE_FROM_VERSION}
10+
status:
11+
instances:
12+
- name: '00'
13+
replicas: 1
14+
readyReplicas: 1
15+
updatedReplicas: 1
16+
pgbackrest:
17+
repos:
18+
- name: repo1
19+
replicaCreateBackupComplete: true
20+
stanzaCreated: true
21+
---
22+
# Even when the cluster exists, the pgupgrade is not progressing because the cluster is not shutdown
23+
apiVersion: postgres-operator.crunchydata.com/v1beta1
24+
kind: PGUpgrade
25+
metadata:
26+
name: empty-image-upgrade
27+
status:
28+
conditions:
29+
- type: "Progressing"
30+
status: "False"
31+
reason: "PGClusterNotShutdown"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
# Shutdown the cluster -- but without the annotation.
3+
apiVersion: postgres-operator.crunchydata.com/v1beta1
4+
kind: PostgresCluster
5+
metadata:
6+
name: major-upgrade-empty-image
7+
spec:
8+
shutdown: true
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
# Since the cluster is missing the annotation, we get this condition
3+
apiVersion: postgres-operator.crunchydata.com/v1beta1
4+
kind: PGUpgrade
5+
metadata:
6+
name: empty-image-upgrade
7+
status:
8+
conditions:
9+
- type: "Progressing"
10+
status: "False"
11+
reason: "PGClusterMissingRequiredAnnotation"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
# Annotate the cluster for an upgrade.
3+
apiVersion: postgres-operator.crunchydata.com/v1beta1
4+
kind: PostgresCluster
5+
metadata:
6+
name: major-upgrade-empty-image
7+
annotations:
8+
postgres-operator.crunchydata.com/allow-upgrade: empty-image-upgrade
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
# Now that the postgres cluster is shut down and annotated, the pgupgrade
3+
# can finish reconciling. We know the reconciliation is complete when
4+
# the pgupgrade status is succeeded and the postgres cluster status
5+
# has the updated version.
6+
apiVersion: postgres-operator.crunchydata.com/v1beta1
7+
kind: PGUpgrade
8+
metadata:
9+
name: empty-image-upgrade
10+
status:
11+
conditions:
12+
- type: "Progressing"
13+
status: "False"
14+
- type: "Succeeded"
15+
status: "True"
16+
---
17+
apiVersion: postgres-operator.crunchydata.com/v1beta1
18+
kind: PostgresCluster
19+
metadata:
20+
name: major-upgrade-empty-image
21+
status:
22+
postgresVersion: ${KUTTL_PG_UPGRADE_TO_VERSION}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
# Once the pgupgrade is finished, update the version and set shutdown to false
3+
# in the postgres cluster
4+
apiVersion: postgres-operator.crunchydata.com/v1beta1
5+
kind: PostgresCluster
6+
metadata:
7+
name: major-upgrade-empty-image
8+
spec:
9+
postgresVersion: ${KUTTL_PG_UPGRADE_TO_VERSION}
10+
shutdown: false
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
# Wait for the instances to be ready with the target Postgres version.
3+
apiVersion: postgres-operator.crunchydata.com/v1beta1
4+
kind: PostgresCluster
5+
metadata:
6+
name: major-upgrade-empty-image
7+
status:
8+
postgresVersion: ${KUTTL_PG_UPGRADE_TO_VERSION}
9+
instances:
10+
- name: '00'
11+
replicas: 1
12+
readyReplicas: 1
13+
updatedReplicas: 1
14+
pgbackrest:
15+
repos:
16+
- name: repo1
17+
replicaCreateBackupComplete: true
18+
stanzaCreated: true
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: kuttl.dev/v1beta1
2+
kind: TestStep
3+
commands:
4+
# Check that the pgbackrest setup has successfully completed
5+
- script: |
6+
kubectl -n "${NAMESPACE}" exec "statefulset.apps/major-upgrade-empty-image-repo-host" -c pgbackrest -- pgbackrest check --stanza=db
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
# Check the version reported by PostgreSQL
3+
apiVersion: batch/v1
4+
kind: Job
5+
metadata:
6+
name: major-upgrade-empty-image-after
7+
labels: { postgres-operator-test: kuttl }
8+
spec:
9+
backoffLimit: 6
10+
template:
11+
metadata:
12+
labels: { postgres-operator-test: kuttl }
13+
spec:
14+
restartPolicy: Never
15+
containers:
16+
- name: psql
17+
image: ${KUTTL_PSQL_IMAGE}
18+
env:
19+
- name: PGURI
20+
valueFrom: { secretKeyRef: { name: major-upgrade-empty-image-pguser-major-upgrade-empty-image, key: uri } }
21+
22+
# Do not wait indefinitely.
23+
- { name: PGCONNECT_TIMEOUT, value: '5' }
24+
25+
# Note: the `$$$$` is reduced to `$$` by Kubernetes.
26+
# - https://kubernetes.io/docs/tasks/inject-data-application/
27+
command:
28+
- psql
29+
- $(PGURI)
30+
- --quiet
31+
- --echo-errors
32+
- --set=ON_ERROR_STOP=1
33+
- --command
34+
- |
35+
DO $$$$
36+
BEGIN
37+
ASSERT current_setting('server_version_num') LIKE '${KUTTL_PG_UPGRADE_TO_VERSION}%',
38+
format('got %L', current_setting('server_version_num'));
39+
END $$$$;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
apiVersion: batch/v1
3+
kind: Job
4+
metadata:
5+
name: major-upgrade-empty-image-after
6+
status:
7+
succeeded: 1
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## Major upgrade missing image tests
2+
3+
This is a variation derived from our major upgrade KUTTL tests designed to
4+
test scenarios where required container images are not defined in either the
5+
PostgresCluster spec or via the RELATED_IMAGES environment variables.
6+
7+
### Basic PGUpgrade controller and CRD instance validation
8+
9+
* 01--valid-upgrade: create a valid PGUpgrade instance
10+
* 01-assert: check that the PGUpgrade instance exists and has the expected status
11+
12+
### Verify new statuses for missing required container images
13+
14+
* 10--cluster: create the cluster with an unavailable image (i.e. Postgres 10)
15+
* 10-assert: check that the PGUpgrade instance has the expected reason: "PGClusterNotShutdown"
16+
* 11-shutdown-cluster: set the spec.shutdown value to 'true' as required for upgrade
17+
* 11-assert: check that the new reason is set, "PGClusterPrimaryNotIdentified"
18+
19+
### Update to an available Postgres version, start and upgrade PostgresCluster
20+
21+
* 12--start-and-update-version: update the Postgres version on both CRD instances and set 'shutdown' to false
22+
* 12-assert: verify that the cluster is running and the PGUpgrade instance now has the new status info with reason: "PGClusterNotShutdown"
23+
* 13--shutdown-cluster: set spec.shutdown to 'true'
24+
* 13-assert: check that the PGUpgrade instance has the expected reason: "PGClusterMissingRequiredAnnotation"
25+
* 14--annotate-cluster: set the required annotation
26+
* 14-assert: verify that the upgrade succeeded and the new Postgres version shows in the cluster's status
27+
* 15--start-cluster: set the new Postgres version and spec.shutdown to 'false'
28+
29+
### Verify upgraded PostgresCluster
30+
31+
* 15-assert: verify that the cluster is running
32+
* 16-check-pgbackrest: check that the pgbackrest setup has successfully completed
33+
* 17--check-version: check the version reported by PostgreSQL
34+
* 17-assert: assert the Job from the previous step succeeded
35+
36+

0 commit comments

Comments
 (0)