Skip to content

Commit

Permalink
add test cronjob manifests for errors and delays
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiahui-Zhang-20 committed Dec 5, 2023
1 parent 95ea882 commit 8bb2cab
Show file tree
Hide file tree
Showing 4 changed files with 94 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
33 changes: 33 additions & 0 deletions k8s/errors/cronjob-late-maybe-error.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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!; fi
if [ $r -eq 1 ]; then 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
30 changes: 30 additions & 0 deletions k8s/errors/cronjob-maybe-error.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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!; fi
if [ $r -eq 1 ]; then exit 1; fi
restartPolicy: Never

0 comments on commit 8bb2cab

Please sign in to comment.