forked from IBM/CodeEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·49 lines (38 loc) · 1.2 KB
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# Env Vars:
# NUM: number of instances of the job to run
# REGISTRY: name of the image registry/namespace to get the images
# Clean up previous run
function clean() {
set +ex
echo Cleaning...
(
ibmcloud ce job delete -n job-job -f
ibmcloud ce jobrun delete -n job-doit -f
ibmcloud ce jobrun delete -n job-doit2 -f
rm -f out
) > /dev/null 2>&1
}
clean
[[ "$1" == "clean" ]] && exit 0
set -ex
export REGISTRY=${REGISTRY:-icr.io/codeengine}
export NUM=${NUM:-10}
# Create a Job definition
ibmcloud ce job create --name job-job --array-indices=1-${NUM} \
--image ${REGISTRY}/firstjob
# Now submit the job using that definition - and wait for it to finish
ibmcloud ce jobrun submit --name job-doit --job job-job --wait
# Now submit a job w/o creating a job definition first - and wait to finish
ibmcloud ce jobrun submit --name job-doit2 --array-indices=1-${NUM} \
--image ${REGISTRY}/firstjob --wait
# Show the stats about the job
ibmcloud ce jobrun get --name job-doit2
# Now look at a view of the logs to make sure it worked
ibmcloud ce jobrun logs --instance job-doit2-1-0 | tee out
if ! grep "Hi from" out > /dev/null ; then
echo "Missing expected outout"
exit 1
fi
# Clean up
clean