fix(tests): fix flaky tests from updates (#816)

**Description**
<!--
Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context. List any dependencies that
are required for this change.
-->
⚒️ Fixes  # <!--(issue)-->

**⚙️ Type of change**

- [ ] ⚙️ Feature/App addition
- [ ] 🪛 Bugfix
- [ ] ⚠️ Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] 🔃 Refactor of current code

**🧪 How Has This Been Tested?**
<!--
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration
-->

**📃 Notes:**
<!-- Please enter any other relevant information here -->

**✔️ Checklist:**

- [ ] ⚖️ My code follows the style guidelines of this project
- [ ] 👀 I have performed a self-review of my own code
- [ ] #️⃣ I have commented my code, particularly in hard-to-understand
areas
- [ ] 📄 I have made corresponding changes to the documentation
- [ ] ⚠️ My changes generate no new warnings
- [ ] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [ ] ⬆️ I increased versions for any altered app according to semantic
versioning
- [ ] I made sure the title starts with `feat(chart-name):`,
`fix(chart-name):` or `chore(chart-name):`

** App addition**

If this PR is an app addition please make sure you have done the
following.

- [ ] 🖼️ I have added an icon in the Chart's root directory called
`icon.png`

---

_Please don't blindly check all the boxes. Read them and only check
those that apply.
Those checkboxes are there for the reviewer to see what is this all
about and
the status of this PR with a quick glance._
This commit is contained in:
Stavros Kois
2024-05-19 16:39:42 +03:00
committed by GitHub
parent d1e75b0d5b
commit 6799df67c4
8 changed files with 172 additions and 7 deletions

View File

@@ -7,6 +7,10 @@ release:
tests:
- it: should generate correct spec with recovery/backup
set:
postgres16Image:
repository: ghcr.io/cloudnative-pg/postgresql
tag: "16.3"
pullPolicy: IfNotPresent
cnpg:
my-pg:
enabled: true
@@ -33,7 +37,7 @@ tests:
path: spec
value:
enableSuperuserAccess: true
imageName: ghcr.io/cloudnative-pg/postgresql:16.2
imageName: ghcr.io/cloudnative-pg/postgresql:16.3
primaryUpdateStrategy: unsupervised
primaryUpdateMethod: switchover
logLevel: info

View File

@@ -7,6 +7,10 @@ release:
tests:
- it: should generate correct spec
set:
postgres16Image:
repository: ghcr.io/cloudnative-pg/postgresql
tag: "16.3"
pullPolicy: IfNotPresent
cnpg:
my-pg:
enabled: true
@@ -29,7 +33,7 @@ tests:
path: spec
value:
enableSuperuserAccess: true
imageName: ghcr.io/cloudnative-pg/postgresql:16.2
imageName: ghcr.io/cloudnative-pg/postgresql:16.3
primaryUpdateStrategy: unsupervised
primaryUpdateMethod: switchover
logLevel: info

View File

