forked from IBM/CodeEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·44 lines (34 loc) · 1.19 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
#!/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 ws-server -f
ibmcloud ce jobrun delete -n ws-client -f
rm -f out
) > /dev/null 2>&1
}
clean
[[ "$1" == "clean" ]] && exit 0
set -ex
export REGISTRY=${REGISTRY:-icr.io/codeengine}
# Create the websocket server app
ibmcloud ce app create -n ws-server --image ${REGISTRY}/ws-server
# Get the URL of the app for later use
URL=$(ibmcloud ce app get -n ws-server -o url)
# Now submit a job to run the client, passing in the URL to the App as an arg.
# Change the protocol on the App from https to wss (secure websocket).
# And wait for the job to finish.
ibmcloud ce jobrun submit -n ws-client --image ${REGISTRY}/ws-client \
--arg ${URL/https/wss} --wait
# Get the overall status of the job and verify that the client exited properly
ibmcloud ce jobrun get -n ws-client | tee out
grep "client-0-0 .* Succeeded" out > /dev/null
# Check the client logs to ensure it got the right response from the server
ibmcloud ce jobrun logs -n ws-client | tee out
grep "Client read.*0987654321" out > /dev/null
# Clean up
clean