forked from IBM/CodeEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·49 lines (37 loc) · 1.18 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:
# 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 jobrun delete -n j2a-job -f
ibmcloud ce app delete -n j2a-app -f
) > /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 j2a-app --min=1 --max=1 --image ${REGISTRY}/j2a-app
# Get metadata about the app for later use
URL=$(ibmcloud ce app get -n j2a-app -o url)
# Create/run the job, passing in the project/namespace - and wait to finish
ibmcloud ce jobrun submit -n j2a-job --ai=1-${COUNT} \
--image ${REGISTRY}/j2a-job --wait
# Check the app to see how many times it was hit
if ! [[ "Count: $((COUNT*10))" == "$(curl -fs $URL)" ]]; then
echo "Should be $((COUNT*10))"
# Show the logs for the job to see if it tells us why all messages didn't
# make it.
ibmcloud ce jobrun logs -n j2a-job
# And for completeness, show the logs for the app too, but should be empty
ibmcloud ce app logs -n j2a-app
exit 1
fi
# Clean up
clean