forked from IBM/CodeEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·52 lines (40 loc) · 1.09 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
#!/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 app delete -n anj-app -f
ibmcloud ce jobrun delete -n anj-job -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}
# First create an app based on our image
ibmcloud ce app create -n anj-app --image ${REGISTRY}/app-n-job
# Get the URL of the app
URL=$(ibmcloud ce app get -n anj-app -o url)
# And call it
curl -fs $URL | tee out
[[ "${PIPESTATUS[0]}" == "0" ]]
if ! grep "Hello from.*app" out > /dev/null ; then
echo "Unexpected output"
exit 1
fi
# And now use the same image as a batch job - and wait to finish
ibmcloud ce jobrun submit --name anj-job --ai=1-$NUM \
--image ${REGISTRY}/app-n-job --wait
ibmcloud ce jobrun logs --instance anj-job-1-0 | tee out
if ! grep "Hello from.*job" out > /dev/null ; then
echo "Missing expected outout"
exit 1
fi
# Clean up
clean