Files
truecharts/charts/library/common-test/tests/cronjob/validation_test.yaml
T
Stavros Kois 006cae1856 fix(common): set correct default for restartPolicy for cronjobs (#28356)
**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  #28118

**⚙️ Type of change**

- [ ] ⚙️ Feature/App addition
- [x] 🪛 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:**

- [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
- [x] 📄 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
- [x] ⬆️ 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._
2024-10-26 17:55:53 +02:00

75 lines
2.2 KiB
YAML

suite: cronjob validation test
templates:
- common.yaml
release:
name: test-release-name
namespace: test-release-namespace
tests:
- it: should fail with invalid concurrencyPolicy
set:
workload:
workload-name:
enabled: true
primary: true
type: CronJob
concurrencyPolicy: not-a-policy
podSpec: {}
asserts:
- failedTemplate:
errorMessage: CronJob - Expected [concurrencyPolicy] to be one of [Allow, Forbid, Replace], but got [not-a-policy]
- it: should fail with empty schedule
set:
workload:
workload-name:
enabled: true
primary: true
type: CronJob
schedule:
podSpec: {}
asserts:
- failedTemplate:
errorMessage: CronJob - Expected non-empty [schedule]
- it: should fail with invalid completionMode (make sure job validation kicks in)
set:
workload:
workload-name:
enabled: true
primary: true
type: CronJob
schedule: "* * * * *"
completionMode: not-a-mode
podSpec: {}
asserts:
- failedTemplate:
errorMessage: Job - Expected [completionMode] to be one of [Indexed, NonIndexed], but got [not-a-mode]
- it: should fail with namespace longer than 63 characters
set:
workload:
workload-name:
enabled: true
primary: true
type: CronJob
schedule: "* * * * *"
namespace: my-extra-super-duper-long-name-that-is-longer-than-63-characters
podSpec: {}
asserts:
- failedTemplate:
errorMessage: CronJob - Namespace [my-extra-super-duper-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.
- it: should fail with restartPolicy "Always" for CronJob
set:
workload:
workload-name:
enabled: true
primary: true
type: CronJob
schedule: "* * * * *"
podSpec:
restartPolicy: Always
asserts:
- failedTemplate:
errorMessage: Expected [restartPolicy] to be one of [Never, OnFailure] for [CronJob] but got [Always]