-
Notifications
You must be signed in to change notification settings - Fork 0
/
common-script
58 lines (48 loc) · 1.52 KB
/
common-script
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
#!/usr/bin/env bash
set -eux
# only for ubuntu machines
TARGETS=${TARGETS:-1}
PORTS=${PORTS:-29090}
COUNT=${COUNT:-3}
SPEED=${SPEED:-15000}
READ=${READ:-false}
PROMETHEUS=${PROMETHEUS:-}
READ_PERIOD=${READ_PERIOD:-15000}
JOB_NAME=${JOB_NAME:-stress}
# install python
apt-get update
apt-get install -y python git
# update pip
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
# install docker
apt-get update
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
apt-add-repository 'deb https://apt.dockerproject.org/repo ubuntu-xenial main'
apt-get update
apt-cache policy docker-engine
apt-get install -y docker-engine
#add user to docker
sudo usermod -aG docker $(whoami)
# clone stress-tool
git clone https://github.com/prazumovsky/prom-stress-tool
cd prom-stress-tool
# parse ports to array
IFS=',' read -a arrports <<<"$PORTS"
docker build . -t stress
for i in `seq 0 $((TARGETS - 1))`;
do
docker run -p ${arrports[i]}:${arrports[i]} \
--name target-$i \
-e PORT=${arrports[i]} \
-e COUNT=$COUNT \
-e SPEED=$SPEED \
-d stress
if [ $READ = true ]; then
docker run --name reader-$i -e READ=$READ \
-e PROMETHEUS=$PROMETHEUS \
-e JOB_NAME=$JOB_NAME \
-e INSTANCE=~\"^.+${arrports[i]}$\" \
-e READ_PERIOD=$READ_PERIOD -d stress;
fi
done