-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy pathrun
executable file
·47 lines (36 loc) · 1.1 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
#!/bin/bash
# Env Vars:
# COUNT: 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 a2j-job -f
ibmcloud ce app delete -n a2j-app -f
rm -f out
) > /dev/null 2>&1
}
clean
[[ "$1" == "clean" ]] && exit 0
set -ex
export REGISTRY=${REGISTRY:-icr.io/codeengine}
export COUNT=${COUNT:-50}
# Create the app
ibmcloud ce app create -n a2j-app --cpu .125 --memory 0.25G --image ${REGISTRY}/a2j-app
# Get metadata about the app for later use
URL=$(ibmcloud ce app get -n a2j-app -o url)
# Create the job definition
ibmcloud ce job create -n a2j-job --ai=1-${COUNT} --cpu .125 --memory 0.25G --image ${REGISTRY}/a2j-job
# Now, curl the app and see if it creates the job
curl -fs ${URL}/a2j-job -X PUT | tee out
[[ "${PIPESTATUS[0]}" == "0" ]]
jobrun=$(cat out)
while ! ibmcloud ce jobrun get -n ${jobrun} | grep "Succeeded.*${COUNT}" ; do
sleep 2
done
# Verify job ran ok
ibmcloud ce jobrun logs -i ${jobrun}-${COUNT}-0 | grep "JOB_INDEX.*${COUNT}"
# Clean up
clean