-
Notifications
You must be signed in to change notification settings - Fork 68
K8SPG-833 add "custom-envs" e2e test #1315
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
17d6f03
K8SPG-833 add e2e test
nmarukovich b6f6bd0
Merge branch 'main' into K8SPG-833_add_e2e_test
nmarukovich 413370d
Merge branch 'main' into K8SPG-833_add_e2e_test
nmarukovich a785e80
Merge branch 'main' into K8SPG-833_add_e2e_test
nmarukovich 6219010
fix PR comments
nmarukovich feab0ae
Merge branch 'K8SPG-833_add_e2e_test' of github.com:percona/percona-p…
nmarukovich 09c40b5
Merge branch 'main' into K8SPG-833_add_e2e_test
nmarukovich 3e34cdb
Merge branch 'main' into K8SPG-833_add_e2e_test
eleo007 57eb63a
Merge branch 'main' into K8SPG-833_add_e2e_test
nmarukovich 3134d14
Fix PR comments
nmarukovich a82d412
Merge branch 'K8SPG-833_add_e2e_test' of github.com:percona/percona-p…
nmarukovich ffcc65e
Merge branch 'main' into K8SPG-833_add_e2e_test
nmarukovich 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
Some comments aren't visible on the classic Files Changed page.
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
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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| backup-enable-disable | ||
| custom-envs | ||
| custom-extensions | ||
| custom-tls | ||
| database-init-sql | ||
|
|
||
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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| backup-enable-disable | ||
| custom-envs | ||
| custom-extensions | ||
| custom-tls | ||
| database-init-sql | ||
|
|
||
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,14 @@ | ||
| 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 | ||
| deploy_s3_secrets |
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,106 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestAssert | ||
| timeout: 120 | ||
| --- | ||
| kind: StatefulSet | ||
| apiVersion: apps/v1 | ||
| metadata: | ||
| labels: | ||
| postgres-operator.crunchydata.com/cluster: custom-envs | ||
| postgres-operator.crunchydata.com/data: postgres | ||
| postgres-operator.crunchydata.com/instance-set: instance1 | ||
| ownerReferences: | ||
| - apiVersion: postgres-operator.crunchydata.com/v1beta1 | ||
| kind: PostgresCluster | ||
| name: custom-envs | ||
| controller: true | ||
| blockOwnerDeletion: true | ||
| status: | ||
| observedGeneration: 1 | ||
| replicas: 1 | ||
| readyReplicas: 1 | ||
| currentReplicas: 1 | ||
| updatedReplicas: 1 | ||
| collisionCount: 0 | ||
| --- | ||
| kind: Deployment | ||
| apiVersion: apps/v1 | ||
| metadata: | ||
| name: custom-envs-pgbouncer | ||
| labels: | ||
| postgres-operator.crunchydata.com/cluster: custom-envs | ||
| postgres-operator.crunchydata.com/role: pgbouncer | ||
| annotations: | ||
| deployment.kubernetes.io/revision: '1' | ||
| ownerReferences: | ||
| - apiVersion: postgres-operator.crunchydata.com/v1beta1 | ||
| kind: PostgresCluster | ||
| name: custom-envs | ||
| controller: true | ||
| blockOwnerDeletion: true | ||
| status: | ||
| observedGeneration: 1 | ||
| replicas: 1 | ||
| updatedReplicas: 1 | ||
| readyReplicas: 1 | ||
| --- | ||
| kind: Job | ||
| apiVersion: batch/v1 | ||
| metadata: | ||
| labels: | ||
| postgres-operator.crunchydata.com/cluster: custom-envs | ||
| 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: custom-envs | ||
| ownerReferences: | ||
| - apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGCluster | ||
| name: custom-envs | ||
| controller: true | ||
| blockOwnerDeletion: true | ||
| finalizers: | ||
| - postgres-operator.crunchydata.com/finalizer | ||
| status: | ||
| instances: | ||
| - name: instance1 | ||
| readyReplicas: 1 | ||
| replicas: 1 | ||
| updatedReplicas: 1 | ||
| observedGeneration: 1 | ||
| pgbackrest: | ||
| repos: | ||
| - name: repo1 | ||
| stanzaCreated: true | ||
| proxy: | ||
| pgBouncer: | ||
| readyReplicas: 1 | ||
| replicas: 1 | ||
| --- | ||
| apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGCluster | ||
| metadata: | ||
| name: custom-envs | ||
| status: | ||
| pgbouncer: | ||
| ready: 1 | ||
| size: 1 | ||
| postgres: | ||
| instances: | ||
| - name: instance1 | ||
| ready: 1 | ||
| size: 1 | ||
| ready: 1 | ||
| size: 1 | ||
| 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,15 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestStep | ||
| timeout: 20 | ||
| commands: | ||
| - script: |- | ||
| set -o errexit | ||
| set -o xtrace | ||
|
|
||
| source ../../functions | ||
|
|
||
| get_cr \ | ||
| | yq eval ' | ||
| .spec.proxy.pgBouncer.replicas=1 | | ||
| .spec.instances[].replicas=1' - \ | ||
| | 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,21 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestStep | ||
| timeout: 10 | ||
| commands: | ||
| - script: |- | ||
| set -o errexit | ||
| set -o xtrace | ||
|
|
||
| source ../../functions | ||
| get_cr | yq eval ' | ||
| .spec.proxy.pgBouncer.replicas = 1 | | ||
| .spec.instances[].replicas = 1 | | ||
| .spec.instances[].env = ((.spec.instances[].env // []) + [{"name": "MY_ENV", "value": "1000"}] | unique_by(.name)) | ||
| ' - | kubectl -n "${NAMESPACE}" apply -f - | ||
|
|
||
|
|
||
| sleep 10 | ||
| wait_cluster_consistency custom-envs | ||
|
|
||
| check_env_in_pod add instance MY_ENV 1000 | ||
|
|
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,48 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestAssert | ||
| timeout: 120 | ||
| --- | ||
| apiVersion: postgres-operator.crunchydata.com/v1beta1 | ||
| kind: PostgresCluster | ||
| metadata: | ||
| name: custom-envs | ||
| ownerReferences: | ||
| - apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGCluster | ||
| name: custom-envs | ||
| controller: true | ||
| blockOwnerDeletion: true | ||
| finalizers: | ||
| - postgres-operator.crunchydata.com/finalizer | ||
| status: | ||
| instances: | ||
| - name: instance1 | ||
| readyReplicas: 1 | ||
| replicas: 1 | ||
| updatedReplicas: 1 | ||
| observedGeneration: 2 | ||
| pgbackrest: | ||
| repos: | ||
| - name: repo1 | ||
| stanzaCreated: true | ||
| proxy: | ||
| pgBouncer: | ||
| readyReplicas: 1 | ||
| replicas: 1 | ||
| --- | ||
| apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGCluster | ||
| metadata: | ||
| name: custom-envs | ||
| status: | ||
| pgbouncer: | ||
| ready: 1 | ||
| size: 1 | ||
| postgres: | ||
| instances: | ||
| - name: instance1 | ||
| ready: 1 | ||
| size: 1 | ||
| ready: 1 | ||
| size: 1 | ||
| 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,48 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestAssert | ||
| timeout: 120 | ||
| --- | ||
| apiVersion: postgres-operator.crunchydata.com/v1beta1 | ||
| kind: PostgresCluster | ||
| metadata: | ||
| name: custom-envs | ||
| ownerReferences: | ||
| - apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGCluster | ||
| name: custom-envs | ||
| controller: true | ||
| blockOwnerDeletion: true | ||
| finalizers: | ||
| - postgres-operator.crunchydata.com/finalizer | ||
| status: | ||
| instances: | ||
| - name: instance1 | ||
| readyReplicas: 1 | ||
| replicas: 1 | ||
| updatedReplicas: 1 | ||
| observedGeneration: 3 | ||
| pgbackrest: | ||
| repos: | ||
| - name: repo1 | ||
| stanzaCreated: true | ||
| proxy: | ||
| pgBouncer: | ||
| readyReplicas: 1 | ||
| replicas: 1 | ||
| --- | ||
| apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGCluster | ||
| metadata: | ||
| name: custom-envs | ||
| status: | ||
| pgbouncer: | ||
| ready: 1 | ||
| size: 1 | ||
| postgres: | ||
| instances: | ||
| - name: instance1 | ||
| ready: 1 | ||
| size: 1 | ||
| ready: 1 | ||
| size: 1 | ||
| state: ready |
19 changes: 19 additions & 0 deletions
19
e2e-tests/tests/custom-envs/03-update-env-for-instance.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,19 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestStep | ||
| timeout: 10 | ||
| commands: | ||
| - script: |- | ||
| set -o errexit | ||
| set -o xtrace | ||
|
|
||
| source ../../functions | ||
| kubectl -n ${NAMESPACE} get pg custom-envs -o yaml | \ | ||
| yq eval ' | ||
| .spec.instances[].env[] |= | ||
| (select(.name == "MY_ENV").value = "2000")' - | \ | ||
| kubectl apply -f - | ||
|
|
||
| sleep 10 | ||
| wait_cluster_consistency custom-envs | ||
|
|
||
| check_env_in_pod add instance MY_ENV 2000 |
24 changes: 24 additions & 0 deletions
24
e2e-tests/tests/custom-envs/04-add-env-secret-to-instance.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: TestStep | ||
| timeout: 20 | ||
| commands: | ||
| - script: |- | ||
| set -o errexit | ||
| set -o xtrace | ||
|
|
||
| source ../../functions | ||
|
|
||
| # Create a secret | ||
| kubectl create secret generic instance-env-secret \ | ||
| --from-literal=DB_USER_TEST_ENV=myuser \ | ||
| --from-literal=DB_PASSWORD_TEST_ENV='MyS3cretP@ss' \ | ||
| -n "${NAMESPACE}" || true | ||
|
|
||
| kubectl get pg custom-envs -n ${NAMESPACE} -o yaml | \ | ||
| yq eval '.spec.instances[].envFrom += [{"secretRef": {"name": "instance-env-secret"}}]' - | \ | ||
| kubectl apply -f - | ||
|
|
||
| sleep 10 | ||
| wait_cluster_consistency custom-envs | ||
| check_env_in_pod add instance DB_USER_TEST_ENV myuser | ||
|
||
|
|
||
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.
Maybe it is better to fail a test if secret is not created? Without secret - the next step will fail anyway?