From 2ff0e92645f0494c7574fca31fdc83aa9fbb1aa3 Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Sun, 7 Apr 2024 16:13:32 +0300 Subject: [PATCH] fix(tests): fix document position on cnpg after pgversion cm removal (#777) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** ⚒️ Fixes # **⚙️ 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?** **📃 Notes:** **✔️ Checklist:** - [x] ⚖️ My code follows the style guidelines of this project - [x] 👀 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 - [x] ⚠️ My changes generate no new warnings - [x] 🧪 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 - [x] 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._ --- .../backup_provider_secret_spec_test.yaml | 2 +- .../tests/cnpg/cluster_backup_spec_test.yaml | 14 +-- .../cnpg/cluster_recovery_spec_test.yaml | 2 +- .../tests/cnpg/cluster_spec_test.yaml | 6 +- .../tests/cnpg/credentials_test.yaml | 10 +- .../common-test/tests/cnpg/db_wait_test.yaml | 6 +- .../tests/cnpg/pg_version_configmap_test.yaml | 105 ------------------ .../tests/container/resources_test.yaml | 2 +- .../addons/vpn/_gluetunContainer.tpl | 13 ++- library/common/templates/spawner/_cnpg.tpl | 4 +- 10 files changed, 32 insertions(+), 132 deletions(-) delete mode 100644 library/common-test/tests/cnpg/pg_version_configmap_test.yaml diff --git a/library/common-test/tests/cnpg/backup_provider_secret_spec_test.yaml b/library/common-test/tests/cnpg/backup_provider_secret_spec_test.yaml index 275ae0f6..9a5286ab 100644 --- a/library/common-test/tests/cnpg/backup_provider_secret_spec_test.yaml +++ b/library/common-test/tests/cnpg/backup_provider_secret_spec_test.yaml @@ -23,7 +23,7 @@ tests: manualBackups: - name: today asserts: - - documentIndex: &secretDoc 3 + - documentIndex: &secretDoc 2 isKind: of: Secret - documentIndex: *secretDoc 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 1dc71f84..252c637f 100644 --- a/library/common-test/tests/cnpg/cluster_backup_spec_test.yaml +++ b/library/common-test/tests/cnpg/cluster_backup_spec_test.yaml @@ -21,7 +21,7 @@ tests: azure: connectionString: some-connection-string asserts: - - documentIndex: &secretDoc 2 + - documentIndex: &secretDoc 1 isKind: of: Secret - documentIndex: *secretDoc @@ -97,7 +97,7 @@ tests: google: applicationCredentials: some-credentials asserts: - - documentIndex: &secretDoc 2 + - documentIndex: *secretDoc isKind: of: Secret - documentIndex: *secretDoc @@ -164,7 +164,7 @@ tests: accessKey: some-access-key secretKey: some-secret-key asserts: - - documentIndex: &secretDoc 2 + - documentIndex: *secretDoc isKind: of: Secret - documentIndex: *secretDoc @@ -235,7 +235,7 @@ tests: accessKey: some-access-key secretKey: some-secret-key asserts: - - documentIndex: &secretDoc 2 + - documentIndex: *secretDoc isKind: of: Secret - documentIndex: *secretDoc @@ -306,7 +306,7 @@ tests: accessKey: some-access-key secretKey: some-secret-key asserts: - - documentIndex: &secretDoc 2 + - documentIndex: *secretDoc isKind: of: Secret - documentIndex: *secretDoc @@ -378,7 +378,7 @@ tests: accessKey: some-access-key secretKey: some-secret-key asserts: - - documentIndex: &secretDoc 2 + - documentIndex: *secretDoc isKind: of: Secret - documentIndex: *secretDoc @@ -456,5 +456,5 @@ tests: path: metadata.name value: test-release-name-common-test-cnpg-my-pg - documentIndex: *clusterDoc - isNull: + notExists: path: spec.backup.target 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 07df5deb..faa090ac 100644 --- a/library/common-test/tests/cnpg/cluster_recovery_spec_test.yaml +++ b/library/common-test/tests/cnpg/cluster_recovery_spec_test.yaml @@ -88,7 +88,7 @@ tests: pitrTarget: time: "2021-01-01T00:00:00Z" asserts: - - documentIndex: &secretDoc 2 + - documentIndex: &secretDoc 1 isKind: of: Secret - documentIndex: *secretDoc diff --git a/library/common-test/tests/cnpg/cluster_spec_test.yaml b/library/common-test/tests/cnpg/cluster_spec_test.yaml index 53f09c22..0eadf682 100644 --- a/library/common-test/tests/cnpg/cluster_spec_test.yaml +++ b/library/common-test/tests/cnpg/cluster_spec_test.yaml @@ -72,7 +72,7 @@ tests: tag: "15.6" global: fallbackDefaults: - pgVersion: "15" + pgVersion: 15 vctAccessModes: - ReadWriteMany - ReadWriteOnce @@ -124,7 +124,7 @@ tests: enabled: true user: test-user database: test-db - pgVersion: "15" + pgVersion: 15 type: vectors asserts: - documentIndex: *clusterDoc @@ -152,7 +152,7 @@ tests: enabled: true user: test-user database: test-db - pgVersion: "15" + pgVersion: 15 asserts: - documentIndex: *clusterDoc isKind: diff --git a/library/common-test/tests/cnpg/credentials_test.yaml b/library/common-test/tests/cnpg/credentials_test.yaml index 826a32b7..77fb7e0f 100644 --- a/library/common-test/tests/cnpg/credentials_test.yaml +++ b/library/common-test/tests/cnpg/credentials_test.yaml @@ -13,7 +13,7 @@ tests: user: test-user database: test-db asserts: - - documentIndex: &secretDoc 3 + - documentIndex: &secretDoc 2 isKind: of: Secret - documentIndex: *secretDoc @@ -36,7 +36,7 @@ tests: path: stringData.password pattern: ^[a-zA-Z0-9]{62}$ - - documentIndex: &secretDoc 2 + - documentIndex: &secretDoc 1 isKind: of: Secret - documentIndex: *secretDoc @@ -73,7 +73,7 @@ tests: enabled: true createRO: false asserts: - - documentIndex: &secretDoc 3 + - documentIndex: &secretDoc 2 isKind: of: Secret - documentIndex: *secretDoc @@ -110,7 +110,7 @@ tests: enabled: true createRO: true asserts: - - documentIndex: &secretDoc 4 + - documentIndex: &secretDoc 3 isKind: of: Secret - documentIndex: *secretDoc @@ -156,7 +156,7 @@ tests: database: test-db password: test-password asserts: - - documentIndex: &secretDoc 3 + - documentIndex: &secretDoc 2 isKind: of: Secret - documentIndex: *secretDoc diff --git a/library/common-test/tests/cnpg/db_wait_test.yaml b/library/common-test/tests/cnpg/db_wait_test.yaml index 499df3e8..a3c93edd 100644 --- a/library/common-test/tests/cnpg/db_wait_test.yaml +++ b/library/common-test/tests/cnpg/db_wait_test.yaml @@ -22,7 +22,7 @@ tests: user: test-user database: test-db asserts: - - documentIndex: &deployDoc 4 + - documentIndex: &deployDoc 3 isKind: of: Deployment - documentIndex: *deployDoc @@ -63,7 +63,7 @@ tests: enabled: true createRO: false asserts: - - documentIndex: &deployDoc 5 + - documentIndex: &deployDoc 4 isKind: of: Deployment - documentIndex: *deployDoc @@ -111,7 +111,7 @@ tests: enabled: true createRO: true asserts: - - documentIndex: &deployDoc 6 + - documentIndex: &deployDoc 5 isKind: of: Deployment - documentIndex: *deployDoc diff --git a/library/common-test/tests/cnpg/pg_version_configmap_test.yaml b/library/common-test/tests/cnpg/pg_version_configmap_test.yaml deleted file mode 100644 index e3262943..00000000 --- a/library/common-test/tests/cnpg/pg_version_configmap_test.yaml +++ /dev/null @@ -1,105 +0,0 @@ -suite: cnpg pgVersion configmap test -templates: - - common.yaml -release: - name: test-release-name - namespace: test-release-namespace -tests: - - it: should generate correct configmap - set: - cnpg: - my-pg: - enabled: true - user: test-user - database: test-db - asserts: - - documentIndex: &cmDoc 1 - isKind: - of: ConfigMap - - documentIndex: *cmDoc - isAPIVersion: - of: v1 - - documentIndex: *cmDoc - equal: - path: metadata.name - value: test-release-name-common-test-cnpg-my-pg-pgversion - - documentIndex: *cmDoc - equal: - path: data.version - value: "16" - - - it: should generate correct configmap with changed defaults - set: - global: - fallbackDefaults: - pgVersion: "15" - cnpg: - my-pg: - enabled: true - user: test-user - database: test-db - asserts: - - documentIndex: *cmDoc - isKind: - of: ConfigMap - - documentIndex: *cmDoc - isAPIVersion: - of: v1 - - documentIndex: *cmDoc - equal: - path: metadata.name - value: test-release-name-common-test-cnpg-my-pg-pgversion - - documentIndex: *cmDoc - equal: - path: data.version - value: "15" - - - it: should generate correct configmap with defaults being a number instead of string - set: - global: - fallbackDefaults: - pgVersion: 15 - cnpg: - my-pg: - enabled: true - user: test-user - database: test-db - asserts: - - documentIndex: *cmDoc - isKind: - of: ConfigMap - - documentIndex: *cmDoc - isAPIVersion: - of: v1 - - documentIndex: *cmDoc - equal: - path: metadata.name - value: test-release-name-common-test-cnpg-my-pg-pgversion - - documentIndex: *cmDoc - equal: - path: data.version - value: "15" - - - it: should generate correct configmap with changed at cnpg level - set: - cnpg: - my-pg: - enabled: true - user: test-user - database: test-db - pgVersion: "15" - asserts: - - documentIndex: *cmDoc - isKind: - of: ConfigMap - - documentIndex: *cmDoc - isAPIVersion: - of: v1 - - documentIndex: *cmDoc - equal: - path: metadata.name - value: test-release-name-common-test-cnpg-my-pg-pgversion - - documentIndex: *cmDoc - equal: - path: data.version - value: "15" diff --git a/library/common-test/tests/container/resources_test.yaml b/library/common-test/tests/container/resources_test.yaml index 8c237c36..e5408941 100644 --- a/library/common-test/tests/container/resources_test.yaml +++ b/library/common-test/tests/container/resources_test.yaml @@ -455,7 +455,7 @@ tests: requests: cpu: 10m memory: 50Mi - - documentIndex: &deploymentDoc 9 + - documentIndex: &deploymentDoc 8 isKind: of: Deployment - documentIndex: *deploymentDoc diff --git a/library/common/templates/addons/vpn/_gluetunContainer.tpl b/library/common/templates/addons/vpn/_gluetunContainer.tpl index 6eb3dc07..a8a1d1fb 100644 --- a/library/common/templates/addons/vpn/_gluetunContainer.tpl +++ b/library/common/templates/addons/vpn/_gluetunContainer.tpl @@ -37,16 +37,21 @@ env: DNS_KEEP_NAMESERVER: "on" DOT: "off" {{- if $.Values.addons.vpn.killSwitch }} -{{- $excludednetworks := ( printf "%v,%v" $.Values.chartContext.podCIDR $.Values.chartContext.svcCIDR ) -}} +{{- $excludednetworks := (printf "%v,%v" $.Values.chartContext.podCIDR $.Values.chartContext.svcCIDR) -}} {{- range $.Values.addons.vpn.excludedNetworks_IPv4 -}} - {{- $excludednetworks = ( printf "%v,%v" $excludednetworks . ) -}} + {{- $excludednetworks = (printf "%v,%v" $excludednetworks .) -}} {{- end }} {{- range $.Values.addons.vpn.excludedNetworks_IPv6 -}} - {{- $excludednetworksv6 = ( printf "%v,%v" $excludednetworks . ) -}} + {{- $excludednetworksv6 = (printf "%v,%v" $excludednetworks .) -}} {{- end }} FIREWALL: "on" FIREWALL_OUTBOUND_SUBNETS: {{ $excludednetworks | quote }} -{{- $inputPorts := (list $.Values.service.main.ports.main.port) -}} +{{- $inputPorts := list -}} +{{- if and + $.Values.service $.Values.service.main $.Values.service.main.ports + $.Values.service.main.ports.main $.Values.service.main.ports.main.port -}} + {{- $inputPorts = list $.Values.service.main.ports.main.port -}} +{{- end -}} {{- $inputPorts = concat $inputPorts $.Values.addons.vpn.inputPorts | mustUniq }} FIREWALL_INPUT_PORTS: {{ join "," $inputPorts }} {{- else }} diff --git a/library/common/templates/spawner/_cnpg.tpl b/library/common/templates/spawner/_cnpg.tpl index 0fe5764f..80df3955 100644 --- a/library/common/templates/spawner/_cnpg.tpl +++ b/library/common/templates/spawner/_cnpg.tpl @@ -24,10 +24,10 @@ {{- if eq $enabled "true" -}} {{/* Handle version string */}} - {{- $pgVersion := $objectData.pgVersion | default (toString $.Values.global.fallbackDefaults.pgVersion) -}} + {{- $pgVersion := ($objectData.pgVersion | default $.Values.global.fallbackDefaults.pgVersion) | toString -}} {{/* Set the updated pgVersion version to objectData */}} - {{- $_ := set $objectData "pgVersion" ($pgVersion | toString) -}} + {{- $_ := set $objectData "pgVersion" $pgVersion -}} {{/* allow for injecting major upgrade code */}} {{- if $objectData.upgradeMajor -}}