Files
library-charts/library/common-test/tests/cnpg/cluster_backup_spec_test.yaml
Kjeld Schouten 47daa5c813 feat(common): rework and update cnpg code (#509)
**Description**
This PR aims to rework and update cnpg code to expose more features of
CNPG to our users.
Primarily a big change would be the support of more backup and restore
options.

- add some missing options for both cluster and pooler
- seperates cluster and pooler sections
- add labels/annotions for pooler and cluster seperatly as well as
cnpg-wide labels-annotations
- Simplify storage logic
- Disable metrics by default

**⚙️ Type of change**

- [x] ⚙️ Feature/App addition
- [x] 🪛 Bugfix
- [x] ⚠️ Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [x] 🔃 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:**

It will be very loosely inspired by the work done here, mostly because
it gives some nice values.yaml structure on how to deal with the many
backup options:
https://github.com/cloudnative-pg/charts/pull/106

It's going to be flagged as "breaking", because of the shear scope and
the fact it would likely also include a change in standard operating
procedures when it comes to backup-and-restore for our users.

**✔️ 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

** App addition**

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

- [ ] 🪞 I have opened a PR on
[truecharts/containers](https://github.com/truecharts/containers) adding
the container to TrueCharts mirror repo.
- [ ] 🖼️ 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._

---------

Co-authored-by: Stavros kois <s.kois@outlook.com>
Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>
2023-12-04 02:49:27 +02:00

224 lines
6.8 KiB
YAML

suite: cnpg cluster backup spec test
templates:
- common.yaml
release:
name: test-release-name
namespace: test-release-namespace
tests:
- it: should generate correct spec with backups (azure)
set:
operator:
verify:
enabled: false
cnpg:
my-pg:
enabled: true
user: test-user
database: test-db
backups:
enabled: true
target: primary
retentionPolicy: 10d
provider: azure
destinationPath: some-path
azure:
connectionString: some-connection-string
asserts:
- documentIndex: &secretDoc 2
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-azure-creds
- documentIndex: *secretDoc
equal:
path: stringData
value:
CONNECTION_STRING: some-connection-string
STORAGE_ACCOUNT: ""
STORAGE_KEY: ""
STORAGE_SAS_TOKEN: ""
- documentIndex: &clusterDoc 1
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:
target: primary
retentionPolicy: 10d
barmanObjectStore:
wal:
compression: gzip
encryption: AES256
data:
compression: gzip
encryption: AES256
jobs: 2
endpointURL: null
destinationPath: some-path
azureCredentials:
connectionString:
key: CONNECTION_STRING
name: test-release-name-common-test-cnpg-my-pg-provider-backup-azure-creds
storageAccount:
key: STORAGE_ACCOUNT
name: test-release-name-common-test-cnpg-my-pg-provider-backup-azure-creds
storageKey:
key: STORAGE_KEY
name: test-release-name-common-test-cnpg-my-pg-provider-backup-azure-creds
storageSasToken:
key: STORAGE_SAS_TOKEN
name: test-release-name-common-test-cnpg-my-pg-provider-backup-azure-creds
- it: should generate correct spec with backups (google)
set:
operator:
verify:
enabled: false
cnpg:
my-pg:
enabled: true
user: test-user
database: test-db
backups:
enabled: true
target: primary
retentionPolicy: 10d
provider: google
destinationPath: some-path
google:
applicationCredentials: some-credentials
asserts:
- documentIndex: &secretDoc 2
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-google-creds
- documentIndex: *secretDoc
equal:
path: stringData
value:
APPLICATION_CREDENTIALS: some-credentials
- documentIndex: &clusterDoc 1
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:
target: primary
retentionPolicy: 10d
barmanObjectStore:
wal:
compression: gzip
encryption: AES256
data:
compression: gzip
encryption: AES256
jobs: 2
endpointURL: null
destinationPath: some-path
googleCredentials:
gkeEnvironment: false
applicationCredentials:
key: APPLICATION_CREDENTIALS
name: test-release-name-common-test-cnpg-my-pg-provider-backup-google-creds
- it: should generate correct spec with backups (s3)
set:
operator:
verify:
enabled: false
cnpg:
my-pg:
enabled: true
user: test-user
database: test-db
backups:
enabled: true
target: primary
retentionPolicy: 10d
provider: s3
destinationPath: some-path
endpointURL: some-url
s3:
accessKey: some-access-key
secretKey: some-secret-key
asserts:
- documentIndex: &secretDoc 2
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 1
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:
target: primary
retentionPolicy: 10d
barmanObjectStore:
wal:
compression: gzip
encryption: AES256
data:
compression: gzip
encryption: AES256
jobs: 2
endpointURL: some-url
destinationPath: some-path
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