Skip to content

Commit

Permalink
tests: add test cronjob manifests for errors and delays (#70)
Browse files Browse the repository at this point in the history
* add test cronjob manifests for errors and delays

* clean up shell commands
  • Loading branch information
Jiahui-Zhang-20 committed Dec 5, 2023
1 parent cf29c41 commit dd38bdf
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 3 deletions.
4 changes: 1 addition & 3 deletions k8s/errors/cronjob-basic-error.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,5 @@ spec:
command:
- /bin/sh
- -c
- |
sleep 1
invalid_command
- sleep 1; invalid_command
restartPolicy: Never
32 changes: 32 additions & 0 deletions k8s/errors/cronjob-late-maybe-error.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: cronjob-late-maybe-error
labels:
type: test-pod
spec:
schedule: "* * * * *"
jobTemplate:
spec:
backoffLimit: 0
template:
metadata:
labels:
type: test-pod
run: cronjob-late-maybe-error
spec:
containers:
- name: hello
image: busybox:1.28
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- |
MINWAIT=0
MAXWAIT=60
sleep $((MINWAIT+RANDOM % (MAXWAIT-MINWAIT)))
sleep 3
r=$((RANDOM%2))
if [ $r -eq 0 ]; then echo Hello!; else exit 1; fi
restartPolicy: Never
30 changes: 30 additions & 0 deletions k8s/errors/cronjob-late-success.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: cronjob-late-success
labels:
type: test-pod
spec:
schedule: "* * * * *"
jobTemplate:
spec:
template:
metadata:
labels:
type: test-pod
run: cronjob-late-success
spec:
containers:
- name: hello
image: busybox:1.28
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- |
date
MINWAIT=0
MAXWAIT=60
sleep $((MINWAIT+RANDOM % (MAXWAIT-MINWAIT)))
echo Hello!
restartPolicy: Never
29 changes: 29 additions & 0 deletions k8s/errors/cronjob-maybe-error.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: cronjob-maybe-error
labels:
type: test-pod
spec:
schedule: "* * * * *"
jobTemplate:
spec:
backoffLimit: 0
template:
metadata:
labels:
type: test-pod
run: cronjob-maybe-error
spec:
containers:
- name: hello
image: busybox:1.28
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- |
sleep 3
r=$((RANDOM%2))
if [ $r -eq 0 ]; then echo Hello!; else exit 1; fi
restartPolicy: Never

0 comments on commit dd38bdf

Please sign in to comment.