forked from Percona-QA/percona-qa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpxc-sst-test.sh
executable file
·487 lines (401 loc) · 12.8 KB
/
pxc-sst-test.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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
#!/bin/bash -ue
# Created by Raghavendra Prabhu
# Updated by Ramesh Sivaraman, Percona LLC
# This script will test the data consistency between Percona XtraDB Cluster nodes.
# Dispay script usage details
usage () {
echo "Usage:"
echo " pxc-correctness-testing.sh --workdir=PATH"
echo ""
echo "Additional options:"
echo " -w, --workdir=PATH Specify work directory"
echo " -b, --build-number=NUMBER Specify work build directory"
echo " -x, --xb-version=VERSION Specify xtrabackup version"
echo " -k, --with-keyring-plugin Run the script with keyring-file plugin"
echo " -e, --with-binlog-encryption Run the script with binary log encryption feature"
}
# Check if we have a functional getopt(1)
if ! getopt --test
then
go_out="$(getopt --options=w:b:x:keh --longoptions=workdir:,build-number:,xb-version:,with-keyring-plugin,with-binlog-encryption,help \
--name="$(basename "$0")" -- "$@")"
test $? -eq 0 || exit 1
eval set -- "$go_out"
fi
if [[ $go_out == " --" ]];then
usage
exit 1
fi
for arg
do
case "$arg" in
-- ) shift; break;;
-w | --workdir )
export WORKDIR="$2"
if [[ ! -d "$WORKDIR" ]]; then
echo "ERROR: Workdir ($WORKDIR) directory does not exist. Terminating!"
exit 1
fi
shift 2
;;
-b | --build-number )
export BUILD_NUMBER="$2"
shift 2
;;
-e | --with-binlog-encryption )
shift
export BINLOG_ENCRYPTION=1
;;
-k | --with-keyring-plugin )
shift
export KEYRING_PLUGIN=1
;;
-x | --xb-version )
export XB_VERSION="$2"
shift 2
;;
-h | --help )
usage
exit 0
;;
esac
done
#Format version string (thanks to wsrep_sst_xtrabackup-v2)
normalize_version(){
local major=0
local minor=0
local patch=0
# Only parses purely numeric version numbers, 1.2.3
# Everything after the first three values are ignored
if [[ $1 =~ ^([0-9]+)\.([0-9]+)\.?([0-9]*)([\.0-9])*$ ]]; then
major=${BASH_REMATCH[1]}
minor=${BASH_REMATCH[2]}
patch=${BASH_REMATCH[3]}
fi
printf %02d%02d%02d $major $minor $patch
}
#Version comparison script (thanks to wsrep_sst_xtrabackup-v2)
check_for_version()
{
local local_version_str="$( normalize_version $1 )"
local required_version_str="$( normalize_version $2 )"
if [[ "$local_version_str" < "$required_version_str" ]]; then
return 1
else
return 0
fi
}
set +e
echo "Killing existing mysqld"
pgrep -f mysqld
pkill -f mysqld
sleep 10
pgrep mysqld || pkill -9 -f mysqld
set -e
sleep 5
# generic variables
if [[ -z ${WORKDIR:-} ]]; then
export WORKDIR=${PWD}
fi
ROOT_FS=$WORKDIR
if [[ -z ${XB_VERSION:-} ]]; then
export XB_VERSION=2.4
fi
if [ -z ${BUILD_NUMBER:-} ]; then
BUILD_NUMBER=1001
fi
if [[ ${KEYRING_PLUGIN:-} -eq 1 ]]; then
export EXTRA_ENCRIPTION_OPTIONS="--early-plugin-load=keyring_file.so --keyring_file_data=keyring"
fi
if [[ ${BINLOG_ENCRYPTION:-} -eq 1 ]];then
if [[ -z ${KEYRING_PLUGIN:-} ]]; then
export EXTRA_ENCRIPTION_OPTIONS="--early-plugin-load=keyring_file.so --keyring_file_data=keyring"
fi
export EXTRA_ENCRIPTION_OPTIONS="$EXTRA_ENCRIPTION_OPTIONS --encrypt_binlog --master_verify_checksum=on --binlog_checksum=crc32 --innodb_encrypt_tables=ON"
fi
cd $WORKDIR
SCRIPT_PWD=$(cd `dirname $0` && pwd)
FAILEDTESTS=""
DISTESTS=""
GVER="galera${GALERA_VER:-2}"
count=$(ls -1ct Percona-XtraDB-Cluster*.tar.gz | wc -l)
if [[ $count -gt 1 ]];then
for dirs in `ls -1ct Percona-XtraDB-Cluster*.tar.gz | tail -n +2`;do
rm -rf $dirs
done
fi
echo "Removing older core files, if any"
rm -f ${WORKDIR}/**/*core*
echo "Removing older directories"
find . -maxdepth 1 -type d -mtime +10 -exec rm -rf {} \+
#Check PXC binary tar ball
PXC_TAR=`ls -1td ?ercona-?tra??-?luster* 2>/dev/null | grep ".tar" | head -n1`
if [[ ! -z $PXC_TAR ]];then
tar -xzf $PXC_TAR
PXCBASE=`ls -1td ?ercona-?tra??-?luster* 2>/dev/null | grep -v ".tar" | head -n1`
export PATH="$ROOT_FS/$PXCBASE/bin:$PATH"
else
PXCBASE=`ls -1td ?ercona-?tra??-?luster* 2>/dev/null | grep -v ".tar" | head -n1`
if [[ -z $PXCBASE ]] ; then
echoit "ERROR! Could not find PXC base directory."
exit 1
else
export PATH="$ROOT_FS/$PXCBASE/bin:$PATH"
fi
fi
BUILD_WIPE=$[ ${BUILD_NUMBER} - 5 ]
if [ -d ${BUILD_WIPE} ]; then rm -Rf ${BUILD_WIPE}; fi
mkdir ${BUILD_NUMBER}
export ROOT_FS="$WORKDIR/${BUILD_NUMBER}"
MYSQL_BASEDIR="${ROOT_FS}/$PXCBASE"
declare MYSQL_VERSION=$(${MYSQL_BASEDIR}/bin/mysqld --version 2>&1 | grep -oe '[0-9]\.[0-9][\.0-9]*' | head -n1)
if ! check_for_version $MYSQL_VERSION "8.0.0" ; then
#Check PXB binary tar ball
PXB_TAR=`ls -1td ?ercona-?trabackup* 2>/dev/null | grep ".tar" | head -n1`
if [[ ! -z $PXB_TAR ]];then
tar -xzf $PXB_TAR
PXBBASE=`ls -1td ?ercona-?trabackup* 2>/dev/null | grep -v ".tar" | head -n1`
export PATH="$ROOT_FS/$PXBBASE/bin:$PATH"
else
PXBBASE=`ls -1td ?ercona-?trabackup* 2>/dev/null | grep -v ".tar" | head -n1`
if [[ -z $PXBBASE ]] ; then
echoit "ERROR! Could not find PXB base directory."
exit 1
else
export PATH="$ROOT_FS/$PXBBASE/bin:$PATH"
fi
fi
fi
mv $PXCBASE $ROOT_FS/
if ! check_for_version $MYSQL_VERSION "8.0.0" ; then
mv $PXBBASE $ROOT_FS/
fi
[ -e "qpress" ] && mv qpress $ROOT_FS/
rm -rf /tmp/blog1 /tmp/blog2 || true
mkdir -p /tmp/blog1 /tmp/blog2
touch /tmp/blog1/TESTFILE
touch /tmp/blog2/TESTFILE
#rm *.tar.gz
cd ${BUILD_NUMBER}
mkdir -p $ROOT_FS/tmp
export XB_TESTDIR="${MYSQL_BASEDIR}/percona-xtradb-cluster-tests/sst"
#export XB_TESTDIR="$ROOT_FS/$BBASE/share/percona-xtrabackup-test/"
#export XB_TESTDIR="${SCRIPT_PWD}/percona-xtradb-cluster-tests/sst"
trap "cp -R $XB_TESTDIR/results $WORKDIR/results-${BUILD_NUMBER} && tar czf $WORKDIR/results-${BUILD_NUMBER}.tar.gz $WORKDIR/results-${BUILD_NUMBER} " EXIT KILL
cp -R $XB_TESTDIR/certs /tmp/
#cp $MYSQL_BASEDIR/lib/$GVER/libgalera_smm.so $MYSQL_BASEDIR/lib/
echo "Workdir: $ROOT_FS"
echo "Basedir: $MYSQL_BASEDIR"
cd $XB_TESTDIR
echo "PATH $PATH"
echo "XB_TESTDIR $XB_TESTDIR"
if [[ -n ${SST_DEBUG:-} && $SST_DEBUG == '2' ]];then
./run.sh -d $MYSQL_BASEDIR -t t/xb_galera_sst.sh
elif [[ -n ${SST_DEBUG:-} && $SST_DEBUG == '30' ]];then
./run.sh -g -d $MYSQL_BASEDIR -t t/xb_galera_sst.sh
else
./run.sh -d $MYSQL_BASEDIR -t t/xb_galera_sst.sh
fi
#exit
if [[ -n ${SST_DEBUG:-} ]];then
set -x
fi
echo "Running advanced tests"
NUMTESTS=$(ls $XB_TESTDIR/conf/conf* | wc -l)
NUMTESTS=$(( NUMTESTS/2 ))
if [[ -n ${SST_DEBUG:-} && $SST_DEBUG == '2' ]];then
sed -i -e '2 i\
set -x' $MYSQL_BASEDIR/bin/wsrep_sst_xtrabackup
fi
for tn in `seq 1 $NUMTESTS`; do
export CONF="conf${tn}"
t=$(head -1 $XB_TESTDIR/conf/conf${tn}.cnf-node1 | tr -d '#')
if [[ $DISTESTS == *$CONF* ]];then
echo "Skipping test $t"
continue
fi
if grep -qE '56only' $XB_TESTDIR/conf/conf${tn}.cnf-node1;then
echo "Skipping test $t since it is 56only"
continue
fi
t+=" with $CONF"
echo "Running test $t"
if [[ $t == *rlimit* ]];then
export PING_ATTEMPTS=130
else
export PING_ATTEMPTS=100
fi
if [[ "$t" == *"encrypt"* ]];then
if [[ ! -z ${EXTRA_ENCRIPTION_OPTIONS:-} ]];then
echo "This run will initiate with keyring-file plugin/data-at-rest encryption options"
export KEYRING_ENCRIPTION_OPTIONS="$EXTRA_ENCRIPTION_OPTIONS"
fi
fi
set +e
if [[ -n ${SST_DEBUG:-} && $SST_DEBUG == '2' ]];then
./run.sh -d $MYSQL_BASEDIR -t t/xb_galera_sst_advanced-v2.sh
elif [[ -n ${SST_DEBUG:-} && $SST_DEBUG == '30' ]];then
./run.sh -g -d $MYSQL_BASEDIR -t t/xb_galera_sst_advanced-v2.sh
else
./run.sh -d $MYSQL_BASEDIR -t t/xb_galera_sst_advanced-v2.sh
fi
if [[ $? -ne 0 ]];then
FAILEDTESTS+="Test $t failed\n"
fi
set -e
if [[ $t == *progressfile* ]];then
set +e
mv /tmp/progress1-$CONF.log $XB_TESTDIR/results/
mv /tmp/progress2-$CONF.log $XB_TESTDIR/results/
set -e
fi
done
for tn in `seq 1 $NUMTESTS`; do
export CONF="conf${tn}"
t=$(head -1 $XB_TESTDIR/conf/conf${tn}.cnf-node1 | tr -d '#')
if [[ $DISTESTS == *$CONF* ]];then
echo "Skipping test $t"
continue
fi
if grep -qE 'v2only|56only' $XB_TESTDIR/conf/conf${tn}.cnf-node1;then
echo "Skipping test $t since it is v2only|56only"
continue
fi
t+=" with $CONF"
echo "Running test $t"
if [[ $t == *rlimit* ]];then
export PING_ATTEMPTS=130
else
export PING_ATTEMPTS=100
fi
if [[ "$t" == *"encrypt"* ]];then
if [[ ! -z ${EXTRA_ENCRIPTION_OPTIONS:-} ]];then
echo "This run will initiate with keyring-file plugin/data-at-rest encryption options"
export KEYRING_ENCRIPTION_OPTIONS="$EXTRA_ENCRIPTION_OPTIONS"
fi
fi
set +e
if [[ -n ${SST_DEBUG:-} && $SST_DEBUG == '2' ]];then
./run.sh -d $MYSQL_BASEDIR -t t/xb_galera_sst_advanced.sh
elif [[ -n ${SST_DEBUG:-} && $SST_DEBUG == '30' ]];then
./run.sh -g -d $MYSQL_BASEDIR -t t/xb_galera_sst_advanced.sh
else
./run.sh -d $MYSQL_BASEDIR -t t/xb_galera_sst_advanced.sh
fi
if [[ $? -ne 0 ]];then
FAILEDTESTS+="Test $t failed\n"
fi
set -e
if [[ $t == *progressfile* ]];then
set +e
mv /tmp/progress1-$CONF.log $XB_TESTDIR/results/
mv /tmp/progress2-$CONF.log $XB_TESTDIR/results/
set -e
fi
done
unset CONF
echo "Running test for SST special dirs with encrypt=1"
t="SST special dirs with encrypt=1"
set +e
if [[ -n ${SST_DEBUG:-} && $SST_DEBUG == '2' ]];then
./run.sh -d $MYSQL_BASEDIR -t t/xb_galera_sst_dirs.sh
elif [[ -n ${SST_DEBUG:-} && $SST_DEBUG == '30' ]];then
./run.sh -g -d $MYSQL_BASEDIR -t t/xb_galera_sst_dirs.sh
else
./run.sh -d $MYSQL_BASEDIR -t t/xb_galera_sst_dirs.sh
fi
if [[ $? -ne 0 ]];then
FAILEDTESTS+="Test $t failed\n"
fi
set -e
echo "Running test for SST special dirs with encrypt=2"
export CONF=bug1098566-1
t="SST special dirs with encrypt=2 with $CONF"
set +e
if [[ -n ${SST_DEBUG:-} && $SST_DEBUG == '2' ]];then
./run.sh -d $MYSQL_BASEDIR -t t/xb_galera_sst_dirs.sh
elif [[ -n ${SST_DEBUG:-} && $SST_DEBUG == '30' ]];then
./run.sh -g -d $MYSQL_BASEDIR -t t/xb_galera_sst_dirs.sh
else
./run.sh -d $MYSQL_BASEDIR -t t/xb_galera_sst_dirs.sh
fi
if [[ $? -ne 0 ]];then
FAILEDTESTS+="Test $t failed\n"
fi
unset CONF
set -e
echo "Running test for SST special dirs with encrypt=3"
export CONF=bug1098566-2
t="SST special dirs with encrypt=3 with $CONF"
set +e
if [[ -n ${SST_DEBUG:-} && $SST_DEBUG == '2' ]];then
./run.sh -d $MYSQL_BASEDIR -t t/xb_galera_sst_dirs.sh
elif [[ -n ${SST_DEBUG:-} && $SST_DEBUG == '30' ]];then
./run.sh -g -d $MYSQL_BASEDIR -t t/xb_galera_sst_dirs.sh
else
./run.sh -d $MYSQL_BASEDIR -t t/xb_galera_sst_dirs.sh
fi
if [[ $? -ne 0 ]];then
FAILEDTESTS+="Test $t failed\n"
fi
unset CONF
set -e
echo "Running test for SST special dirs with encrypt=1 and innobackupex options"
export CONF=bug1098566-3
t="SST special dirs with encrypt=1 and inno-backup opts with $CONF"
set +e
if [[ -n ${SST_DEBUG:-} && $SST_DEBUG == '2' ]];then
./run.sh -c galera55 -d $MYSQL_BASEDIR -t t/xb_galera_sst_dirs.sh
elif [[ -n ${SST_DEBUG:-} && $SST_DEBUG == '30' ]];then
./run.sh -g -c galera55 -d $MYSQL_BASEDIR -t t/xb_galera_sst_dirs.sh
else
./run.sh -c galera55 -d $MYSQL_BASEDIR -t t/xb_galera_sst_dirs.sh
fi
if [[ $? -ne 0 ]];then
FAILEDTESTS+="Test $t failed\n"
fi
unset CONF
set -e
echo "Running test for SST special dirs with undo-log-directory"
export CONF=bug1394836
t="SST special dirs with undo-log-directory with $CONF"
set +e
if [[ -n ${SST_DEBUG:-} && $SST_DEBUG == '2' ]];then
./run.sh -c galera55 -d $MYSQL_BASEDIR -t t/xb_galera_sst_dirs.sh
elif [[ -n ${SST_DEBUG:-} && $SST_DEBUG == '30' ]];then
./run.sh -g -c galera55 -d $MYSQL_BASEDIR -t t/xb_galera_sst_dirs.sh
else
./run.sh -c galera55 -d $MYSQL_BASEDIR -t t/xb_galera_sst_dirs.sh
fi
if [[ $? -ne 0 ]];then
FAILEDTESTS+="Test $t failed\n"
fi
unset CONF
set -e
echo "Running test for encrypted replication and SST"
if [[ ! -z ${EXTRA_ENCRIPTION_OPTIONS:-} ]];then
echo "This run will initiate with keyring-file plugin/data-at-rest encryption options"
fi
t="Encrypted replication and encrypted SST"
set +e
if [[ -n ${SST_DEBUG:-} && $SST_DEBUG == '2' ]];then
./run.sh -d $MYSQL_BASEDIR -t t/xb_galera_sst_encrypted.sh
elif [[ -n ${SST_DEBUG:-} && $SST_DEBUG == '30' ]];then
./run.sh -g -d $MYSQL_BASEDIR -t t/xb_galera_sst_encrypted.sh
else
./run.sh -d $MYSQL_BASEDIR -t t/xb_galera_sst_encrypted.sh
fi
if [[ $? -ne 0 ]];then
FAILEDTESTS+="Test $t failed\n"
fi
set -e
if [[ -n $FAILEDTESTS ]];then
echo "Following tests unsuccessful"
echo -e "$FAILEDTESTS"
exit 1
fi
if [[ ! -e /tmp/blog1/TESTFILE || ! -e /tmp/blog2/TESTFILE ]];then
echo "conf20 failed"
exit 1
fi
rm -rf /tmp/blog1 /tmp/blog2 || true