-
Notifications
You must be signed in to change notification settings - Fork 0
/
execute-jpetstore-with-workload.sh
executable file
·131 lines (96 loc) · 3.01 KB
/
execute-jpetstore-with-workload.sh
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
125
126
127
128
129
130
131
#!/bin/bash
# Execute a distributed JPetStore with docker locally.
# Utilize one workload model to drive the JPetStore or
# allow interactive mode.
# 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
# stopping docker container
function stopDocker() {
information "Stopping existing distributed jpetstore instances ..."
docker stop frontend
docker stop order
docker stop catalog
docker stop account
docker rm frontend
docker rm order
docker rm catalog
docker rm account
docker network rm jpetstore-net
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
DOCKER=`which docker`
CURL=`which curl`
checkExecutable docker "$DOCKER"
checkExecutable docker "$CURL"
if [ "$INTERACTIVE" == "no" ] ; then
checkExecutable workload-runner $WORKLOAD_RUNNER
if [ "$WEB_DRIVER" != "" ] ; then
checkExecutable web-driver $WEB_DRIVER
fi
checkFile log-configuration $BASE_DIR/log4j.cfg
fi
###################################
# check if no leftovers are running
# stop docker
stopDocker
###################################
# starting
# jpetstore
information "Start jpetstore"
docker network create --driver bridge jpetstore-net
docker run -e LOGGER=$LOGGER -d --name account --network=jpetstore-net jpetstore-account-service
docker run -e LOGGER=$LOGGER -d --name order --network=jpetstore-net jpetstore-order-service
docker run -e LOGGER=$LOGGER -d --name catalog --network=jpetstore-net jpetstore-catalog-service
docker run -e LOGGER=$LOGGER -d --name frontend --network=jpetstore-net jpetstore-frontend-service
ID=`docker ps | grep 'frontend' | awk '{ print $1 }'`
FRONTEND=`docker inspect $ID | grep '"IPAddress' | awk '{ print $2 }' | tail -1 | sed 's/^"\(.*\)",/\1/g'`
SERVICE_URL="http://$FRONTEND:8080/jpetstore-frontend"
information "Service URL $SERVICE_URL"
while ! curl -sSf $SERVICE_URL 2> /dev/null > /dev/null ; do
echo "waiting 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
if [ "$WEB_DRIVER" != "" ] ; then
$WORKLOAD_RUNNER -c $WORKLOAD_PATH -u "$SERVICE_URL" -d "$WEB_DRIVER"
else
$WORKLOAD_RUNNER -c $WORKLOAD_PATH -u "$SERVICE_URL"
fi
sleep 10
fi
###################################
# shutdown
# shutdown jpetstore
stopDocker
information "Done"
# end