-
Notifications
You must be signed in to change notification settings - Fork 80
K8SPG-908 postgis e2e test #1503
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
gkech
wants to merge
4
commits into
main
Choose a base branch
from
K8SPG-908-e2e-test
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
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 |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ pgbouncer-mtls | |
| pg-tde | ||
| pg-tde-wal-encrypt | ||
| pitr | ||
| postgis | ||
| scaling | ||
| scheduled-backup | ||
| self-healing | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ pgbouncer-mtls | |
| pg-tde | ||
| pg-tde-wal-encrypt | ||
| pitr | ||
| postgis | ||
| scaling | ||
| scheduled-backup | ||
| self-healing | ||
|
|
||
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 |
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 | ||
| timeout: 10 | ||
| commands: | ||
| - script: |- | ||
| set -o errexit | ||
| set -o xtrace | ||
|
|
||
| source ../../functions | ||
| init_temp_dir # do this only in the first TestStep | ||
|
|
||
| deploy_operator | ||
| deploy_client |
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,115 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestAssert | ||
| timeout: 180 | ||
| --- | ||
| kind: StatefulSet | ||
| apiVersion: apps/v1 | ||
| metadata: | ||
| name: postgis-repo-host | ||
| labels: | ||
| postgres-operator.crunchydata.com/cluster: postgis | ||
| postgres-operator.crunchydata.com/data: pgbackrest | ||
| postgres-operator.crunchydata.com/pgbackrest: '' | ||
| postgres-operator.crunchydata.com/pgbackrest-dedicated: '' | ||
| ownerReferences: | ||
| - apiVersion: upstream.pgv2.percona.com/v1beta1 | ||
| kind: PostgresCluster | ||
| name: 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: postgis | ||
| postgres-operator.crunchydata.com/data: postgres | ||
| postgres-operator.crunchydata.com/instance-set: instance1 | ||
| ownerReferences: | ||
| - apiVersion: upstream.pgv2.percona.com/v1beta1 | ||
| kind: PostgresCluster | ||
| name: 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: postgis-pgbouncer | ||
| labels: | ||
| postgres-operator.crunchydata.com/cluster: postgis | ||
| postgres-operator.crunchydata.com/role: pgbouncer | ||
| ownerReferences: | ||
| - apiVersion: upstream.pgv2.percona.com/v1beta1 | ||
| kind: PostgresCluster | ||
| name: postgis | ||
| controller: true | ||
| blockOwnerDeletion: true | ||
| status: | ||
| observedGeneration: 1 | ||
| replicas: 3 | ||
| updatedReplicas: 3 | ||
| readyReplicas: 3 | ||
| --- | ||
| apiVersion: upstream.pgv2.percona.com/v1beta1 | ||
| kind: PostgresCluster | ||
| metadata: | ||
| name: postgis | ||
| ownerReferences: | ||
| - apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGCluster | ||
| name: 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 | ||
| proxy: | ||
| pgBouncer: | ||
| readyReplicas: 3 | ||
| replicas: 3 | ||
| --- | ||
| apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGCluster | ||
| metadata: | ||
| name: postgis | ||
| status: | ||
| pgbouncer: | ||
| ready: 3 | ||
| size: 3 | ||
| postgres: | ||
| instances: | ||
| - name: instance1 | ||
| ready: 3 | ||
| size: 3 | ||
| ready: 3 | ||
| size: 3 | ||
| state: ready |
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 | ||
| timeout: 100 | ||
| commands: | ||
| - script: |- | ||
| set -o errexit | ||
| set -o xtrace | ||
|
|
||
| source ../../functions | ||
|
|
||
| postgres_image=$(get_container_image "postgis" "${PG_VER}") | ||
| get_cr | yq eval ".spec.image = \"${postgres_image}\"" - | kubectl -n "${NAMESPACE}" apply -f - |
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,28 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestAssert | ||
| timeout: 120 | ||
| --- | ||
| apiVersion: upstream.pgv2.percona.com/v1beta1 | ||
| kind: PostgresCluster | ||
| metadata: | ||
| name: postgis | ||
| status: | ||
| instances: | ||
| - name: instance1 | ||
| readyReplicas: 3 | ||
| replicas: 3 | ||
| updatedReplicas: 3 | ||
| pgbackrest: | ||
| repoHost: | ||
| ready: true | ||
| proxy: | ||
| pgBouncer: | ||
| readyReplicas: 3 | ||
| replicas: 3 | ||
| --- | ||
| apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGCluster | ||
| metadata: | ||
| name: postgis | ||
| status: | ||
| state: ready |
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 | ||
| timeout: 360 | ||
| commands: | ||
| - script: |- | ||
| set -o errexit | ||
| set -o xtrace | ||
|
|
||
| source ../../functions | ||
|
|
||
| PSQL_URI="postgres:$(get_psql_user_pass postgis-pguser-postgres)@$(get_psql_user_host postgis-pguser-postgres)/postgres" | ||
|
|
||
| # Create a second DB before enable so auto-install covers both databases. | ||
| run_psql_local "CREATE DATABASE mygisdata;" "${PSQL_URI}" | ||
|
|
||
| # Patch the underlying PostgresCluster to enable PostGIS. | ||
| # The Percona operator does not override postGISVersion on reconcile, | ||
| # so this setting is preserved and triggers PostGIS extension installation. | ||
| kubectl -n "${NAMESPACE}" patch postgrescluster postgis \ | ||
| --type=merge \ | ||
| --patch "{\"spec\":{\"postGISVersion\":\"${POSTGIS_VER}\"}}" | ||
|
|
||
| wait_cluster_consistency postgis | ||
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,16 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestAssert | ||
| timeout: 30 | ||
| --- | ||
| kind: ConfigMap | ||
| apiVersion: v1 | ||
| metadata: | ||
| name: 03-check-postgis | ||
| data: | ||
| extensions_postgres: fuzzystrmatch,postgis,postgis_tiger_geocoder,postgis_topology | ||
| extensions_mygisdata: fuzzystrmatch,postgis,postgis_tiger_geocoder,postgis_topology | ||
| schemas: tiger,topology | ||
| geometry: geometry | ||
| geojson: '{"type":"Point","coordinates":[-118.4079,33.9434]}' | ||
| version_matches: "true" | ||
| image_is_gis: "true" |
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,73 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestStep | ||
| timeout: 180 | ||
|
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. timeout in wrong place |
||
| commands: | ||
| - script: |- | ||
| set -o errexit | ||
| set -o xtrace | ||
|
|
||
| source ../../functions | ||
|
|
||
| BASE_URI="postgres:$(get_psql_user_pass postgis-pguser-postgres)@$(get_psql_user_host postgis-pguser-postgres)" | ||
|
|
||
| select_matching() { | ||
| local db=$1 | ||
| local sql=$2 | ||
| local pattern=$3 | ||
|
|
||
| run_psql_local "${sql}" "${BASE_URI}/${db}" \ | ||
| | tr -d '[:blank:]' | grep -E "${pattern}" | sort | paste -sd, - | ||
| } | ||
|
|
||
| get_extensions() { | ||
| select_matching "$1" \ | ||
| "SELECT extname FROM pg_extension ORDER BY extname;" \ | ||
| '^(fuzzystrmatch|postgis|postgis_tiger_geocoder|postgis_topology)$' | ||
| } | ||
|
|
||
| check_extensions() { | ||
| [[ "$(get_extensions "$1")" == "fuzzystrmatch,postgis,postgis_tiger_geocoder,postgis_topology" ]] | ||
| } | ||
|
|
||
| retry 24 5 check_extensions postgres | ||
| retry 24 5 check_extensions mygisdata | ||
|
|
||
| extensions_postgres=$(get_extensions postgres) | ||
| extensions_mygisdata=$(get_extensions mygisdata) | ||
|
|
||
| schemas=$(select_matching postgres \ | ||
| "SELECT nspname FROM pg_catalog.pg_namespace ORDER BY nspname;" \ | ||
| '^(tiger|topology)$') | ||
|
|
||
| geometry=$(run_psql_local \ | ||
| "SELECT pg_typeof(ST_MakePoint(28.385200,-81.563900));" \ | ||
| "${BASE_URI}/postgres" | tr -d '[:space:]') | ||
|
|
||
| geojson=$(run_psql_local \ | ||
| "SELECT ST_AsGeoJSON(ST_SetSRID(ST_MakePoint(-118.4079,33.9434),4326)::geography);" \ | ||
| "${BASE_URI}/postgres" | tr -d '[:space:]') | ||
|
|
||
| version=$(run_psql_local \ | ||
| "SELECT left(postgis_version(),1);" \ | ||
| "${BASE_URI}/postgres" | tr -d '[:space:]') | ||
| spec_version=$(kubectl -n "${NAMESPACE}" get postgrescluster postgis -o jsonpath='{.spec.postGISVersion}') | ||
| version_matches=false | ||
| if [[ "${spec_version}" == "${POSTGIS_VER}" && "${version}" == "${POSTGIS_VER:0:1}" ]]; then | ||
| version_matches=true | ||
| fi | ||
|
|
||
| primary=$(get_pod_by_role postgis primary name) | ||
| image=$(kubectl -n "${NAMESPACE}" get pod "${primary}" -o jsonpath='{.spec.containers[?(@.name=="database")].image}') | ||
| image_is_gis=false | ||
| if [[ "${image}" == *postgres-gis* ]]; then | ||
| image_is_gis=true | ||
| fi | ||
|
|
||
| kubectl create configmap -n "${NAMESPACE}" 03-check-postgis \ | ||
| --from-literal=extensions_postgres="${extensions_postgres}" \ | ||
| --from-literal=extensions_mygisdata="${extensions_mygisdata}" \ | ||
| --from-literal=schemas="${schemas}" \ | ||
| --from-literal=geometry="${geometry}" \ | ||
| --from-literal=geojson="${geojson}" \ | ||
| --from-literal=version_matches="${version_matches}" \ | ||
| --from-literal=image_is_gis="${image_is_gis}" | ||
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,22 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestStep | ||
| delete: | ||
| - apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGCluster | ||
| metadata: | ||
| name: postgis | ||
| - apiVersion: upstream.pgv2.percona.com/v1beta1 | ||
| kind: PostgresCluster | ||
| metadata: | ||
| name: postgis | ||
| commands: | ||
| - script: |- | ||
| set -o errexit | ||
| set -o xtrace | ||
|
|
||
| source ../../functions | ||
|
|
||
| remove_all_finalizers | ||
| check_operator_panic | ||
| destroy_operator | ||
| timeout: 60 |
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
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.
is this something we need to fix?