forked from IBM/CodeEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·63 lines (50 loc) · 1.64 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
59
60
61
62
63
#!/bin/bash
# Env Vars:
# NUM: number of instances of the job to run
# REGISTRY: name of the image registry/namespace to get the images
# REGION: the IBM Cloud Region in which we're running
# Clean up previous run
function clean() {
set +ex
echo Cleaning...
(
ibmcloud ce job delete -n bj-job -f
ibmcloud ce jobrun delete -n bj-jobrun -f
ibmcloud resource service-instance-delete bj-es -f --recursive
ibmcloud secret delete -n secret-ibm-cloud-operator -f
ibmcloud configmap delete -n config-ibm-cloud-operator -f
rm -f out
) > /dev/null 2>&1
}
clean
[[ "$1" == "clean" ]] && exit 0
set -ex
export REGISTRY=${REGISTRY:-icr.io/codeengine}
export NUM=${COUNT:-10}
export REGION=$(ibmcloud target | awk '/Region:/{ print $2 }') # Grab region
# Create an instance of Event Streams
ibmcloud resource service-instance-create bj-es messagehub lite \
$REGION
# Wait for the service instance to be ready
set +x
echo "Waiting for Event Streams to become available..."
while ! ibmcloud resource service-instance bj-es | grep "State.*active" ; do
sleep 5
done > /dev/null
echo
set -x
# Create a Job definition
ibmcloud ce job create --name bj-job --array-indices=1-${NUM} \
--image ${REGISTRY}/bind-job
# Bind the service instance to the job
ibmcloud ce job bind --name bj-job --service-instance bj-es
# Now submit the job using that definition -- wait to finish
ibmcloud ce jobrun submit --name myrun --job bj-job --wait
# Now look at a view of the logs to make sure it worked
ibmcloud ce jobrun logs --instance myrun-1-0 | tee out
if ! grep CE_SERVICES out > /dev/null ; then
echo "Missing CE_SERVICES in App's env vars"
exit 1
fi
# Clean up
clean