chore(pdb): expand tests (#843)

**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-06-25 22:44:15 +03:00
committed by GitHub
parent be9538bc2c
commit c6e56261ef
4 changed files with 54 additions and 11 deletions

View File

@@ -5,7 +5,7 @@ release:
name: test-release-name
namespace: test-release-namespace
tests:
- it: should pass with zero in keys
- it: should pass with zero in keys (minAvailable)
set:
podDisruptionBudget:
my-pdb1:
@@ -13,7 +13,6 @@ tests:
customLabels:
label1: value1
minAvailable: 0
maxUnavailable: 0
asserts:
- documentIndex: &pdbDoc 0
isKind:
@@ -23,12 +22,28 @@ tests:
path: spec
content:
minAvailable: 0
- it: should pass with zero in keys (maxUnavailable)
set:
podDisruptionBudget:
my-pdb1:
enabled: true
customLabels:
label1: value1
maxUnavailable: 0
asserts:
- documentIndex: &pdbDoc 0
isKind:
of: PodDisruptionBudget
- documentIndex: *pdbDoc
isSubset:
path: spec
content:
maxUnavailable: 0
- it: should pass keys from tpl
- it: should pass keys from tpl (minAvailable)
set:
k1: 0
k2: 0
k3: AlwaysAllow
podDisruptionBudget:
my-pdb1:
@@ -36,7 +51,6 @@ tests:
customLabels:
label1: value1
minAvailable: "{{ .Values.k1 }}"
maxUnavailable: "{{ .Values.k2 }}"
unhealthyPodEvictionPolicy: "{{ .Values.k3 }}"
asserts:
- documentIndex: *pdbDoc
@@ -44,9 +58,24 @@ tests:
path: spec
content:
minAvailable: 0
maxUnavailable: 0
unhealthyPodEvictionPolicy: AlwaysAllow
- it: should pass keys from tpl (maxUnavailable)
set:
k2: 0
podDisruptionBudget:
my-pdb1:
enabled: true
customLabels:
label1: value1
maxUnavailable: "{{ .Values.k2 }}"
asserts:
- documentIndex: *pdbDoc
isSubset:
path: spec
content:
maxUnavailable: 0
- it: should pass with percentage in keys
set:
percentage: 50%
@@ -55,14 +84,12 @@ tests:
enabled: true
customLabels:
label1: value1
minAvailable: 50%
maxUnavailable: "{{ .Values.percentage }}"
asserts:
- documentIndex: *pdbDoc
isSubset:
path: spec
content:
minAvailable: 50%
maxUnavailable: 50%
- it: should pass with minAvailable defined

View File

@@ -8,8 +8,8 @@ tests:
- it: should fail with name longer than 63 characters
set:
podDisruptionBudget:
my-poddisruptionbudget-super-long-name-that-is-longer-than-63-characters:
enabled: true
? my-poddisruptionbudget-super-long-name-that-is-longer-than-63-characters
: enabled: true
asserts:
- failedTemplate:
errorMessage: Name [test-release-name-common-test-my-poddisruptionbudget-super-long-name-that-is-longer-than-63-characters] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 63 characters.
@@ -153,3 +153,15 @@ tests:
asserts:
- failedTemplate:
errorMessage: Pod Disruption Budget - Selected pod [my-pod] is not defined
- it: should fail with both minAvailable and maxUnavailable
set:
podDisruptionBudget:
my-poddisruptionbudget:
enabled: true
targetSelector: my-pod
minAvailable: 1
maxUnavailable: 1
asserts:
- failedTemplate:
errorMessage: Pod Disruption Budget - Expected one of [minAvailable, maxUnavailable] to be defined in [podDisruptionBudget.my-poddisruptionbudget], but got both

View File

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

View File

@@ -41,6 +41,10 @@ objectData:
{{- end -}}
{{- end -}}
{{- if and ($objectData.minAvailable) ($objectData.maxUnavailable) -}}
{{- fail (printf "Pod Disruption Budget - Expected one of [%s] to be defined in [podDisruptionBudget.%s], but got both" (join ", " $keys) $objectData.shortName) -}}
{{- end -}}
{{- if not $hasKey -}}
{{- fail (printf "Pod Disruption Budget - Expected at least one of [%s] to be defined in [podDisruptionBudget.%s]" (join ", " $keys) $objectData.shortName) -}}
{{- end -}}