-
Notifications
You must be signed in to change notification settings - Fork 1
/
execute-observation.sh
executable file
·189 lines (136 loc) · 4.8 KB
/
execute-observation.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#!/bin/bash
BASE_DIR=$(cd "$(dirname "$0")"; pwd)
. $BASE_DIR/config
. $BASE_DIR/common-functions.sh
###################
# functions
# stop petstore
function stop-jpetstore() {
information "Terminate running single-jpetstores ..."
for I in `docker ps -a| awk '{ print $1,$2 }' | grep "single-jpetstore" | awk '{ print $1 }'` ; do
docker stop $I
information "stoped a container"
docker rm $I
done
information "done"
}
######################
# parameter evaluation
if [ "$1" == "" ] ; then
export INTERACTIVE="yes"
export EXPERIMENT_ID="interactive"
information "Interactive mode no specialized workload driver"
else
export INTERACTIVE="no"
checkFile workload "$1"
WORKLOAD_PATH="$1"
export EXPERIMENT_ID=`basename "$WORKLOAD_PATH" | sed 's/\.yaml$//g'`
information "Automatic mode, workload driver is ${WORKLOAD_PATH}"
fi
export COLLECTOR_DATA_DIR="${DATA_DIR}/${EXPERIMENT_ID}"
###################################
# check setup
if [ "$INTERACTIVE" == "no" ] ; then
checkExecutable workload-runner $WORKLOAD_RUNNER
checkExecutable web-driver $WEB_DRIVER
checkFile log-configuration $BASE_DIR/log4j.cfg
fi
checkExecutable collector $COLLECTOR
checkExecutable workload-runner $WORKLOAD_RUNNER
####################
# main script
information "--------------------------------------------------------------------"
information "$EXPERIMENT_ID $WORKLOAD_CONFIGURATION"
information "--------------------------------------------------------------------"
##
# cleanup
stop-jpetstore
information "Cleanup collector..."
for I in `ps auxw | grep collector | grep java | awk '{ print $2 }'` ; do
information "stopping $I"
kill -TERM $I
sleep 2
kill -9 $I
done
information "done"
echo ""
information "Cleanup directories"
if [ -d "$COLLECTOR_DATA_DIR" ] ; then
rm -rf $COLLECTOR_DATA_DIR/*
else
mkdir -p "$COLLECTOR_DATA_DIR"
fi
##################
# start experiment
information "Deploying experiment..."
##
# collector
information "Start collector"
# configure collector
cat << EOF > collector.config
# common
kieker.monitoring.name=${EXPERIMENT_ID}
kieker.monitoring.hostname=
kieker.monitoring.metadata=true
# TCP collector
iobserve.service.reader=org.iobserve.service.source.MultipleConnectionTcpCompositeStage
org.iobserve.service.source.MultipleConnectionTcpCompositeStage.port=9876
org.iobserve.service.source.MultipleConnectionTcpCompositeStage.capacity=8192
# dump stage
kieker.monitoring.writer=kieker.monitoring.writer.filesystem.FileWriter
kieker.monitoring.writer.filesystem.FileWriter.customStoragePath=$COLLECTOR_DATA_DIR/
kieker.monitoring.writer.filesystem.FileWriter.charsetName=UTF-8
kieker.monitoring.writer.filesystem.FileWriter.maxEntriesInFile=25000
kieker.monitoring.writer.filesystem.FileWriter.maxLogSize=-1
kieker.monitoring.writer.filesystem.FileWriter.maxLogFiles=-1
kieker.monitoring.writer.filesystem.FileWriter.mapFileHandler=kieker.monitoring.writer.filesystem.TextMapFileHandler
kieker.monitoring.writer.filesystem.TextMapFileHandler.flush=true
kieker.monitoring.writer.filesystem.TextMapFileHandler.compression=kieker.monitoring.writer.filesystem.compression.NoneCompressionFilter
kieker.monitoring.writer.filesystem.FileWriter.logFilePoolHandler=kieker.monitoring.writer.filesystem.RotatingLogFilePoolHandler
kieker.monitoring.writer.filesystem.FileWriter.logStreamHandler=kieker.monitoring.writer.filesystem.TextLogStreamHandler
kieker.monitoring.writer.filesystem.FileWriter.flush=true
kieker.monitoring.writer.filesystem.FileWriter.bufferSize=81920
EOF
export COLLECTOR_OPTS=-Dlog4j.configuration=file:///$BASE_DIR/log4j.cfg
$COLLECTOR -c collector.config &
COLLECTOR_PID=$!
sleep 10
##
# jpetstore
information "Start jpetstore"
docker run -e LOGGER="${LOGGER}" --name 'single-service' -d single-jpetstore
# get IP address of the container
ID=`docker ps | grep 'single-service' | awk '{ print $1 }'`
SERVICE=`docker inspect $ID | grep '"IPAddress' | awk '{ print $2 }' | tail -1 | sed 's/^"\(.*\)",/\1/g'`
SERVICE_URL="http://$SERVICE:8080/jpetstore"
# wait for service coming up
information "Service URL is ${SERVICE_URL}"
information "Connection fails are expected until the service is available."
while ! curl -sSf ${SERVICE_URL} ; do
sleep 1
done
information "Service ready\n"
##
# workload
# 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"
sleep 10
fi
####
# end of experiment
information "Undeploying experiment."
# stop and remove jpetstore
stop-jpetstore
# finally stop the collector
kill -TERM ${COLLECTOR_PID}
rm collector.config
wait ${COLLECTOR_PID}
information "Experiment complete."
# end