diff --git a/library/common-test/tests/cnpg/cluster_backup_spec_test.yaml b/library/common-test/tests/cnpg/cluster_backup_spec_test.yaml index 4e7570df..b544a539 100644 --- a/library/common-test/tests/cnpg/cluster_backup_spec_test.yaml +++ b/library/common-test/tests/cnpg/cluster_backup_spec_test.yaml @@ -216,6 +216,220 @@ tests: retentionPolicy: 10d target: primary + - it: should use the revision when set in server name + set: + 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 + revision: some-revision + 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: + 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-rsome-revision + wal: + compression: gzip + encryption: AES256 + retentionPolicy: 10d + target: primary + + - it: should override serverName when set + set: + 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 + serverName: some-server-name + 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: + 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: some-server-name + wal: + compression: gzip + encryption: AES256 + retentionPolicy: 10d + target: primary + + - it: should override serverName when set (and also take account revision) + set: + 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 + serverName: some-server-name + revision: "1" + 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: + 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: some-server-name-r1 + wal: + compression: gzip + encryption: AES256 + retentionPolicy: 10d + target: primary + - it: should generate correct spec with empty target set: cnpg: diff --git a/library/common-test/tests/cnpg/cluster_recovery_spec_test.yaml b/library/common-test/tests/cnpg/cluster_recovery_spec_test.yaml index 07717ad7..9ba8af40 100644 --- a/library/common-test/tests/cnpg/cluster_recovery_spec_test.yaml +++ b/library/common-test/tests/cnpg/cluster_recovery_spec_test.yaml @@ -515,3 +515,220 @@ tests: storageSasToken: key: STORAGE_SAS_TOKEN name: test-release-name-common-test-cnpg-my-pg-provider-recovery-azure-creds + + - it: should use revision in serverName when set + set: + cnpg: + my-pg: + enabled: true + user: test-user + database: test-db + mode: recovery + recovery: + method: object_store + provider: google + destinationPath: gs://some-bucket + revision: some-revision + google: + applicationCredentials: some-credentials + pitrTarget: + time: "2021-01-01T00:00:00Z" + 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-recovery-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: + bootstrap: + recovery: + secret: + name: test-release-name-common-test-cnpg-my-pg-user + owner: test-user + database: test-db + source: test-release-name-common-test-cnpg-my-pg-rsome-revision + recoveryTarget: + targetTime: "2021-01-01T00:00:00Z" + - documentIndex: *clusterDoc + isSubset: + path: spec + content: + externalClusters: + - name: test-release-name-common-test-cnpg-my-pg-rsome-revision + barmanObjectStore: + serverName: test-release-name-common-test-cnpg-my-pg-rsome-revision + destinationPath: gs://some-bucket + endpointURL: null + googleCredentials: + applicationCredentials: + key: APPLICATION_CREDENTIALS + name: test-release-name-common-test-cnpg-my-pg-provider-recovery-google-creds + gkeEnvironment: false + + - it: should override serverName when set + set: + cnpg: + my-pg: + enabled: true + user: test-user + database: test-db + mode: recovery + recovery: + method: object_store + provider: google + destinationPath: gs://some-bucket + serverName: some-server-name + google: + applicationCredentials: some-credentials + pitrTarget: + time: "2021-01-01T00:00:00Z" + 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-recovery-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: + bootstrap: + recovery: + secret: + name: test-release-name-common-test-cnpg-my-pg-user + owner: test-user + database: test-db + source: some-server-name + recoveryTarget: + targetTime: "2021-01-01T00:00:00Z" + - documentIndex: *clusterDoc + isSubset: + path: spec + content: + externalClusters: + - name: some-server-name + barmanObjectStore: + serverName: some-server-name + destinationPath: gs://some-bucket + endpointURL: null + googleCredentials: + applicationCredentials: + key: APPLICATION_CREDENTIALS + name: test-release-name-common-test-cnpg-my-pg-provider-recovery-google-creds + gkeEnvironment: false + + - it: should override serverName when set along with revision + set: + cnpg: + my-pg: + enabled: true + user: test-user + database: test-db + mode: recovery + recovery: + method: object_store + provider: google + destinationPath: gs://some-bucket + serverName: some-server-name + revision: "20" + google: + applicationCredentials: some-credentials + pitrTarget: + time: "2021-01-01T00:00:00Z" + 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-recovery-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: + bootstrap: + recovery: + secret: + name: test-release-name-common-test-cnpg-my-pg-user + owner: test-user + database: test-db + source: some-server-name-r20 + recoveryTarget: + targetTime: "2021-01-01T00:00:00Z" + - documentIndex: *clusterDoc + isSubset: + path: spec + content: + externalClusters: + - name: some-server-name-r20 + barmanObjectStore: + serverName: some-server-name-r20 + destinationPath: gs://some-bucket + endpointURL: null + googleCredentials: + applicationCredentials: + key: APPLICATION_CREDENTIALS + name: test-release-name-common-test-cnpg-my-pg-provider-recovery-google-creds + gkeEnvironment: false diff --git a/library/common-test/tests/cnpg/cluster_validation_test.yaml b/library/common-test/tests/cnpg/cluster_validation_test.yaml index ff9d1bb6..c379efc0 100644 --- a/library/common-test/tests/cnpg/cluster_validation_test.yaml +++ b/library/common-test/tests/cnpg/cluster_validation_test.yaml @@ -152,6 +152,22 @@ tests: - failedTemplate: errorMessage: CNPG Recovery - Expected a non-empty [recovery] key + - it: should fail with revision in recovery not a string + set: + cnpg: + my-pg: + enabled: true + user: test-user + database: test-db + mode: recovery + recovery: + method: backup + backupName: some-backup-name + revision: 5 + asserts: + - failedTemplate: + errorMessage: CNPG Recovery - Expected [recovery.revision] to be a string, got [float64] + - it: should fail with invalid recovery method set: cnpg: @@ -318,6 +334,24 @@ tests: - failedTemplate: errorMessage: CNPG Recovery - You need to specify [recovery.azure.containerName] or [recovery.destinationPath] + - it: should fail with revision in backups not a string + set: + cnpg: + my-pg: + enabled: true + user: test-user + database: test-db + backups: + enabled: true + provider: azure + revision: 5 + azure: + connectionString: some-connection-string + target: primary + asserts: + - failedTemplate: + errorMessage: CNPG Backup - Expected [backups.revision] to be a string, got [float64] + - it: should fail with invalid target when backups are enabled set: cnpg: