forked from Percona-QA/percona-qa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpmm-testsuite.sh
274 lines (227 loc) · 6.37 KB
/
pmm-testsuite.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#!/usr/bin/env bats
WORKDIR="${PWD}"
DIRNAME="$BATS_TEST_DIRNAME"
DIRNAME=$(dirname "$0")
# pmm-framework.sh functions
function pmm_framework_setup() {
${DIRNAME}/pmm-framework.sh --setup
}
function pmm_framework_add_clients() {
${DIRNAME}/pmm-framework.sh --addclient=$1,$2 --download
}
function pmm_wipe_all() {
${DIRNAME}/pmm-framework.sh --wipe
}
function pmm_wipe_clients() {
${DIRNAME}/pmm-framework.sh --wipe-clients
}
function pmm_wipe_server() {
${DIRNAME}/pmm-framework.sh --wipe-server
}
# functions for some env setup
function setup_local_consul_exporter() {
echo "Setting up consul_exporter"
FILE_NAME="consul_exporter-0.3.0.linux-amd64.tar.gz"
if [ -f ${FILE_NAME} ]; then
echo "File exists"
else
wget https://github.com/prometheus/consul_exporter/releases/download/v0.3.0/consul_exporter-0.3.0.linux-amd64.tar.gz
tar -zxpf consul_exporter-0.3.0.linux-amd64.tar.gz
fi
IP_ADDR=$(ip route get 1 | awk '{print $NF;exit}')
echo "Running consul_exporter"
echo "IMPORTANT: pmm-server docker should be run with additional -p 8500:8500"
./consul_exporter-0.3.0.linux-amd64/consul_exporter -consul.server http://${IP_ADDR}:8500 > /dev/null 2>&1 &
}
# functions for bats calling
function run_linux_metrics_tests() {
if [[ $tap == 1 ]] ; then
bats --tap $DIRNAME/linux-metrics.bats
else
bats $DIRNAME/linux-metrics.bats
fi
}
function run_generic_tests() {
if [[ $tap == 1 ]] ; then
bats --tap ${DIRNAME}/generic-tests.bats
else
bats ${DIRNAME}/generic-tests.bats
fi
}
function run_ps_specific_tests() {
if [[ $tap == 1 ]] ; then
bats --tap ${DIRNAME}/ps-specific-tests.bats
else
bats ${DIRNAME}/ps-specific-tests.bats
fi
}
function run_postgresql_specific_tests() {
if [[ $tap == 1 ]] ; then
bats --tap ${DIRNAME}/pgsql-specific-tests.bats
else
bats ${DIRNAME}/pgsql-specific-tests.bats
fi
}
function run_pxc_specific_tests() {
if [[ $tap == 1 ]] ; then
bats --tap ${DIRNAME}/pxc-specific-tests.bats
else
bats ${DIRNAME}/pxc-specific-tests.bats
fi
}
function run_mongodb_specific_tests() {
if [[ $tap == 1 ]] ; then
bats --tap ${DIRNAME}/mongodb-tests.bats
else
bats ${DIRNAME}/mongodb-tests.bats
fi
}
function run_proxysql_tests() {
if [[ $tap == 1 ]] ; then
bats --tap ${DIRNAME}/proxysql-tests.bats
else
bats ${DIRNAME}/proxysql-tests.bats
fi
}
function run_external_exporters_tests() {
if [[ $tap == 1 ]] ; then
bats --tap ${DIRNAME}/external_exporters_tests.bats
else
bats ${DIRNAME}/external_exporters_tests.bats
fi
}
function run_pmm_summary() {
if [[ $tap == 1 ]] ; then
bats --tap ${DIRNAME}/pmm-summary.bats
else
bats ${DIRNAME}/pmm-summary.bats
fi
}
function run_pmm_default_memory_check() {
if [[ $tap == 1 ]] ; then
bats --tap ${DIRNAME}/pmm-default-memory-check.bats
else
bats ${DIRNAME}/pmm-default-memory-check.bats
fi
}
function run_pmm_memory_check() {
if [[ $tap == 1 ]] ; then
bats --tap ${DIRNAME}/pmm-memory-check.bats
else
bats ${DIRNAME}/pmm-memory-check.bats
fi
}
function run_pmm_metrics_memory_check() {
if [[ $tap == 1 ]] ; then
bats --tap ${DIRNAME}/pmm-metrics-memory-check.bats
else
bats ${DIRNAME}/pmm-metrics-memory-check.bats
fi
}
function run_pmm_slow_log_rotation_check() {
if [[ $tap == 1 ]] ; then
bats --tap ${DIRNAME}/pmm-slow-log-rotation-tests.bats
else
bats ${DIRNAME}/pmm-slow-log-rotation-tests.bats
fi
}
# Additional functions
function run_create_table() {
bash ${DIRNAME}/create_table.sh $1 $2
}
function run_populate_table() {
bash ${DIRNAME}/populate_table.sh $1 $2 $3
}
# Setting up the PMM using pmm_framework_setup() here
# if [[ $setup == "1" ]]; then
# # Check if both options are passed.
# if [[ $pmm_server_memory == "1" && $pmm_docker_memory == "1" ]]; then
# echo "Please use one of the options to limit the memory!"
# exit 1
# fi
# # Pass values to setup script
# if [[ $pmm_server_memory == "1" ]]; then
# METRICS_MEMORY="--pmm-server-memory=768000"
# pmm_framework_setup $METRICS_MEMORY
# elif [[ $pmm_docker_memory == "1" ]]; then
# MEMORY="--pmm-docker-memory=2147483648"
# pmm_framework_setup $MEMORY
# else
# pmm_framework_setup ""
# fi
# fi
# Running tests
echo "Wipe clients"
pmm_wipe_clients
echo "Adding clients"
pmm_framework_add_clients $instance_t $instance_c
if [[ $instance_t != "mo" ]] ; then
echo "Running linux metrics tests"
run_linux_metrics_tests
fi
echo "Running generic tests"
run_generic_tests
echo "Running default memory consumption check"
if [[ -z $pmm_server_memory && -z $pmm_docker_memory ]]; then
run_pmm_default_memory_check
elif [[ $pmm_server_memory != "1" && $pmm_docker_memory != "1" ]]; then
run_pmm_default_memory_check
else
echo "OK - Skipped"
fi
echo "Running memory consumption check for --memory option"
if [[ $pmm_docker_memory == "1" ]]; then
run_pmm_memory_check
else
echo "OK - Skipped"
fi
echo "Running memory consumption check for -e METRICS_MEMORY option"
if [[ $pmm_server_memory == "1" ]]; then
run_pmm_metrics_memory_check
else
echo "OK - Skipped"
fi
echo "Running Slow Log rotation tests [PMM-2432]"
run_pmm_slow_log_rotation_check
echo "Running external exporters tests"
setup_local_consul_exporter
run_external_exporters_tests
if [[ $stress == "1" && $table_c != "0" && -z $table_size ]] ; then
echo "WARN: Running stress tests; creating empty tables"
run_create_table $instance_t $table_c
elif [[ $stress == "1" && $table_c != "0" && $table_size != "0" ]] ; then
echo "WARN: Running stress tests; creating tables and inserting using sysbench"
run_populate_table $instance_t $table_c $table_size
else
echo "Skipping stress test!"
fi
if [[ $instance_t == "mo" ]] ; then
echo "Running MongoDB specific tests"
run_mongodb_specific_tests
fi
if [[ $instance_t == "ps" ]]; then
echo "Running PS specific tests"
run_ps_specific_tests
fi
if [[ $instance_t == "pgsql" ]]; then
echo "Running Postgre SQL specific tests"
run_postgresql_specific_tests
fi
if [[ $instance_t == "pxc" ]]; then
echo "Running PXC specific tests"
run_pxc_specific_tests
fi
echo "Validate Summary Checks"
run_pmm_summary
# ProxySQL
# @test "Running ProxySQL tests" {
# if [[ $instance_t != "pxc" ]] ; then
# skip "Skipping ProxySQL specific tests!"
# fi
# run_proxysql_tests
# echo ${output}
# [ "$status" -eq 0 ]
# }
# ProxySQL
echo "Wipe clients"
pmm_wipe_clients