@@ -0,0 +1,146 @@
suite: credentials list test
templates:
- common.yaml
release:
name: test-release-name
namespace: test-release-namespace
tests:
- it: should generate correct spec with backups (s3) (credentialsList)
set:
credentialsList:
- name: test
type: s3
accessKey: some-access-key
secretKey: some-secret-key
bucket: some-bucket
encrKey: some-encr-key
url: some-url
cnpg:
my-pg:
enabled: true
user: test-user
database: test-db
password: test-password
backups:
enabled: true
target: primary
retentionPolicy: 10d
credentials: test
destinationPath: some-path
asserts:
- documentIndex: &secretDoc 1
isKind:
of: Secret
- documentIndex: *secretDoc
isAPIVersion:
of: v1
- documentIndex: *secretDoc
equal:
path: metadata.name
value: test-release-name-common-test-cnpg-my-pg-provider-backup-s3-creds
- documentIndex: *secretDoc
equal:
path: stringData
value:
ACCESS_KEY_ID: some-access-key
ACCESS_SECRET_KEY: some-secret-key
- documentIndex: &clusterDoc 0
isKind:
of: Cluster
- documentIndex: *clusterDoc
isAPIVersion:
of: postgresql.cnpg.io/v1
- documentIndex: *clusterDoc
equal:
path: metadata.name
value: test-release-name-common-test-cnpg-my-pg
- documentIndex: *clusterDoc
isSubset:
path: spec
content:
backup:
retentionPolicy: 10d
target: primary
barmanObjectStore:
data:
compression: gzip
encryption: AES256
jobs: 2
destinationPath: some-path
endpointURL: some-url
s3Credentials:
accessKeyId:
key: ACCESS_KEY_ID
name: test-release-name-common-test-cnpg-my-pg-provider-backup-s3-creds
secretAccessKey:
key: ACCESS_SECRET_KEY
name: test-release-name-common-test-cnpg-my-pg-provider-backup-s3-creds
serverName: test-release-name-common-test-cnpg-my-pg
wal:
compression: gzip
encryption: AES256
- it: should generate correct spec with volsync (s3) (credentialsList)
set:
persistence:
destbackup:
enabled: true
type: pvc
mountPath: /backedup
volsync:
- name: mybackup1
type: restic
credentials: mys3
dest:
enabled: true
src:
enabled: false
credentialsList:
- name: mys3
type: s3
url: some-url
bucket: some-bucket
encrKey: some-key
accessKey: some-access-key
secretKey: some-secret-key
asserts:
- documentIndex: &secretDoc 0
isKind:
of: Secret
- documentIndex: *secretDoc
isAPIVersion:
of: v1
- documentIndex: *secretDoc
equal:
path: metadata.name
value: test-release-name-common-test-destbackup-volsync-mybackup1
- documentIndex: *secretDoc
equal:
path: stringData
value:
AWS_ACCESS_KEY_ID: some-access-key
AWS_SECRET_ACCESS_KEY: some-secret-key
RESTIC_PASSWORD: some-key
RESTIC_REPOSITORY: s3:some-url/some-bucket/test-release-name/volsync/destbackup-volsync-mybackup1
- documentIndex: &replicationDestDoc 1
isKind:
of: ReplicationDestination
- documentIndex: *replicationDestDoc
isAPIVersion:
of: volsync.backube/v1alpha1
- documentIndex: *replicationDestDoc
equal:
path: spec
value:
trigger:
manual: restore-once
restic:
repository: test-release-name-common-test-destbackup-volsync-mybackup1
copyMethod: Snapshot
capacity: 100Gi
accessModes:
- ReadWriteOnce
moverSecurityContext:
fsGroup: 568
runAsUser: 568
runAsGroup: 568

View File

@@ -37,6 +37,10 @@ tests:
- documentIndex: *secretDoc
isAPIVersion:
of: v1
- documentIndex: *secretDoc
equal:
path: metadata.name
value: test-release-name-common-test-destbackup-volsync-mybackup1
- documentIndex: *secretDoc
equal:
path: stringData

View File

@@ -59,10 +59,17 @@ tests:
enabled: true
dest:
enabled: false
credentials: {}
credentials:
my-other-secret:
type: s3
url: some-url
bucket: some-bucket
encrKey: some-key
accessKey: some-access-key
secretKey: some-secret-key
asserts:
- failedTemplate:
errorMessage: VolSync - Expected credentials [my-secret] to be defined in [credentials.my-secret]
errorMessage: VolSync - Expected credentials [my-secret] to be defined in [credentials] which currently contains [my-other-secret] keys
- it: should fail if credentials.url is empty
set:

View File

@@ -15,7 +15,7 @@ maintainers:
name: common
sources: null
type: library
version: 23.0.7
version: 23.0.8
annotations:
artifacthub.io/category: "integration-delivery"
artifacthub.io/license: "BUSL-1.1"

View File

@@ -29,7 +29,7 @@ apiVersion: volsync.backube/v1alpha1
kind: ReplicationDestination
metadata:
name: {{ printf "%s-%s-dest" $objectData.name $volsyncData.name }}
namespace: {{ include "tc.v1.common.lib.metadata.namespace" (dict "rootCtx" $rootCtx "objectData" $objectData "caller" "replicationdestination") }}
namespace: {{ include "tc.v1.common.lib.metadata.namespace" (dict "rootCtx" $rootCtx "objectData" $objectData "caller" "Replication Destination") }}
{{- $labels := (mustMerge ($volsyncData.labels | default dict) (include "tc.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)) -}}
{{- with (include "tc.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
labels:

View File

@@ -6,7 +6,7 @@
{{- $credentials := get $rootCtx.Values.credentials $credName -}}
{{- if not $credentials -}}
{{- fail (printf "%s - Expected credentials [%s] to be defined in [credentials.%s]" $caller $credName $credName) -}}
{{- fail (printf "%s - Expected credentials [%s] to be defined in [credentials] which currently contains [%s] keys" $caller $credName (keys $rootCtx.Values.credentials | join ", ")) -}}
{{- end -}}
{{- $validCredTypes := list "s3" -}}