forked from IBM/CodeEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·50 lines (40 loc) · 1.07 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
#!/bin/bash
# Env Vars:
# 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 helloworld -f
ibmcloud ce jobrun delete -n hi-job -f
rm -f out
) > /dev/null 2>&1
}
clean
[[ "$1" == "clean" ]] && exit 0
set -ex
export REGISTRY=${REGISTRY:-icr.io/codeengine}
# Create the app
ibmcloud ce app create -n helloworld --image ${REGISTRY}/helloworld
# Get the URL of the app for later use
URL=$(ibmcloud ce app get -n helloworld -o url)
# Now call it
curl -w "\n%{http_code}\n" -fs $URL | tee out
if ! [[ "${PIPESTATUS[0]}" == "0" ]] ; then
echo "Expected zero return code"
cat out
exit 1
fi
curl -w "\n%{http_code}\n" -fs $URL -d "Hi" -o out
if [[ $(cat out) != "Hi" ]]; then
echo "Unexpected output"
cat out
exit 1
fi
# Since the image can be used as a job too, test it
ibmcloud ce jobrun submit --name hi-job --ai=1 --image ${REGISTRY}/helloworld \
--wait
ibmcloud ce jobrun logs -n hi-job | tee out | grep "Hello from.*job" || exit 1
# Clean up
clean