forked from Percona-QA/percona-qa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pxc6-long-run-test.sh
executable file
·344 lines (279 loc) · 9.25 KB
/
pxc6-long-run-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
#!/bin/bash -ue
set +e
echo "Killing existing mysqld"
pgrep -f mysqld
pkill -f mysqld
sleep 10
pgrep mysqld || pkill -9 -f mysqld
set -e
sleep 5
LPATH=${SPATH:-/usr/share/doc/sysbench/tests/db}
IST_RUN=0
# For local run - User Configurable Variables
if [ -z ${SDURATION} ]; then
SDURATION=50
fi
if [ -z ${DUALTEST} ]; then
DUALTEST=1
fi
if [ -z ${SST_METHOD} ]; then
SST_METHOD=rsync
fi
if [ -z ${STEST} ]; then
STEST=oltp
fi
if [ -z ${TSIZE} ]; then
TSIZE=250
fi
if [ -z ${NUMT} ]; then
NUMT=8
fi
if [ -z ${TCOUNT} ]; then
TCOUNT=50
fi
if [ -z ${AUTOINC} ]; then
AUTOINC=off
fi
SBENCH="sysbench"
XB_VER=2.2.1
WORKDIR=$1
ROOT_FS=$WORKDIR
sst_method=${SST_METHOD:-xtrabackup}
cd $WORKDIR
if [[ $sst_method == xtrabackup ]];then
TAR=`ls -1ct percona-xtrabackup*.tar.gz | head -n1`
#BBASE="$(basename $TAR .tar.gz)"
tar -xf $TAR
BBASE="percona-xtrabackup-${XB_VER}-Linux-x86_64"
export PATH="$ROOT_FS/$BBASE/bin:$PATH"
fi
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
find . -maxdepth 1 -type d -name 'Percona-XtraDB-Cluster*' -exec rm -rf {} \+
echo "Removing older core files, if any"
rm -f ${ROOT_FS}/**/*core*
echo "Removing older directories"
find . -maxdepth 1 -type d -mtime +10 -exec rm -rf {} \+
echo "Removing their symlinks"
find . -maxdepth 1 -type l -mtime +10 -delete
TAR=`ls -1ct Percona-XtraDB-Cluster*.tar.gz | head -n1`
#BASE="$(basename $TAR .tar.gz)"
BASE="$(tar tf $TAR | head -1 | tr -d '/')"
tar -xf $TAR
# Keep (PS & QA) builds & results for ~40 days (~1/day)
BUILD_WIPE=$[ ${BUILD_NUMBER} - 40 ]
if [ -d ${BUILD_WIPE} ]; then rm -Rf ${BUILD_WIPE}; fi
# For Sysbench
if [[ "x${Host}" == "xubuntu-trusty-64bit" ]];then
export CFLAGS="-Wl,--no-undefined -lasan"
fi
if [[ ! -e `which sysbench` ]];then
echo "Sysbench not found"
exit 1
fi
echo "Note: Using sysbench at $(which sysbench)"
# Parameter of parameterized build
if [[ -n $SDURATION ]];then
export SYSBENCH_DURATION=$SDURATION
else
export SYSBENCH_DURATION=300
fi
WORKDIR="${ROOT_FS}/$BUILD_NUMBER"
mkdir -p $WORKDIR/logs
# User settings
SENDMAIL="/usr/sbin/sendmail"
cleanup(){
tar cvzf $ROOT_FS/results-${BUILD_NUMBER}.tar.gz $WORKDIR/logs || true
}
trap cleanup EXIT KILL
prepare()
{
local sock=$1
local log=$2
echo "Sysbench Run: Prepare stage"
$SBENCH --test=$LPATH/parallel_prepare.lua --report-interval=10 --oltp-auto-inc=$AUTOINC --mysql-engine-trx=yes --mysql-table-engine=innodb \
--oltp-table-size=$TSIZE --oltp_tables_count=$TCOUNT --mysql-db=test --mysql-user=root --num-threads=$NUMT \
--db-driver=mysql --mysql-socket=$sock prepare 2>&1 | tee $log
# $MYSQL_BASEDIR/bin/mysql -S $sock -u root -e "create database testdb;" || true
}
rw_full()
{
local sock=$1
local log=$2
echo "Sysbench Run: OLTP RW testing"
$SBENCH --mysql-table-engine=innodb --num-threads=$NUMT --report-interval=10 --oltp-auto-inc=$AUTOINC --max-time=$SYSBENCH_DURATION --max-requests=1870000000 \
--test=$SDIR/$STEST.lua --init-rng=on --oltp_index_updates=10 --oltp_non_index_updates=10 --oltp_distinct_ranges=15 --oltp_order_ranges=15 --oltp_tables_count=$TCOUNT --mysql-db=test \
--mysql-user=root --db-driver=mysql --mysql-socket=$sock run 2>&1 | tee $log
}
clean_up()
{
local sock=$1
local log=$2
echo "Sysbench Run: Cleanup"
$SBENCH --test=$LPATH/parallel_prepare.lua \
--oltp_tables_count=$TCOUNT --mysql-db=test --mysql-user=root \
--db-driver=mysql --mysql-socket=$sock cleanup 2>&1 | tee $log
}
WORKDIR="${ROOT_FS}/$BUILD_NUMBER"
mkdir -p $WORKDIR
MYSQL_BASEDIR="${ROOT_FS}/$BASE"
export MYSQL_VARDIR="$WORKDIR/mysqldir"
mkdir -p $MYSQL_VARDIR
SDIR="$LPATH"
SRESULTS="$WORKDIR/sresults"
mkdir -p $SRESULTS
echo "Workdir: $WORKDIR"
echo "Basedir: $MYSQL_BASEDIR"
ADDR="127.0.0.1"
RPORT=$(( RANDOM%21 + 10 ))
RBASE1="$(( RPORT*1000 ))"
#lsof -i tcp:$RBASE1 | awk 'NR!=1 {print $2}' | xargs kill -9 2>/dev/null
echo "Setting RBASE to $RBASE1"
RADDR1="$ADDR:$(( RBASE1 + 7 ))"
LADDR1="$ADDR:$(( RBASE1 + 8 ))"
RBASE2="$(( RBASE1 + 100 ))"
#lsof -i tcp:$RBASE2 | awk 'NR!=1 {print $2}' | xargs kill -9 2>/dev/null
RADDR2="$ADDR:$(( RBASE2 + 7 ))"
LADDR2="$ADDR:$(( RBASE2 + 8 ))"
SUSER=root
SPASS=
node1="${MYSQL_VARDIR}/node1"
mkdir -p $node1
node2="${MYSQL_VARDIR}/node2"
mkdir -p $node2
echo "Starting PXC node1"
pushd ${MYSQL_BASEDIR}/mysql-test/
set +e
perl mysql-test-run.pl \
--start-and-exit \
--port-base=$RBASE1 \
--nowarnings \
--vardir=$node1 \
--mysqld=--skip-performance-schema \
--mysqld=--innodb_file_per_table \
--mysqld=--binlog-format=ROW \
--mysqld=--wsrep-slave-threads=2 \
--mysqld=--innodb_autoinc_lock_mode=2 \
--mysqld=--innodb_locks_unsafe_for_binlog=1 \
--mysqld=--wsrep-provider=${MYSQL_BASEDIR}/lib/libgalera_smm.so \
--mysqld=--wsrep_cluster_address=gcomm:// \
--mysqld=--wsrep_sst_receive_address=$RADDR1 \
--mysqld=--wsrep_node_incoming_address=$ADDR \
--mysqld=--wsrep_provider_options="gmcast.listen_addr=tcp://$LADDR1" \
--mysqld=--wsrep_sst_method=$sst_method \
--mysqld=--wsrep_sst_auth=$SUSER:$SPASS \
--mysqld=--wsrep_node_address=$ADDR \
--mysqld=--innodb_flush_method=O_DIRECT \
--mysqld=--core-file \
--mysqld=--loose-new \
--mysqld=--sql-mode=no_engine_substitution \
--mysqld=--loose-innodb \
--mysqld=--secure-file-priv= \
--mysqld=--loose-innodb-status-file=1 \
--mysqld=--skip-name-resolve \
--mysqld=--socket=$node1/socket.sock \
--mysqld=--log-error=$WORKDIR/logs/node1.err \
--mysqld=--log-output=none \
1st
set -e
popd
sleep 10
# Sysbench Runs
## Prepare/setup
echo "Sysbench Run: Prepare stage"
if [[ -n ${BUILTIN_SYSBENCH:-} ]];then
/usr/bin/sysbench --test=oltp --oltp-auto-inc=off --mysql-engine-trx=yes --mysql-table-engine=innodb \
--oltp-table-size=100000 --mysql-db=test --mysql-user=root \
--db-driver=mysql --mysql-socket=$node1/socket.sock prepare \
> $SRESULTS/sysbench_prepare.txt
else
prepare $node1/socket.sock $WORKDIR/logs/sysbench_prepare.txt
fi
$MYSQL_BASEDIR/bin/mysql -S $node1/socket.sock -u root -e "create database testdb;" || true
if [[ -n ${DUALTEST:-} ]];then
pushd ${MYSQL_BASEDIR}/mysql-test/
export MYSQLD_BOOTSTRAP_CMD=
set +e
perl mysql-test-run.pl \
--start-and-exit \
--port-base=$RBASE2 \
--nowarnings \
--vardir=$node2 \
--mysqld=--skip-performance-schema \
--mysqld=--innodb_file_per_table \
--mysqld=--binlog-format=ROW \
--mysqld=--wsrep-slave-threads=2 \
--mysqld=--innodb_autoinc_lock_mode=2 \
--mysqld=--innodb_locks_unsafe_for_binlog=1 \
--mysqld=--wsrep-provider=${MYSQL_BASEDIR}/lib/libgalera_smm.so \
--mysqld=--wsrep_cluster_address=gcomm://$LADDR1 \
--mysqld=--wsrep_sst_receive_address=$RADDR2 \
--mysqld=--wsrep_node_incoming_address=$ADDR \
--mysqld=--wsrep_provider_options="gmcast.listen_addr=tcp://$LADDR2" \
--mysqld=--wsrep_sst_method=$sst_method \
--mysqld=--wsrep_sst_auth=$SUSER:$SPASS \
--mysqld=--wsrep_node_address=$ADDR \
--mysqld=--innodb_flush_method=O_DIRECT \
--mysqld=--core-file \
--mysqld=--loose-new \
--mysqld=--sql-mode=no_engine_substitution \
--mysqld=--loose-innodb \
--mysqld=--secure-file-priv= \
--mysqld=--loose-innodb-status-file=1 \
--mysqld=--skip-name-resolve \
--mysqld=--log-error=$WORKDIR/logs/node2.err \
--mysqld=--socket=$node2/socket.sock \
--mysqld=--log-output=none \
1st
set -e
popd
fi
echo "Sleeping for 10s"
sleep 10
if [[ -z ${BUILTIN_SYSBENCH:-} ]];then
STABLE="test.sbtest1"
else
STABLE="test.sbtest"
fi
if [[ ! -e $SDIR/${STEST}.lua ]];then
pushd /tmp
rm $STEST.lua || true
wget -O $STEST.lua https://github.com/Percona-QA/sysbench/tree/0.5/sysbench/tests/db/${STEST}.lua
SDIR=/tmp/
popd
fi
set -x
if [[ -n ${DUALTEST:-} ]];then
## OLTP RW Run
echo "Sysbench Run: OLTP RW testing"
if [[ -n ${BUILTIN_SYSBENCH:-} ]];then
/usr/bin/sysbench --num-threads=16 --oltp-auto-inc=off --max-time=$SYSBENCH_DURATION --max-requests=1870000000 \
--test=oltp --oltp-table-size=100000 --mysql-db=test \
--mysql-user=root --db-driver=mysql --mysql-socket=$node2/socket.sock \
run > $SRESULTS/sysbench_rw_run.txt
else
echo "Table row count after SST run"
rw_full "$node1/socket.sock,$node2/socket.sock" $WORKDIR/logs/sysbench_rw_run.txt
clean_up $node1/socket.sock $WORKDIR/logs/sysbench_cleanup.txt
fi
else
## OLTP RW Run
echo "Sysbench Run: OLTP RW testing"
if [[ -n ${BUILTIN_SYSBENCH:-} ]];then
/usr/bin/sysbench --num-threads=16 --oltp-auto-inc=off --max-time=$SYSBENCH_DURATION --max-requests=1870000000 \
--test=oltp --oltp-table-size=100000 --mysql-db=test \
--mysql-user=root --db-driver=mysql --mysql-socket=$node1/socket.sock \
run > $SRESULTS/sysbench_rw_run.txt
else
echo "Table row count after SST run"
rw_full "$node1/socket.sock" $WORKDIR/logs/sysbench_rw_run.txt
clean_up $node1/socket.sock $WORKDIR/logs/sysbench_cleanup.txt
fi
fi
set +x
$MYSQL_BASEDIR/bin/mysqladmin --socket=$node1/socket.sock -u root shutdown
$MYSQL_BASEDIR/bin/mysqladmin --socket=$node2/socket.sock -u root shutdown