forked from IBM/CodeEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·58 lines (45 loc) · 1.48 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
50
51
52
53
54
55
56
57
58
#!/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 tester-j -f
ibmcloud ce jobrun delete -n tester-doit -f
ibmcloud ce jobrun delete -n tester-doit2 -f
rm -f out
) > /dev/null 2>&1
}
clean
[[ "$1" == "clean" ]] && exit 0
set -ex
export REGISTRY=${REGISTRY:-ibmcom}
export NUM=${NUM:-10}
# Create a Job definition that will run 10 instances
ibmcloud ce job create --name tester-j --array-indices=1-${NUM} \
--image ${REGISTRY}/testjob
# Now submit the job using that definition - and wait for it to finish
ibmcloud ce jobrun submit --name tester-doit --job tester-j --wait
# Now look at a view of the logs to make sure it worked
ibmcloud ce jobrun logs --instance tester-doit-1-0 | tee out
# Verify it ran ok
if ! grep "Hello World" out > /dev/null ; then
echo "Missing expected outout"
exit 1
fi
# Now submit a job w/o creating a job definition first - and wait to finish
ibmcloud ce jobrun submit --name tester-doit2 --array-indices=1-${NUM} \
--image ${REGISTRY}/testjob --env MSG="Hi there" --wait
# Show the stats about the job
ibmcloud ce jobrun get --name tester-doit2
# Now look at a view of the logs to make sure it worked
ibmcloud ce jobrun logs --instance tester-doit2-1-0 | tee out
if ! grep "Hi there" out > /dev/null ; then
echo "Missing expected outout"
exit 1
fi
# Clean up
clean