Skip to content

Commit

Permalink
test: add health tests for batch/cronjob
Browse files Browse the repository at this point in the history
Signed-off-by: Ali Ghotbizadeh <[email protected]>
  • Loading branch information
polarAli committed Aug 29, 2023
1 parent 438ad4c commit 26f77c2
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 0 deletions.
21 changes: 21 additions & 0 deletions resource_customizations/batch/CronJob/health_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
tests:
- healthStatus:
status: Healthy
message: CronJob has never run
inputPath: testdata/notScheduled.yaml
- healthStatus:
status: Healthy
message: CronJob has run successfully
inputPath: testdata/successfullyRun.yaml
- healthStatus:
status: Progressing
message: CronJob has active jobs
inputPath: testdata/activeJobs.yaml
- healthStatus:
status: Degraded
message: CronJob has not run successfully
inputPath: testdata/oldLastSuccessfulRun.yaml
- healthStatus:
status: Degraded
message: CronJob has not run successfully
inputPath: testdata/noLastSuccessfulRun.yaml
26 changes: 26 additions & 0 deletions resource_customizations/batch/CronJob/testdata/activeJobs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: batch/v1
kind: CronJob
name: activeJobsCronJob
namespace: default
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: activeJobsCronJob
image: busybox
command:
- /bin/sh
- -c
- date; echo Hello from the Kubernetes cluster
restartPolicy: OnFailure
status:
active:
- apiVersion: batch/v1
kind: Job
name: activeJobsCronJob-1597969200
namespace: default
uid: 0a0a0a0a-0a0a-0a0a-0a0a-0a0a0a0a0a0a
lastScheduleTime: "2020-08-20T18:00:00Z"
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: batch/v1
kind: CronJob
name: noLastSuccessfulRunCronJob
namespace: default
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: noLastSuccessfulRunCronJob
image: busybox
command:
- /bin/sh
- -c
- date; echo Hello from the Kubernetes cluster
restartPolicy: OnFailure
status:
lastScheduleTime: "2020-08-20T18:00:00Z"
20 changes: 20 additions & 0 deletions resource_customizations/batch/CronJob/testdata/notScheduled.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: batch/v1
kind: CronJob
name: notScheduledCronJob
namespace: default
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: notScheduledCronJob
image: busybox
command:
- /bin/sh
- -c
- date; echo Hello from the Kubernetes cluster
restartPolicy: OnFailure
status:
lastScheduleTime: null
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: batch/v1
kind: CronJob
name: oldLastSuccessfulRunCronJob
namespace: default
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: oldLastSuccessfulRunCronJob
image: busybox
command:
- /bin/sh
- -c
- date; echo Hello from the Kubernetes cluster
restartPolicy: OnFailure
status:
lastScheduleTime: "2020-08-20T18:00:00Z"
lastSuccessfulTime: "2020-08-20T15:00:00Z"
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: batch/v1
kind: CronJob
name: successfullyRunCronJob
namespace: default
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: successfullyRunCronJob
image: busybox
command:
- /bin/sh
- -c
- date; echo Hello from the Kubernetes cluster
restartPolicy: OnFailure
status:
lastScheduleTime: "2020-08-20T18:00:00Z"
lastSuccessfulTime: "2020-08-20T18:05:00Z"

0 comments on commit 26f77c2

Please sign in to comment.