-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·88 lines (65 loc) · 1.59 KB
/
start.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
#!/usr/bin/env bash
GREEN=`tput setaf 2`
RESET=`tput sgr0`
query() {
date
echo "${GREEN}Querying${RESET}"
wget -qO - http://localhost:8080 & wget -qO - http://localhost:8080
}
sleeping() {
date
IDLE_TIME=$1
until [ $IDLE_TIME -lt 1 ]; do
let IDLE_TIME-=1
printf "${IDLE_TIME} "
sleep 1
done
echo ""
}
rebuildMongoNode() {
date
query
echo "${GREEN}Remove node $1 ${RESET}"
docker-compose stop mongodb$1 && docker-compose rm -f mongodb$1
sleeping 60
docker-compose exec mongodb$2 sh status.sh
query
echo "${GREEN}Add node $1 ${RESET}"
docker-compose up -d mongodb$1
sleeping 60
docker-compose exec mongodb$2 sh status.sh
query
}
docker-compose up -d --no-recreate
docker-compose ps
echo "${GREEN}Initialize cluster in T-5s${RESET}"
sleeping 5
docker-compose exec mongodb0 sh init.sh
echo "${GREEN}Test starts in T-20s${RESET}"
sleeping 20
docker-compose exec mongodb0 sh status.sh
echo "${GREEN}Testing ...${RESET}"
query
sleeping 5
rebuildMongoNode 2 1
rebuildMongoNode 1 0
rebuildMongoNode 0 2
date
echo "${GREEN}Cluster status by node 0${RESET}"
docker-compose exec mongodb0 sh status.sh
echo "${GREEN}Cluster status by node 1${RESET}"
docker-compose exec mongodb1 sh status.sh
echo "${GREEN}Cluster status by node 2${RESET}"
docker-compose exec mongodb2 sh status.sh
query
query
query
AFTER_IDLE_TIME=900
echo "${GREEN}Starting after test queries every 5s.${RESET}"
until [ $AFTER_IDLE_TIME -lt 1 ]; do
date
let AFTER_IDLE_TIME-=5
printf "${AFTER_IDLE_TIME} "
query
sleep 5
done