Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise major-upgrade tests #3823

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions testing/kuttl/e2e/major-upgrade/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
---
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PGUpgrade
metadata:
name: major-upgrade-do-it
status:
conditions:
- type: "Progressing"
status: "False"
reason: "PGUpgradeInvalid"
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
collectors:
- type: command
command: kubectl -n $NAMESPACE describe pgupgrade major-upgrade-do-it
- namespace: $NAMESPACE
selector: postgres-operator.crunchydata.com/pgupgrade=major-upgrade-do-it
6 changes: 6 additions & 0 deletions testing/kuttl/e2e/major-upgrade/01-invalid-upgrade.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
apply:
- files/01-create-invalid-pgupgrade.yaml
assert:
- files/01-invalid-pgupgrade-created.yaml
17 changes: 7 additions & 10 deletions testing/kuttl/e2e/major-upgrade/02-assert.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
---
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PGUpgrade
metadata:
name: major-upgrade-do-it
status:
conditions:
- type: "Progressing"
status: "False"
reason: "PGClusterNotFound"
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
collectors:
- type: command
command: kubectl -n $NAMESPACE describe pgupgrade major-upgrade-do-it
- namespace: $NAMESPACE
selector: postgres-operator.crunchydata.com/pgupgrade=major-upgrade-do-it
6 changes: 6 additions & 0 deletions testing/kuttl/e2e/major-upgrade/02-valid-upgrade.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
apply:
- files/02-create-valid-upgrade.yaml
assert:
- files/02-valid-upgrade-created.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
apply:
- files/10-create-already-updated-cluster.yaml
assert:
- files/10-already-updated-cluster-created.yaml
22 changes: 11 additions & 11 deletions testing/kuttl/e2e/major-upgrade/10-assert.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
# pgupgrade should exit since the cluster is already at the requested version
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PGUpgrade
metadata:
name: major-upgrade-do-it
status:
conditions:
- type: "Progressing"
status: "False"
reason: "PGUpgradeResolved"
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
collectors:
- type: command
command: kubectl -n $NAMESPACE describe pods --selector postgres-operator.crunchydata.com/cluster=major-upgrade
- type: command
command: kubectl -n $NAMESPACE describe pgupgrade major-upgrade-do-it
- namespace: $NAMESPACE
selector: postgres-operator.crunchydata.com/cluster=major-upgrade
- namespace: $NAMESPACE
selector: postgres-operator.crunchydata.com/pgupgrade=major-upgrade-do-it
42 changes: 11 additions & 31 deletions testing/kuttl/e2e/major-upgrade/30-assert.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,11 @@
---
# Wait for the instances to be ready and the replica backup to complete
# by waiting for the status to signal pods ready and pgbackrest stanza created
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PostgresCluster
metadata:
name: major-upgrade
spec:
postgresVersion: ${KUTTL_PG_UPGRADE_FROM_VERSION}
status:
instances:
- name: '00'
replicas: 3
readyReplicas: 3
updatedReplicas: 3
pgbackrest:
repos:
- name: repo1
replicaCreateBackupComplete: true
stanzaCreated: true
---
# Even when the cluster exists, the pgupgrade is not progressing because the cluster is not shutdown
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PGUpgrade
metadata:
name: major-upgrade-do-it
status:
conditions:
- type: "Progressing"
status: "False"
reason: "PGClusterNotShutdown"
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
collectors:
- type: command
command: kubectl -n $NAMESPACE describe pods --selector postgres-operator.crunchydata.com/cluster=major-upgrade
- type: command
command: kubectl -n $NAMESPACE describe pgupgrade major-upgrade-do-it
- namespace: $NAMESPACE
selector: postgres-operator.crunchydata.com/cluster=major-upgrade
- namespace: $NAMESPACE
selector: postgres-operator.crunchydata.com/pgupgrade=major-upgrade-do-it
6 changes: 6 additions & 0 deletions testing/kuttl/e2e/major-upgrade/30-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
apply:
- files/30-create-cluster.yaml
assert:
- files/30-cluster-created.yaml
6 changes: 6 additions & 0 deletions testing/kuttl/e2e/major-upgrade/31-data.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
apply:
- files/31-create-data.yaml
assert:
- files/31-data-created.yaml
22 changes: 11 additions & 11 deletions testing/kuttl/e2e/major-upgrade/32-assert.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
# Since the cluster is missing the annotation, we get this condition
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PGUpgrade
metadata:
name: major-upgrade-do-it
status:
conditions:
- type: "Progressing"
status: "False"
reason: "PGClusterMissingRequiredAnnotation"
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
collectors:
- type: command
command: kubectl -n $NAMESPACE describe pods --selector postgres-operator.crunchydata.com/cluster=major-upgrade
- type: command
command: kubectl -n $NAMESPACE describe pgupgrade major-upgrade-do-it
- namespace: $NAMESPACE
selector: postgres-operator.crunchydata.com/cluster=major-upgrade
- namespace: $NAMESPACE
selector: postgres-operator.crunchydata.com/pgupgrade=major-upgrade-do-it
6 changes: 6 additions & 0 deletions testing/kuttl/e2e/major-upgrade/32-shutdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
apply:
- files/32-shutdown-cluster.yaml
assert:
- files/32-cluster-shutdown.yaml
6 changes: 6 additions & 0 deletions testing/kuttl/e2e/major-upgrade/33-annotate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
apply:
- files/33-annotate-cluster.yaml
assert:
- files/33-cluster-annotated.yaml
33 changes: 11 additions & 22 deletions testing/kuttl/e2e/major-upgrade/33-assert.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
---
# Now that the postgres cluster is shut down and annotated, the pgupgrade
# can finish reconciling. We know the reconciling is complete when
# the pgupgrade status is succeeded and the postgres cluster status
# has the updated version.
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PGUpgrade
metadata:
name: major-upgrade-do-it
status:
conditions:
- type: "Progressing"
status: "False"
- type: "Succeeded"
status: "True"
---
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PostgresCluster
metadata:
name: major-upgrade
status:
postgresVersion: ${KUTTL_PG_UPGRADE_TO_VERSION}
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
collectors:
- type: command
command: kubectl -n $NAMESPACE describe pods --selector postgres-operator.crunchydata.com/cluster=major-upgrade
- type: command
command: kubectl -n $NAMESPACE describe pgupgrade major-upgrade-do-it
- namespace: $NAMESPACE
selector: postgres-operator.crunchydata.com/cluster=major-upgrade
- namespace: $NAMESPACE
selector: postgres-operator.crunchydata.com/pgupgrade=major-upgrade-do-it
29 changes: 11 additions & 18 deletions testing/kuttl/e2e/major-upgrade/34-assert.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
---
# Wait for the instances to be ready with the target Postgres version.
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PostgresCluster
metadata:
name: major-upgrade
status:
postgresVersion: ${KUTTL_PG_UPGRADE_TO_VERSION}
instances:
- name: '00'
replicas: 3
readyReplicas: 3
updatedReplicas: 3
pgbackrest:
repos:
- name: repo1
replicaCreateBackupComplete: true
stanzaCreated: true
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
collectors:
- type: command
command: kubectl -n $NAMESPACE describe pods --selector postgres-operator.crunchydata.com/cluster=major-upgrade
- type: command
command: kubectl -n $NAMESPACE describe pgupgrade major-upgrade-do-it
- namespace: $NAMESPACE
selector: postgres-operator.crunchydata.com/cluster=major-upgrade
- namespace: $NAMESPACE
selector: postgres-operator.crunchydata.com/pgupgrade=major-upgrade-do-it
6 changes: 6 additions & 0 deletions testing/kuttl/e2e/major-upgrade/34-restart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
apply:
- files/34-restart-cluster.yaml
assert:
- files/34-cluster-restarted.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
kind: TestAssert
commands:
# Check that the pgbackrest setup has successfully completed
- script: |
Expand All @@ -9,3 +9,10 @@ commands:
# Check that the old pg folders do not exist on the replica
REPLICA=$(kubectl get pod -l=postgres-operator.crunchydata.com/role=replica -n "${NAMESPACE}" -o=jsonpath='{ .items[0].metadata.name }')
kubectl -n "${NAMESPACE}" exec "${REPLICA}" -c database -- [ ! -d "pgdata/pg${KUTTL_PG_UPGRADE_FROM_VERSION}" ]
collectors:
- type: command
command: kubectl -n $NAMESPACE describe pods --selector postgres-operator.crunchydata.com/cluster=major-upgrade
- type: command
command: kubectl -n $NAMESPACE describe pgupgrade major-upgrade-do-it
- namespace: $NAMESPACE
selector: postgres-operator.crunchydata.com/cluster=major-upgrade
25 changes: 11 additions & 14 deletions testing/kuttl/e2e/major-upgrade/36-assert.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
---
apiVersion: batch/v1
kind: Job
metadata:
name: major-upgrade-after
status:
succeeded: 1
---
apiVersion: batch/v1
kind: Job
metadata:
name: major-upgrade-after-replica
status:
succeeded: 1
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
collectors:
- type: command
command: kubectl -n $NAMESPACE describe pods --selector postgres-operator.crunchydata.com/cluster=major-upgrade
- type: command
command: kubectl -n $NAMESPACE describe pgupgrade major-upgrade-do-it
- namespace: $NAMESPACE
selector: postgres-operator.crunchydata.com/cluster=major-upgrade
- namespace: $NAMESPACE
selector: postgres-operator.crunchydata.com/pgupgrade=major-upgrade-do-it
6 changes: 6 additions & 0 deletions testing/kuttl/e2e/major-upgrade/36-restart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
apply:
- files/36-check-data-and-version.yaml
assert:
- files/36-data-and-version-checked.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PGUpgrade
metadata:
name: major-upgrade-do-it
status:
conditions:
- type: "Progressing"
status: "False"
reason: "PGUpgradeInvalid"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PGUpgrade
metadata:
name: major-upgrade-do-it
status:
conditions:
- type: "Progressing"
status: "False"
reason: "PGClusterNotFound"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# pgupgrade should exit since the cluster is already at the requested version
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PGUpgrade
metadata:
name: major-upgrade-do-it
status:
conditions:
- type: "Progressing"
status: "False"
reason: "PGUpgradeResolved"
31 changes: 31 additions & 0 deletions testing/kuttl/e2e/major-upgrade/files/30-cluster-created.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
# Wait for the instances to be ready and the replica backup to complete
# by waiting for the status to signal pods ready and pgbackrest stanza created
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PostgresCluster
metadata:
name: major-upgrade
spec:
postgresVersion: ${KUTTL_PG_UPGRADE_FROM_VERSION}
status:
instances:
- name: '00'
replicas: 3
readyReplicas: 3
updatedReplicas: 3
pgbackrest:
repos:
- name: repo1
replicaCreateBackupComplete: true
stanzaCreated: true
---
# Even when the cluster exists, the pgupgrade is not progressing because the cluster is not shutdown
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PGUpgrade
metadata:
name: major-upgrade-do-it
status:
conditions:
- type: "Progressing"
status: "False"
reason: "PGClusterNotShutdown"
11 changes: 11 additions & 0 deletions testing/kuttl/e2e/major-upgrade/files/32-cluster-shutdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# Since the cluster is missing the annotation, we get this condition
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PGUpgrade
metadata:
name: major-upgrade-do-it
status:
conditions:
- type: "Progressing"
status: "False"
reason: "PGClusterMissingRequiredAnnotation"
Loading