-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbenchmark.sh
executable file
·93 lines (71 loc) · 2.39 KB
/
benchmark.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
#!/bin/bash
set -e
export SCRIPTPATH=$(realpath $(dirname ${BASH_SOURCE[0]}))
export VERSION=latest
EASEAGENTDIR=${SCRIPTPATH}/easeagent/downloaded
EASEAGENTFILE=${EASEAGENTDIR}/easeagent-${VERSION}.jar
EASEAGENT_INUSE=${EASEAGENTDIR}/easeagent.jar
source ${SCRIPTPATH}/env.sh
export JMX_AGENT_FILE="/easeagent-volume/benchmark/jmx_prometheus_javaagent-0.16.2-SNAPSHOT.jar"
export JMX_AGENT_CONFIG="/easeagent-volume/benchmark/jmx_prometheus_config.yml"
export EASEAGENT_CONFIG_FILE=${EASEAGENT_CONFIG_FILE:-agent_benchmark.properties}
export PROMETHEUS_CONFIG_FILE=${PROMETHEUS_CONFIG_FILE:-prometheus_benchmark.yaml}
COMPOSER=${COMPOSER:-benchmark-swarm-composer}
DOCKERCOMPOSEFILE=${SCRIPTPATH}/${COMPOSER}.yml
> ${DOCKERCOMPOSEFILE}
function generate_specs() {
envsubst < ${SCRIPTPATH}/templ/${COMPOSER}.yml.templ > ${DOCKERCOMPOSEFILE}
}
EASEAGENT=${EASEAGENT-true}
function prepare() {
mkdir -p ${EASEAGENTDIR}
if [ "$EASEAGENT" == "true" ]; then
if [ ! -f ${EASEAGENTFILE} ]; then
echo "easeagent-${VERSION}.jar file can't be found. Downloading from github release page..."
if [ "$VERSION" == "latest" ]; then
curl -sLk https://github.com/megaease/easeagent/releases/latest/download/easeagent.jar -o ${EASEAGENTFILE}
else
curl -sLk https://github.com/megaease/easeagent/releases/download/${VERSION}/easeagent.jar -o ${EASEAGENTFILE}
fi
echo "The file was downloaded succeed"
fi
export JAVA_AGENT_CONFIG="-javaagent:/easeagent-volume/downloaded/easeagent.jar"
cp -f ${EASEAGENTFILE} ${EASEAGENT_INUSE}
echo "with agent:${DOCKERCOMPOSEFILE}"
else
echo "without agent:${DOCKERCOMPOSEFILE}"
export JAVA_AGENT_CONFIG="-Deaseagent.enable=false"
fi
}
function start() {
prepare
generate_specs
#docker stack deploy --compose-file ${DOCKERCOMPOSEFILE} petclinc
docker-compose -f ${DOCKERCOMPOSEFILE} up -d
echo "The stack was provisioned successfully."
}
function stop() {
generate_specs
docker-compose -f ${DOCKERCOMPOSEFILE} down
#docker stack rm petclinc
}
if [ $# -ne 1 ];then
echo "usage: ${BASH_SOURCE[0]} <start [compoment(config/gateway/modules)]/stop [compoment(config/gateway/modules)>"
exit 1
fi
case $1 in
"start")
start
;;
"stop")
stop
;;
"generate")
prepare
generate_specs
;;
*)
echo "usage: ${BASH_SOURCE[0]} <start/stop/generate>"
exit 1
;;
esac