-
Notifications
You must be signed in to change notification settings - Fork 73
K8SPG-1000 Add extensions major upgrade tests #1547
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
Open
jvpasinatto
wants to merge
4
commits into
main
Choose a base branch
from
test-upgrade-290
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
287b75b
K8SPG-1000 Add extensions major upgrade tests
jvpasinatto 992ca34
Merge branch 'main' into test-upgrade-290
jvpasinatto 7488d1a
consider in docker.io prefix in get_container_image function
jvpasinatto 7d7e00f
Merge branch 'main' into test-upgrade-290
jvpasinatto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1153,11 +1153,12 @@ get_container_image() { | |||||||||
| local component=$1 | ||||||||||
| local pgVersion=$2 | ||||||||||
|
|
||||||||||
| if [[ ${IMAGE} == percona/* ]] || [[ -n ${FORCE_RELEASE_RUN} ]]; then | ||||||||||
| if [[ ${IMAGE} == percona/* || ${IMAGE} == docker.io/percona/* ]] || [[ -n ${FORCE_RELEASE_RUN} ]]; then | ||||||||||
| local key | ||||||||||
| case $component in | ||||||||||
| pgbouncer) key="IMAGE_PGBOUNCER${pgVersion}" ;; | ||||||||||
| pgbackrest) key="IMAGE_BACKREST${pgVersion}" ;; | ||||||||||
| postgis) key="IMAGE_POSTGIS${pgVersion}" ;; | ||||||||||
| *) key="IMAGE_POSTGRESQL${pgVersion}" ;; | ||||||||||
|
Comment on lines
+1161
to
1162
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [shfmt] reported by reviewdog 🐶
Suggested change
|
||||||||||
| esac | ||||||||||
| get_release_image "$key" | ||||||||||
|
|
||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
e2e-tests/tests/major-upgrade-14-to-15-postgis/00-assert.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestAssert | ||
| timeout: 120 | ||
| --- | ||
| apiVersion: apiextensions.k8s.io/v1 | ||
| kind: CustomResourceDefinition | ||
| metadata: | ||
| name: perconapgclusters.pgv2.percona.com | ||
| spec: | ||
| group: pgv2.percona.com | ||
| names: | ||
| kind: PerconaPGCluster | ||
| listKind: PerconaPGClusterList | ||
| plural: perconapgclusters | ||
| singular: perconapgcluster | ||
| scope: Namespaced | ||
| --- | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestAssert | ||
| metadata: | ||
| name: check-operator-deploy-status | ||
| timeout: 120 | ||
| commands: | ||
| - script: kubectl assert exist-enhanced deployment percona-postgresql-operator -n ${OPERATOR_NS:-$NAMESPACE} --field-selector status.readyReplicas=1 |
13 changes: 13 additions & 0 deletions
13
e2e-tests/tests/major-upgrade-14-to-15-postgis/00-deploy-operator.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestStep | ||
| commands: | ||
| - script: |- | ||
| set -o errexit | ||
| set -o xtrace | ||
|
|
||
| source ../../functions | ||
| init_temp_dir # do this only in the first TestStep | ||
|
|
||
| deploy_operator | ||
| deploy_client | ||
| deploy_s3_secrets |
135 changes: 135 additions & 0 deletions
135
e2e-tests/tests/major-upgrade-14-to-15-postgis/01-assert.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestAssert | ||
| timeout: 120 | ||
| --- | ||
| kind: StatefulSet | ||
| apiVersion: apps/v1 | ||
| metadata: | ||
| name: major-upgrade-14-to-15-postgis-repo-host | ||
| labels: | ||
| postgres-operator.crunchydata.com/cluster: major-upgrade-14-to-15-postgis | ||
| postgres-operator.crunchydata.com/data: pgbackrest | ||
| postgres-operator.crunchydata.com/pgbackrest: '' | ||
| postgres-operator.crunchydata.com/pgbackrest-dedicated: '' | ||
| ownerReferences: | ||
| - apiVersion: postgres-operator.crunchydata.com/v1beta1 | ||
| kind: PostgresCluster | ||
| name: major-upgrade-14-to-15-postgis | ||
| controller: true | ||
| blockOwnerDeletion: true | ||
| status: | ||
| observedGeneration: 1 | ||
| replicas: 1 | ||
| readyReplicas: 1 | ||
| currentReplicas: 1 | ||
| updatedReplicas: 1 | ||
| collisionCount: 0 | ||
| --- | ||
| kind: StatefulSet | ||
| apiVersion: apps/v1 | ||
| metadata: | ||
| labels: | ||
| postgres-operator.crunchydata.com/cluster: major-upgrade-14-to-15-postgis | ||
| postgres-operator.crunchydata.com/data: postgres | ||
| postgres-operator.crunchydata.com/instance-set: instance1 | ||
| ownerReferences: | ||
| - apiVersion: postgres-operator.crunchydata.com/v1beta1 | ||
| kind: PostgresCluster | ||
| name: major-upgrade-14-to-15-postgis | ||
| controller: true | ||
| blockOwnerDeletion: true | ||
| status: | ||
| observedGeneration: 1 | ||
| replicas: 1 | ||
| readyReplicas: 1 | ||
| currentReplicas: 1 | ||
| updatedReplicas: 1 | ||
| collisionCount: 0 | ||
| --- | ||
| kind: Deployment | ||
| apiVersion: apps/v1 | ||
| metadata: | ||
| name: major-upgrade-14-to-15-postgis-pgbouncer | ||
| labels: | ||
| postgres-operator.crunchydata.com/cluster: major-upgrade-14-to-15-postgis | ||
| postgres-operator.crunchydata.com/role: pgbouncer | ||
| annotations: | ||
| deployment.kubernetes.io/revision: '1' | ||
| ownerReferences: | ||
| - apiVersion: postgres-operator.crunchydata.com/v1beta1 | ||
| kind: PostgresCluster | ||
| name: major-upgrade-14-to-15-postgis | ||
| controller: true | ||
| blockOwnerDeletion: true | ||
| status: | ||
| observedGeneration: 1 | ||
| replicas: 3 | ||
| updatedReplicas: 3 | ||
| readyReplicas: 3 | ||
| --- | ||
| kind: Job | ||
| apiVersion: batch/v1 | ||
| metadata: | ||
| labels: | ||
| postgres-operator.crunchydata.com/cluster: major-upgrade-14-to-15-postgis | ||
| postgres-operator.crunchydata.com/pgbackrest: '' | ||
| postgres-operator.crunchydata.com/pgbackrest-backup: replica-create | ||
| postgres-operator.crunchydata.com/pgbackrest-repo: repo1 | ||
| ownerReferences: | ||
| - apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGBackup | ||
| controller: true | ||
| blockOwnerDeletion: true | ||
| status: | ||
| succeeded: 1 | ||
| --- | ||
| apiVersion: postgres-operator.crunchydata.com/v1beta1 | ||
| kind: PostgresCluster | ||
| metadata: | ||
| name: major-upgrade-14-to-15-postgis | ||
| ownerReferences: | ||
| - apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGCluster | ||
| name: major-upgrade-14-to-15-postgis | ||
| controller: true | ||
| blockOwnerDeletion: true | ||
| finalizers: | ||
| - postgres-operator.crunchydata.com/finalizer | ||
| status: | ||
| instances: | ||
| - name: instance1 | ||
| readyReplicas: 3 | ||
| replicas: 3 | ||
| updatedReplicas: 3 | ||
| observedGeneration: 1 | ||
| pgbackrest: | ||
| repoHost: | ||
| apiVersion: apps/v1 | ||
| kind: StatefulSet | ||
| ready: true | ||
| repos: | ||
| - bound: true | ||
| name: repo1 | ||
| replicaCreateBackupComplete: true | ||
| stanzaCreated: true | ||
| proxy: | ||
| pgBouncer: | ||
| readyReplicas: 3 | ||
| replicas: 3 | ||
| --- | ||
| apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGCluster | ||
| metadata: | ||
| name: major-upgrade-14-to-15-postgis | ||
| status: | ||
| pgbouncer: | ||
| ready: 3 | ||
| size: 3 | ||
| postgres: | ||
| instances: | ||
| - name: instance1 | ||
| ready: 3 | ||
| size: 3 | ||
| ready: 3 | ||
| size: 3 | ||
| state: ready |
30 changes: 30 additions & 0 deletions
30
e2e-tests/tests/major-upgrade-14-to-15-postgis/01-create-cluster.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestStep | ||
| timeout: 10 | ||
| commands: | ||
| - script: |- | ||
| set -o errexit | ||
| set -o xtrace | ||
| source ../../functions | ||
| postgres_image=$(get_container_image "postgis" 14) | ||
| pgbouncer_image=$(get_container_image "pgbouncer" 14) | ||
| pgbackrest_image=$(get_container_image "pgbackrest" 14) | ||
| get_cr \ | ||
| | yq eval " | ||
| .spec.postgresVersion = 14 | | ||
| .spec.image = \"${postgres_image}\" | | ||
| .spec.instances[0].dataVolumeClaimSpec.resources.requests.storage = \"3Gi\" | | ||
| .spec.proxy.pgBouncer.image = \"${pgbouncer_image}\" | | ||
| .spec.backups.pgbackrest.image = \"${pgbackrest_image}\" | | ||
| .spec.patroni.removeDataDirectoryOnDivergedTimelines = true | | ||
| .spec.patroni.dynamicConfiguration.postgresql.parameters.shared_preload_libraries = \"pg_cron\" | | ||
| .spec.extensions.builtin.pg_stat_monitor = true | | ||
| .spec.extensions.builtin.pg_stat_statements = false | | ||
| .spec.extensions.builtin.pg_audit = true | | ||
| .spec.extensions.builtin.pgvector = true | | ||
| .spec.extensions.builtin.pg_repack = true | | ||
| .spec.extensions.custom += [{\"name\": \"pg_cron\", \"version\": \"1.6.6\"}]" \ | ||
| | kubectl -n "${NAMESPACE}" apply -f - |
32 changes: 32 additions & 0 deletions
32
e2e-tests/tests/major-upgrade-14-to-15-postgis/02-write-data.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestStep | ||
| commands: | ||
| - script: |- | ||
| set -o errexit | ||
| set -o xtrace | ||
|
|
||
| source ../../functions | ||
|
|
||
| run_psql_local \ | ||
| 'CREATE DATABASE myapp; \c myapp \\\ CREATE TABLE IF NOT EXISTS myApp (id int PRIMARY KEY);' \ | ||
| "postgres:$(get_psql_user_pass major-upgrade-14-to-15-postgis-pguser-postgres)@$(get_psql_user_host major-upgrade-14-to-15-postgis-pguser-postgres)" | ||
|
|
||
| run_psql_local \ | ||
| '\c myapp \\\ INSERT INTO myApp (id) VALUES (100500)' \ | ||
| "postgres:$(get_psql_user_pass major-upgrade-14-to-15-postgis-pguser-postgres)@$(get_psql_user_host major-upgrade-14-to-15-postgis-pguser-postgres)" | ||
|
|
||
| primary=$(get_pod_by_role major-upgrade-14-to-15-postgis primary name) | ||
| kubectl -n ${NAMESPACE} exec ${primary} -- \ | ||
| psql -v ON_ERROR_STOP=1 -d postgres -c 'CREATE DATABASE mygisdata' | ||
| kubectl -n ${NAMESPACE} exec ${primary} -- \ | ||
| psql -v ON_ERROR_STOP=1 -d mygisdata -c 'CREATE SCHEMA gis' | ||
| kubectl -n ${NAMESPACE} exec ${primary} -- \ | ||
| psql -v ON_ERROR_STOP=1 -d mygisdata -c 'CREATE EXTENSION postgis' | ||
| kubectl -n ${NAMESPACE} exec ${primary} -- \ | ||
| psql -v ON_ERROR_STOP=1 -d mygisdata -c 'CREATE TABLE gis.locations (id int PRIMARY KEY, geom geometry(Point, 4326))' | ||
| kubectl -n ${NAMESPACE} exec ${primary} -- \ | ||
| psql -v ON_ERROR_STOP=1 -d mygisdata -c 'INSERT INTO gis.locations (id, geom) VALUES (1, ST_GeomFromText($$POINT(30 10)$$, 4326))' | ||
|
|
||
| run_psql_local \ | ||
| '\c postgres \\\ CREATE EXTENSION pg_cron' \ | ||
| "postgres:$(get_psql_user_pass major-upgrade-14-to-15-postgis-pguser-postgres)@$(get_psql_user_host major-upgrade-14-to-15-postgis-pguser-postgres)" |
11 changes: 11 additions & 0 deletions
11
e2e-tests/tests/major-upgrade-14-to-15-postgis/03-assert.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestAssert | ||
| timeout: 30 | ||
| --- | ||
| kind: ConfigMap | ||
| apiVersion: v1 | ||
| metadata: | ||
| name: 03-read-from-primary | ||
| data: | ||
| data: ' 100500' | ||
| postgis: ' POINT(30 10)' |
12 changes: 12 additions & 0 deletions
12
e2e-tests/tests/major-upgrade-14-to-15-postgis/03-read-from-primary.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestStep | ||
| commands: | ||
| - script: |- | ||
| set -o errexit | ||
| set -o xtrace | ||
|
|
||
| source ../../functions | ||
| data=$(run_psql_local '\c myapp \\\ SELECT * from myApp;' "postgres:$(get_psql_user_pass major-upgrade-14-to-15-postgis-pguser-postgres)@$(get_psql_user_host major-upgrade-14-to-15-postgis-pguser-postgres)") | ||
| postgis=$(run_psql_local '\c mygisdata \\\ SELECT ST_AsText(geom) FROM gis.locations ORDER BY id;' "postgres:$(get_psql_user_pass major-upgrade-14-to-15-postgis-pguser-postgres)@$(get_psql_user_host major-upgrade-14-to-15-postgis-pguser-postgres)") | ||
|
|
||
| kubectl create configmap -n "${NAMESPACE}" 03-read-from-primary --from-literal=data="${data}" --from-literal=postgis="${postgis}" |
61 changes: 61 additions & 0 deletions
61
e2e-tests/tests/major-upgrade-14-to-15-postgis/04-assert.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestAssert | ||
| timeout: 360 | ||
| commands: | ||
| - script: |- | ||
| kubectl -n ${NAMESPACE} get cm \ | ||
| -l app.kubernetes.io/instance=major-upgrade-14-to-15-postgis \ | ||
| -l app.kubernetes.io/component=pg -o yaml | ||
| kubectl -n ${NAMESPACE} get pg,pod,job | ||
| sleep 5 | ||
| --- | ||
| apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGCluster | ||
| metadata: | ||
| name: major-upgrade-14-to-15-postgis | ||
| spec: | ||
| postgresVersion: 15 | ||
| status: | ||
| pgbouncer: | ||
| ready: 3 | ||
| size: 3 | ||
| postgres: | ||
| instances: | ||
| - name: instance1 | ||
| ready: 3 | ||
| size: 3 | ||
| ready: 3 | ||
| size: 3 | ||
| state: ready | ||
| --- | ||
| apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGUpgrade | ||
| metadata: | ||
| name: 14-to-15-postgis | ||
| status: | ||
| conditions: | ||
| - type: Progressing | ||
| reason: PGUpgradeCompleted | ||
| status: "False" | ||
| observedGeneration: 1 | ||
| - type: Succeeded | ||
| reason: PGUpgradeSucceeded | ||
| status: "True" | ||
| observedGeneration: 1 | ||
| observedGeneration: 1 | ||
| --- | ||
| kind: Job | ||
| apiVersion: batch/v1 | ||
| metadata: | ||
| labels: | ||
| postgres-operator.crunchydata.com/cluster: major-upgrade-14-to-15-postgis | ||
| postgres-operator.crunchydata.com/pgbackrest: '' | ||
| postgres-operator.crunchydata.com/pgbackrest-backup: replica-create | ||
| postgres-operator.crunchydata.com/pgbackrest-repo: repo1 | ||
| ownerReferences: | ||
| - apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGBackup | ||
| controller: true | ||
| blockOwnerDeletion: true | ||
| status: | ||
| succeeded: 1 |
23 changes: 23 additions & 0 deletions
23
e2e-tests/tests/major-upgrade-14-to-15-postgis/04-upgrade.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestStep | ||
| commands: | ||
| - script: |- | ||
| set -o errexit | ||
| set -o xtrace | ||
|
|
||
| source ../../functions | ||
|
|
||
| kubectl apply -n ${NAMESPACE} -f - <<-EOF | ||
| apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGUpgrade | ||
| metadata: | ||
| name: 14-to-15-postgis | ||
| spec: | ||
| postgresClusterName: major-upgrade-14-to-15-postgis | ||
| image: ${IMAGE_UPGRADE} | ||
| fromPostgresVersion: 14 | ||
| toPostgresVersion: 15 | ||
| toPostgresImage: $(get_container_image "postgis" 15) | ||
| toPgBouncerImage: $(get_container_image "pgbouncer" 15) | ||
| toPgBackRestImage: $(get_container_image "pgbackrest" 15) | ||
| EOF |
13 changes: 13 additions & 0 deletions
13
e2e-tests/tests/major-upgrade-14-to-15-postgis/05-post-upgrade.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestStep | ||
| commands: | ||
| - script: |- | ||
| set -o errexit | ||
| set -o xtrace | ||
|
|
||
| source ../../functions | ||
|
|
||
| primary=$(get_pod_by_role major-upgrade-14-to-15-postgis primary name) | ||
| kubectl -n ${NAMESPACE} exec ${primary} -- vacuumdb --all --analyze-in-stages | ||
| kubectl -n ${NAMESPACE} exec ${primary} -- vacuumdb --all --analyze-only | ||
| kubectl -n ${NAMESPACE} exec ${primary} -- /pgdata/delete_old_cluster.sh |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[shfmt] reported by reviewdog 🐶