-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecute-kube-jpetstore.sh
More file actions
executable file
·124 lines (91 loc) · 2.82 KB
/
Copy pathexecute-kube-jpetstore.sh
File metadata and controls
executable file
·124 lines (91 loc) · 2.82 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
# parameter
# $1 = workload driver configuration (optional)
BASE_DIR=$(cd "$(dirname "$0")"; pwd)
if [ -f $BASE_DIR/config ] ; then
. $BASE_DIR/config
else
echo "Missing configuration"
exit 1
fi
. $BASE_DIR/common-functions.sh
#############################################
# common functions
# stop kube deployment
function stopKube() {
information "Stopping existing distributed jpetstore instances ..."
kubectl delete --grace-period=60 service/jpetstore
for I in frontend account catalog order ; do
kubectl delete --grace-period=120 pods/$I
done
information "Done"
}
###################################
# check parameters
if [ "$1" == "" ] ; then
export INTERACTIVE="yes"
information "Interactive mode no specialized workload driver"
else
export INTERACTIVE="no"
checkFile workload "$1"
WORKLOAD_PATH="$1"
information "Automatic mode, workload driver is ${WORKLOAD_PATH}"
fi
###################################
# check setup
if [ "$INTERACTIVE" == "no" ] ; then
checkExecutable workload-runner $WORKLOAD_RUNNER
checkExecutable wbe-driver $WEB_DRIVER
checkFile log-configuration $BASE_DIR/log4j.cfg
fi
checkFile jpetstore-configuration $KUBERNETES_DIR/jpetstore.yaml
checkFile usa-configuration $KUBERNETES_DIR/usa.yaml
###################################
# check if no leftovers are running
###################################
# starting
# jpetstore
information "Start jpetstore"
# initial deployment
export LOCATION="GERMANY"
cat $KUBERNETES_DIR/jpetstore.yaml | sed "s/%LOGGER%/$LOGGER/g" | sed "s%LOCATION%/$LOCATION" > start.yaml
cat $KUBERNETES_DIR/usa.yaml | sed "s/%LOGGER%/$LOGGER/g" | sed "s%LOCATION%/$LOCATION" > additional.yaml
kubectl create -f start.yaml
rm start.yaml
# check if service is running
FRONTEND=""
while [ "$FRONTEND" == "" ] ; do
ID=`kubectl get pods | grep frontend | awk '{ print $1 }'`
FRONTEND=`kubectl describe pods/$ID | grep "IP:" | awk '{ print $2 }'`
done
SERVICE_URL="http://$FRONTEND:8080/jpetstore-frontend"
information "Service URL $SERVICE_URL"
while ! curl -sSf $SERVICE_URL 2> /dev/null > /dev/null ; do
echo "wait for service coming up..."
sleep 1
done
# check workload
if [ "$INTERACTIVE" == "yes" ] ; then
information "You may now use JPetStore"
information "Press Enter to stop the service"
read
else
information "Running workload driver"
export SELENIUM_EXPERIMENT_WORKLOADS_OPTS=-Dlog4j.configuration=file:///$BASE_DIR/log4j.cfg
$WORKLOAD_RUNNER -c $WORKLOAD_PATH -u "$SERVICE_URL" -d "$WEB_DRIVER" &
WORKLOAD_RUNNER_PID=$!
sleep 10
fi
# delay
information "Wait for deployment change"
sleep 30
# modification
information "Perform deployment change"
kubectl replace -f additional.yaml --force
# wait for scenario end
information "Wait for scenario end"
wait $WORKLOAD_RUNNER_PID
# shutdown jpetstore
stopKube
information "Done."
# end