-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from abdullah-sl/feature/PLAT-392-add-unit-te…
…sts-for-cronjob-chart Add unit tests for cronjob chart
- Loading branch information
Showing
12 changed files
with
733 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
name: Test cronjob chart | ||
|
||
on: | ||
push: | ||
paths: | ||
- cronjob/** | ||
- .github/workflows/** | ||
pull_request: | ||
paths: | ||
- cronjob/** | ||
- .github/workflows/** | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
helm-version: | ||
- 3.1.0 | ||
- 3.2.3 | ||
- 3.2.4 | ||
- 3.3.0 | ||
- latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Helm ${{ matrix.helm-version }} | ||
uses: azure/[email protected] | ||
with: | ||
version: ${{ matrix.helm-version }} | ||
|
||
- name: Install Helm unittest plugin | ||
run: | | ||
helm plugin install https://github.com/helm-unittest/helm-unittest.git | ||
- name: Run cronjob chart tests | ||
run: | | ||
helm unittest cronjob |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
.github | ||
*.md | ||
*.tgz | ||
tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
suite: ConfigMap Test | ||
templates: | ||
- configmaps.yaml | ||
tests: | ||
- it: should render nothing if no configmaps are provided | ||
asserts: | ||
- hasDocuments: | ||
count: 0 | ||
|
||
- it: should render a configmap | ||
set: | ||
configmaps: | ||
test-configmap: | ||
data: | ||
TEST_KEY: "test-value" | ||
TEST_KEY_2: "test-value-2" | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
- isKind: | ||
of: ConfigMap | ||
- equal: | ||
path: data.TEST_KEY | ||
value: "test-value" | ||
- equal: | ||
path: data.TEST_KEY_2 | ||
value: "test-value-2" | ||
|
||
- it: should render multiple configmaps | ||
set: | ||
configmaps: | ||
test-configmap: | ||
data: | ||
TEST_KEY: "test-value" | ||
test-configmap-2: | ||
data: | ||
TEST_KEY: "test-value" | ||
asserts: | ||
- hasDocuments: | ||
count: 2 | ||
- isKind: | ||
of: ConfigMap | ||
documentIndex: 0 | ||
- equal: | ||
path: metadata.name | ||
value: test-configmap-2 | ||
documentIndex: 1 | ||
- equal: | ||
path: data.TEST_KEY | ||
value: "test-value" | ||
documentIndex: 0 | ||
- equal: | ||
path: data.TEST_KEY | ||
value: "test-value" | ||
documentIndex: 1 | ||
|
||
- it: should render a configmap with quoted values | ||
set: | ||
configmaps: | ||
test-configmap: | ||
data: | ||
TEST_KEY: 9527 | ||
TEST_KEY_2: true | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
- isKind: | ||
of: ConfigMap | ||
- equal: | ||
path: data.TEST_KEY | ||
value: "9527" | ||
- equal: | ||
path: data.TEST_KEY_2 | ||
value: "true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
suite: CronJob Test | ||
templates: | ||
- cronjob.yaml | ||
tests: | ||
- it: should render a argo cron workflow with default values | ||
values: | ||
- ./values/cronjob/argo.yaml | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
- isKind: | ||
of: CronWorkflow | ||
- equal: | ||
path: spec.timezone | ||
value: "Etc/UTC" | ||
- equal: | ||
path: spec.successfulJobsHistoryLimit | ||
value: 3 | ||
- equal: | ||
path: spec.failedJobsHistoryLimit | ||
value: 1 | ||
- equal: | ||
path: spec.concurrencyPolicy | ||
value: "Allow" | ||
- equal: | ||
path: spec.suspend | ||
value: false | ||
- equal: | ||
path: spec.schedule | ||
value: "1 * * * *" | ||
- equal: | ||
path: spec.workflowSpec.templates[1].container.command | ||
value: | ||
- bundle | ||
- exec | ||
- rails | ||
- test | ||
- equal: | ||
path: spec.workflowSpec.templates[1].container.image | ||
value: "test/testImage:latest" | ||
|
||
- it: should render a argo cron workflow with custom values | ||
values: | ||
- ./values/cronjob/argo.yaml | ||
set: | ||
timezone: Asia/Taipei | ||
job: | ||
history: | ||
success: 99 | ||
failed: 99 | ||
concurrency: Forbid | ||
suspend: true | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
- isKind: | ||
of: CronWorkflow | ||
- equal: | ||
path: spec.timezone | ||
value: "Asia/Taipei" | ||
- equal: | ||
path: spec.successfulJobsHistoryLimit | ||
value: 99 | ||
- equal: | ||
path: spec.failedJobsHistoryLimit | ||
value: 99 | ||
- equal: | ||
path: spec.concurrencyPolicy | ||
value: "Forbid" | ||
- equal: | ||
path: spec.suspend | ||
value: true | ||
- equal: | ||
path: spec.schedule | ||
value: "1 * * * *" | ||
- equal: | ||
path: spec.workflowSpec.templates[1].container.command | ||
value: | ||
- bundle | ||
- exec | ||
- rails | ||
- test | ||
- equal: | ||
path: spec.workflowSpec.templates[1].container.image | ||
value: "test/testImage:latest" | ||
|
||
- it: should render a k8s cron job with default values | ||
values: | ||
- ./values/cronjob/k8s.yaml | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
- isKind: | ||
of: CronJob | ||
- equal: | ||
path: spec.successfulJobsHistoryLimit | ||
value: 3 | ||
- equal: | ||
path: spec.failedJobsHistoryLimit | ||
value: 1 | ||
- equal: | ||
path: spec.concurrencyPolicy | ||
value: "Allow" | ||
- equal: | ||
path: spec.suspend | ||
value: false | ||
- equal: | ||
path: spec.schedule | ||
value: "0 * * * *" | ||
- equal: | ||
path: spec.jobTemplate.spec.template.spec.containers[0].image | ||
value: "test/testImage:latest:v1.0.0" | ||
- equal: | ||
path: spec.jobTemplate.spec.template.spec.containers[0].command | ||
value: | ||
- /app/run.sh | ||
|
||
- it: should render a k8s cron job with custom values | ||
values: | ||
- ./values/cronjob/k8s.yaml | ||
set: | ||
job: | ||
history: | ||
success: 99 | ||
failed: 99 | ||
concurrency: Forbid | ||
suspend: true | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
- isKind: | ||
of: CronJob | ||
- equal: | ||
path: spec.successfulJobsHistoryLimit | ||
value: 99 | ||
- equal: | ||
path: spec.failedJobsHistoryLimit | ||
value: 99 | ||
- equal: | ||
path: spec.concurrencyPolicy | ||
value: "Forbid" | ||
- equal: | ||
path: spec.suspend | ||
value: true | ||
- equal: | ||
path: spec.schedule | ||
value: "0 * * * *" | ||
- equal: | ||
path: spec.jobTemplate.spec.template.spec.containers[0].image | ||
value: "test/testImage:latest:v1.0.0" | ||
- equal: | ||
path: spec.jobTemplate.spec.template.spec.containers[0].command | ||
value: | ||
- /app/run.sh | ||
|
||
- it: should render a argo cron workflow when exitNotifications.slackApp exists and mention is null | ||
values: | ||
- ./values/cronjob/argo.yaml | ||
set: | ||
exitNotifications: | ||
slackApp: | ||
mention: ~ | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
- isKind: | ||
of: CronWorkflow | ||
|
||
- it: should render a argo cron workflow when exitNotifications.slackApp.mention exists and onSuccess is null | ||
values: | ||
- ./values/cronjob/argo.yaml | ||
set: | ||
exitNotifications: | ||
slackApp: | ||
mention: | ||
onSuccess: ~ | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
- isKind: | ||
of: CronWorkflow | ||
|
||
- it: should render a argo cron workflow when exitNotifications.slackApp.mention exists and onFailure is null | ||
values: | ||
- ./values/cronjob/argo.yaml | ||
set: | ||
exitNotifications: | ||
slackApp: | ||
mention: | ||
onFailure: ~ | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
- isKind: | ||
of: CronWorkflow | ||
|
||
- it: should not render a argo cron workflow when image.repository is null | ||
values: | ||
- ./values/cronjob/argo.yaml | ||
set: | ||
image: | ||
repository: ~ | ||
asserts: | ||
- failedTemplate: | ||
errorMessage: image.repository must be provided | ||
|
||
- it: should not render a argo cron workflow when image.tag is null | ||
values: | ||
- ./values/cronjob/argo.yaml | ||
set: | ||
image: | ||
tag: ~ | ||
asserts: | ||
- failedTemplate: | ||
errorMessage: image.tag must be provided | ||
|
||
- it: should render a argo cron workflow with minimal values | ||
values: | ||
- ./values/cronjob/argo_minimal.yaml | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
- isKind: | ||
of: CronWorkflow |
Oops, something went wrong.