forked from IBM/CodeEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·43 lines (34 loc) · 1.05 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
#!/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 frontend -f
ibmcloud ce app delete -n backend -f
rm -f out
) > /dev/null 2>&1
}
clean
[[ "$1" == "clean" ]] && exit 0
set -ex
export REGISTRY=${REGISTRY:-ibmcom}
# Create our frontend and backend apps.
# Note that the "backend" app is "cluster local", meaning that it does
# not get assign a public facing URL. Only the "frontend" app can access it
ibmcloud ce app create -n backend --image ${REGISTRY}/priv-back --cluster-local
ibmcloud ce app create -n frontend --image ${REGISTRY}/priv-front
# Get the URL of the app for later use
URL=$(ibmcloud ce app get -n frontend -o url)
# Now call it (stop if curl fails)
curl -fsw "%{http_code}\n" $URL | tee out
[[ "${PIPESTATUS[0]}" == "0" ]]
# Verify the frontend got the right output from the backend
if ! grep "The time is now" out > /dev/null ; then
echo "Missing expected output"
exit 1
fi
# Clean up
clean