Merge lp:~akopytov/percona-xtrabackup/test-suite-cleanups-2.1 into lp:percona-xtrabackup/2.1

Proposed by Alexey Kopytov
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 625
Proposed branch: lp:~akopytov/percona-xtrabackup/test-suite-cleanups-2.1
Merge into: lp:percona-xtrabackup/2.1
Diff against target: 1868 lines (+804/-631)
18 files modified
patches/innodb56.patch (+17/-1)
src/xtrabackup.cc (+6/-14)
test/inc/common.sh (+104/-68)
test/run.sh (+653/-96)
test/subunit.sh (+4/-1)
test/t/bug1085099.sh (+1/-3)
test/t/bug664986.sh (+0/-8)
test/t/bug996493.sh (+0/-4)
test/t/compact_compressed.sh (+10/-5)
test/t/ib_stream_incremental.sh (+1/-1)
test/t/remote_tablespaces.sh (+1/-1)
test/t/undo_tablespaces.sh (+1/-1)
test/t/xb_encrypt.sh (+0/-2)
test/t/xb_part_range.sh (+2/-12)
test/t/xb_perm_basic.sh (+0/-2)
test/t/xb_perm_stream.sh (+0/-2)
test/t/xb_stats_datadir.sh (+4/-5)
test/testrun.c (+0/-405)
To merge this branch: bzr merge lp:~akopytov/percona-xtrabackup/test-suite-cleanups-2.1
Reviewer Review Type Date Requested Status
George Ormond Lorch III (community) g2 Approve
Stewart Smith Pending
Review via email: mp+172963@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) wrote :

http://jenkins.percona.com/view/XtraBackup/job/percona-xtrabackup-2.1-param/360/

Same comments on remaining failures as in the 2.0 MP.

Revision history for this message
Alexey Kopytov (akopytov) wrote :

Would be nice to have this merged sooner rather than later, as I have a pile of other fixes which depends on this branch.

Revision history for this message
George Ormond Lorch III (gl-az) wrote :

Same comments as 2.0 MP, nice work!

review: Approve (g2)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'patches/innodb56.patch'
--- patches/innodb56.patch 2013-07-01 12:21:20 +0000
+++ patches/innodb56.patch 2013-07-04 07:51:31 +0000
@@ -1431,4 +1431,20 @@
1431 int main()1431 int main()
1432 {1432 {
1433 extern void __attribute__((weak)) foo(void);1433 extern void __attribute__((weak)) foo(void);
14341434--- a/mysys/my_thr_init.c
1435+++ b/mysys/my_thr_init.c
1436@@ -462,8 +462,12 @@
1437
1438 extern void **my_thread_var_dbug()
1439 {
1440- struct st_my_thread_var *tmp=
1441- my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys);
1442+ struct st_my_thread_var *tmp;
1443+
1444+ if (!my_thread_global_init_done)
1445+ return NULL;
1446+
1447+ tmp= my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys);
1448 return tmp && tmp->init ? &tmp->dbug : 0;
1449 }
1450 #endif /* DBUG_OFF */
14351451
=== modified file 'src/xtrabackup.cc'
--- src/xtrabackup.cc 2013-06-18 14:49:01 +0000
+++ src/xtrabackup.cc 2013-07-04 07:51:31 +0000
@@ -3835,6 +3835,8 @@
38353835
3836 ulint fold;3836 ulint fold;
38373837
3838 bool checkpoint_found;
3839
3838 max_no = ut_dulint_zero;3840 max_no = ut_dulint_zero;
38393841
3840 if (!xb_init_log_block_size()) {3842 if (!xb_init_log_block_size()) {
@@ -3949,6 +3951,8 @@
3949 // ' ', 4);3951 // ' ', 4);
3950 }3952 }
39513953
3954 checkpoint_found = false;
3955
3952 /* read last checkpoint lsn */3956 /* read last checkpoint lsn */
3953 for (field = LOG_CHECKPOINT_1; field <= LOG_CHECKPOINT_2;3957 for (field = LOG_CHECKPOINT_1; field <= LOG_CHECKPOINT_2;
3954 field += LOG_CHECKPOINT_2 - LOG_CHECKPOINT_1) {3958 field += LOG_CHECKPOINT_2 - LOG_CHECKPOINT_1) {
@@ -3961,25 +3965,13 @@
3961 if (ut_dulint_cmp(checkpoint_no, max_no) >= 0) {3965 if (ut_dulint_cmp(checkpoint_no, max_no) >= 0) {
3962 max_no = checkpoint_no;3966 max_no = checkpoint_no;
3963 max_lsn = MACH_READ_64(log_buf + field + LOG_CHECKPOINT_LSN);3967 max_lsn = MACH_READ_64(log_buf + field + LOG_CHECKPOINT_LSN);
3964/*3968 checkpoint_found = true;
3965 mach_write_to_4(log_buf + field + LOG_CHECKPOINT_OFFSET,
3966 LOG_FILE_HDR_SIZE + ut_dulint_minus(max_lsn,
3967 ut_dulint_align_down(max_lsn,OS_FILE_LOG_BLOCK_SIZE)));
3968
3969 ulint fold;
3970 fold = ut_fold_binary(log_buf + field, LOG_CHECKPOINT_CHECKSUM_1);
3971 mach_write_to_4(log_buf + field + LOG_CHECKPOINT_CHECKSUM_1, fold);
3972
3973 fold = ut_fold_binary(log_buf + field + LOG_CHECKPOINT_LSN,
3974 LOG_CHECKPOINT_CHECKSUM_2 - LOG_CHECKPOINT_LSN);
3975 mach_write_to_4(log_buf + field + LOG_CHECKPOINT_CHECKSUM_2, fold);
3976*/
3977 }3969 }
3978not_consistent:3970not_consistent:
3979 ;3971 ;
3980 }3972 }
39813973
3982 if (ut_dulint_cmp(max_no, ut_dulint_zero) == 0) {3974 if (!checkpoint_found) {
3983 msg("xtrabackup: No valid checkpoint found.\n");3975 msg("xtrabackup: No valid checkpoint found.\n");
3984 goto error;3976 goto error;
3985 }3977 }
39863978
=== modified file 'test/inc/common.sh'
--- test/inc/common.sh 2013-06-28 15:23:23 +0000
+++ test/inc/common.sh 2013-07-04 07:51:31 +0000
@@ -16,9 +16,12 @@
16}16}
1717
1818
19function clean()19########################################################################
20# Remove server var* directories from the worker's var root
21########################################################################
22function remove_var_dirs()
20{23{
21 rm -rf ${TEST_BASEDIR}/var[0-9]24 rm -rf ${TEST_VAR_ROOT}/var[0-9]
22}25}
2326
24function die()27function die()
@@ -34,29 +37,33 @@
34 $MYSQL_INSTALL_DB --defaults-file=${MYSQLD_VARDIR}/my.cnf \37 $MYSQL_INSTALL_DB --defaults-file=${MYSQLD_VARDIR}/my.cnf \
35 --basedir=${MYSQL_BASEDIR} \38 --basedir=${MYSQL_BASEDIR} \
36 ${MYSQLD_EXTRA_ARGS}39 ${MYSQLD_EXTRA_ARGS}
37 cd -40 cd - >/dev/null 2>&1
38}41}
3942
40########################################################################43########################################################################
41# Checks whether MySQL is alive44# Checks whether MySQL with the PID specified as an argument is alive
42########################################################################45########################################################################
43function mysql_ping()46function mysql_ping()
44{47{
45 $MYSQLADMIN $MYSQL_ARGS --wait=100 ping >/dev/null 2>&1 || return 148 local pid=$1
46}49 local attempts=60
50 local i
4751
48function kill_leftovers()52 for ((i=1; i<=attempts; i++))
49{
50 local file
51 for file in ${TEST_BASEDIR}/mysqld*.pid
52 do53 do
53 if [ -f $file ]54 $MYSQLADMIN $MYSQL_ARGS ping >/dev/null 2>&1 && return 0
54 then55 sleep 1
55 vlog "Found a leftover mysqld processes with PID `cat $file`, stopping it"56 # Is the server process still alive?
56 kill -9 `cat $file` 2>/dev/null || true57 if ! kill -0 $pid >/dev/null 2>&1
57 rm -f $file58 then
58 fi59 vlog "Server process PID=$pid died."
60 wait $pid
61 return 1
62 fi
63 vlog "Made $i attempts to connect to server"
59 done64 done
65
66 return 1
60}67}
6168
62function run_cmd()69function run_cmd()
@@ -123,21 +130,14 @@
123 local port130 local port
124 local lockfile131 local lockfile
125132
126 for (( port=PORT_BASE+id; port < 65535; port++))133 for (( port=3307 + RANDOM; port < 65535; port++))
127 do134 do
128 lockfile="/tmp/xtrabackup_port_lock.$port"135 lockfile="/tmp/xtrabackup_port_lock.$port"
129 # Try to atomically lock the current port number136 # Try to atomically lock the current port number
130 if ! set -C > $lockfile137 if ! (set -C; > $lockfile)
131 then138 then
132 set +C139 continue;
133 # check if the process still exists
134 if kill -0 "`cat $lockfile`"
135 then
136 continue;
137 fi
138 # stale file, overwrite it with the current PID
139 fi140 fi
140 set +C
141 echo $$ > $lockfile141 echo $$ > $lockfile
142 if ! nc -z -w1 localhost $port >/dev/null 2>&1142 if ! nc -z -w1 localhost $port >/dev/null 2>&1
143 then143 then
@@ -173,14 +173,14 @@
173 fi173 fi
174174
175 SRV_MYSQLD_IDS[$id]="$id"175 SRV_MYSQLD_IDS[$id]="$id"
176 local vardir="${TEST_BASEDIR}/var${id}"176 local vardir="${TEST_VAR_ROOT}/var${id}"
177 SRV_MYSQLD_VARDIR[$id]="$vardir"177 SRV_MYSQLD_VARDIR[$id]="$vardir"
178 SRV_MYSQLD_DATADIR[$id]="$vardir/data"178 SRV_MYSQLD_DATADIR[$id]="$vardir/data"
179 SRV_MYSQLD_TMPDIR[$id]="$vardir/tmp"179 SRV_MYSQLD_TMPDIR[$id]="$vardir/tmp"
180 SRV_MYSQLD_PIDFILE[$id]="${TEST_BASEDIR}/mysqld${id}.pid"180 SRV_MYSQLD_PIDFILE[$id]="${TEST_VAR_ROOT}/mysqld${id}.pid"
181 SRV_MYSQLD_ERRFILE[$id]="$vardir/data/mysqld${id}.err"181 SRV_MYSQLD_ERRFILE[$id]="$vardir/data/mysqld${id}.err"
182 SRV_MYSQLD_PORT[$id]=`get_free_port $id`182 SRV_MYSQLD_PORT[$id]=`get_free_port $id`
183 SRV_MYSQLD_SOCKET[$id]=`mktemp -t xtrabackup.mysql.sock.XXXXXX`183 SRV_MYSQLD_SOCKET[$id]=`mktemp -t mysql.sock.XXXXXX`
184}184}
185185
186########################################################################186########################################################################
@@ -245,27 +245,36 @@
245function start_server_with_id()245function start_server_with_id()
246{246{
247 local id=$1247 local id=$1
248 local attempts=0
249 local max_attempts=5
248 shift250 shift
249251
250 vlog "Starting server with id=$id..."252 vlog "Starting server with id=$id..."
251253
252 init_server_variables $id254 while true
253 switch_server $id255 do
254256 init_server_variables $id
255 if [ ! -d "$MYSQLD_VARDIR" ]257 switch_server $id
256 then258
257 vlog "Creating server root directory: $MYSQLD_VARDIR"259 if [ ! -d "$MYSQLD_VARDIR" ]
258 mkdir "$MYSQLD_VARDIR"260 then
259 fi261 vlog "Creating server root directory: $MYSQLD_VARDIR"
260 if [ ! -d "$MYSQLD_TMPDIR" ]262 mkdir "$MYSQLD_VARDIR"
261 then263 fi
262 vlog "Creating server temporary directory: $MYSQLD_TMPDIR"264 if [ ! -d "$MYSQLD_TMPDIR" ]
263 mkdir "$MYSQLD_TMPDIR"265 then
264 fi266 vlog "Creating server temporary directory: $MYSQLD_TMPDIR"
265267 mkdir "$MYSQLD_TMPDIR"
266 # Create the configuration file used by mysql_install_db, the server268 fi
267 # and the xtrabackup binary269
268 cat > ${MYSQLD_VARDIR}/my.cnf <<EOF270 if [ -f "$MYSQLD_ERRFILE" ]
271 then
272 rm "$MYSQLD_ERRFILE"
273 fi
274
275 # Create the configuration file used by mysql_install_db, the server
276 # and the xtrabackup binary
277 cat > ${MYSQLD_VARDIR}/my.cnf <<EOF
269[mysqld]278[mysqld]
270socket=${MYSQLD_SOCKET}279socket=${MYSQLD_SOCKET}
271port=${MYSQLD_PORT}280port=${MYSQLD_PORT}
@@ -285,22 +294,42 @@
285user=root294user=root
286EOF295EOF
287296
288 # Create datadir and call mysql_install_db if it doesn't exist297 # Create datadir and call mysql_install_db if it doesn't exist
289 if [ ! -d "$MYSQLD_DATADIR" ]298 if [ ! -d "$MYSQLD_DATADIR" ]
290 then299 then
291 vlog "Creating server data directory: $MYSQLD_DATADIR"300 vlog "Creating server data directory: $MYSQLD_DATADIR"
292 mkdir -p "$MYSQLD_DATADIR"301 mkdir -p "$MYSQLD_DATADIR"
293 call_mysql_install_db302 call_mysql_install_db
294 fi303 fi
295304
296 # Start the server305 # Start the server
297 echo "Starting ${MYSQLD} ${MYSQLD_ARGS} $* "306 echo "Starting ${MYSQLD} ${MYSQLD_ARGS} $* "
298 ${MYSQLD} ${MYSQLD_ARGS} $* &307 ${MYSQLD} ${MYSQLD_ARGS} $* &
299 if ! mysql_ping308 if ! mysql_ping $!
300 then309 then
301 die "Can't start the server!"310 if grep "another mysqld server running on port" $MYSQLD_ERRFILE
302 fi311 then
303 vlog "Server with id=$id has been started on port $MYSQLD_PORT, \312 if ((++attempts < max_attempts))
313 then
314 vlog "Made $attempts attempts to find a free port"
315 reset_server_variables $id
316 free_reserved_port $MYSQLD_PORT
317 continue
318 else
319 vlog "Failed to find a free port after $attempts attempts"
320 fi
321 fi
322 vlog "Can't start the server. Server log (if exists):"
323 vlog "----------------"
324 cat ${MYSQLD_ERRFILE} >&2 || true
325 vlog "----------------"
326 exit -1
327 else
328 break
329 fi
330 done
331
332 vlog "Server with id=$id has been started on port $MYSQLD_PORT, \
304socket $MYSQLD_SOCKET"333socket $MYSQLD_SOCKET"
305}334}
306335
@@ -317,7 +346,9 @@
317346
318 if [ -f "${MYSQLD_PIDFILE}" ]347 if [ -f "${MYSQLD_PIDFILE}" ]
319 then348 then
320 kill -9 `cat ${MYSQLD_PIDFILE}`349 local pid=`cat $MYSQLD_PIDFILE`
350 kill -9 $pid
351 wait $pid || true
321 rm -f ${MYSQLD_PIDFILE}352 rm -f ${MYSQLD_PIDFILE}
322 else353 else
323 vlog "Server PID file '${MYSQLD_PIDFILE}' doesn't exist!"354 vlog "Server PID file '${MYSQLD_PIDFILE}' doesn't exist!"
@@ -484,7 +515,8 @@
484##########################################################################515##########################################################################
485function record_db_state()516function record_db_state()
486{517{
487 $MYSQLDUMP $MYSQL_ARGS -t --compact $1 >"$topdir/tmp/$1_old.sql"518 $MYSQLDUMP $MYSQL_ARGS -t --compact --skip-extended-insert \
519 $1 >"$topdir/tmp/$1_old.sql"
488}520}
489521
490522
@@ -494,7 +526,8 @@
494##########################################################################526##########################################################################
495function verify_db_state()527function verify_db_state()
496{528{
497 $MYSQLDUMP $MYSQL_ARGS -t --compact $1 >"$topdir/tmp/$1_new.sql"529 $MYSQLDUMP $MYSQL_ARGS -t --compact --skip-extended-insert \
530 $1 >"$topdir/tmp/$1_new.sql"
498 diff -u "$topdir/tmp/$1_old.sql" "$topdir/tmp/$1_new.sql"531 diff -u "$topdir/tmp/$1_old.sql" "$topdir/tmp/$1_new.sql"
499}532}
500533
@@ -514,14 +547,14 @@
514 return ${PIPESTATUS[0]}547 return ${PIPESTATUS[0]}
515}548}
516549
517readonly xb_performed_bmp_inc_backup="xtrabackup: using the full scan for incremental backup"
518readonly xb_performed_full_scan_inc_backup="xtrabackup: using the changed page bitmap"
519
520####################################################550####################################################
521# Helper functions for testing incremental backups #551# Helper functions for testing incremental backups #
522####################################################552####################################################
523function check_full_scan_inc_backup()553function check_full_scan_inc_backup()
524{554{
555 local xb_performed_bmp_inc_backup="xtrabackup: using the full scan for incremental backup"
556 local xb_performed_full_scan_inc_backup="xtrabackup: using the changed page bitmap"
557
525 if ! grep -q "$xb_performed_bmp_inc_backup" $OUTFILE ;558 if ! grep -q "$xb_performed_bmp_inc_backup" $OUTFILE ;
526 then559 then
527 vlog "xtrabackup did not perform a full scan for the incremental backup."560 vlog "xtrabackup did not perform a full scan for the incremental backup."
@@ -536,6 +569,9 @@
536569
537function check_bitmap_inc_backup()570function check_bitmap_inc_backup()
538{571{
572 local xb_performed_bmp_inc_backup="xtrabackup: using the full scan for incremental backup"
573 local xb_performed_full_scan_inc_backup="xtrabackup: using the changed page bitmap"
574
539 if ! grep -q "$xb_performed_full_scan_inc_backup" $OUTFILE ;575 if ! grep -q "$xb_performed_full_scan_inc_backup" $OUTFILE ;
540 then576 then
541 vlog "xtrabackup did not use bitmaps for the incremental backup."577 vlog "xtrabackup did not use bitmaps for the incremental backup."
542578
=== removed file 'test/run.sh'
--- test/run.sh 2012-11-30 04:28:06 +0000
+++ test/run.sh 1970-01-01 00:00:00 +0000
@@ -1,14 +0,0 @@
1#!/bin/bash
2
3XB_BUILD="autodetect"
4while getopts "fc:" options; do
5 case $options in
6 c ) XB_BUILD="$OPTARG";;
7 f ) ;; # ignored
8 esac
9done
10
11rm -rf results/ var/ test_results.subunit
12
13CFLAGS=-g make testrun
14./testrun -c $XB_BUILD
150
=== renamed file 'test/testrun.sh' => 'test/run.sh'
--- test/testrun.sh 2013-05-17 11:07:26 +0000
+++ test/run.sh 2013-07-04 07:51:31 +0000
@@ -2,14 +2,39 @@
22
3export DEBUG=3export DEBUG=
44
5shopt -s extglob
6
7set +e
8
5. inc/common.sh9. inc/common.sh
610. subunit.sh
7trap kill_leftovers 1 2 3 1511
812trap cleanup_on_exit EXIT
9set +e13trap terminate SIGHUP SIGINT SIGQUIT SIGTERM
1014
11result=015result=0
1216
17# Default test timeout in seconds
18TEST_TIMEOUT=600
19
20# Magic exit code to indicate a skipped test
21export SKIPPED_EXIT_CODE=200
22
23# Default server installation directory (-d option)
24MYSQL_BASEDIR=${MYSQL_BASEDIR:-"$PWD/server"}
25
26TEST_BASEDIR="$PWD"
27TEST_VAR_ROOT="$TEST_BASEDIR/var"
28
29# Global statistics
30FAILED_COUNT=0
31FAILED_TESTS=
32SKIPPED_COUNT=0
33SKIPPED_TESTS=
34SUCCESSFUL_COUNT=0
35TOTAL_COUNT=0
36TOTAL_TIME=0
37
13function usage()38function usage()
14{39{
15cat <<EOF40cat <<EOF
@@ -24,7 +49,183 @@
24-c conf XtraBackup build configuration as specified to build.sh.49-c conf XtraBackup build configuration as specified to build.sh.
25 Default is 'autodetect', i.e. xtrabackup binary is determined based50 Default is 'autodetect', i.e. xtrabackup binary is determined based
26 on the MySQL version.51 on the MySQL version.
27EOF52-j N Run tests in N parallel processes.
53-T seconds Test timeout (default is $TEST_TIMEOUT seconds).
54EOF
55}
56
57###############################################################################
58# Calculate the number of parallel workers automatically based on the number of
59# available cores
60###############################################################################
61function autocalc_nworkers()
62{
63 if [ -r /proc/cpuinfo ]
64 then
65 NWORKERS=`grep processor /proc/cpuinfo | wc -l`
66 elif which sysctl >/dev/null 2>&1
67 then
68 NWORKERS=`sysctl -n hw.ncpu`
69 fi
70
71 if [[ ! $NWORKERS =~ ^[0-9]+$ || $NWORKERS < 1 ]]
72 then
73 echo "Cannot determine the number of available CPU cures!"
74 exit -1
75 fi
76
77 if [ "$NWORKERS" -gt 16 ]
78 then
79 echo "Autodetected number of cores: $NWORKERS"
80 echo "Limiting to 16 to avoid excessive resource consumption"
81
82 NWORKERS=16
83 fi
84}
85
86###############################################################################
87# Kill a specified worker
88###############################################################################
89function kill_worker()
90{
91 local worker=$1
92 local pid=${worker_pids[$worker]}
93
94 worker_pids[$worker]=""
95
96 if ! kill -0 $pid >/dev/null 2>&1
97 then
98 wait $pid >/dev/null 2>&1 || true
99 return 0
100 fi
101
102 # First send SIGTERM to let worker exit gracefully
103 kill -SIGTERM $pid >/dev/null 2>&1 || true
104
105 sleep 1
106
107 if ! kill -0 $pid >/dev/null 2>&1
108 then
109 wait $pid >/dev/null 2>&1 || true
110 return 0
111 fi
112
113 # Now kill with SIGKILL
114 kill -SIGKILL $pid >/dev/null 2>&1 || true
115 wait $pid >/dev/null 2>&1 || true
116 release_port_locks $pid
117}
118
119########################################################################
120# Kill all running workers
121########################################################################
122function kill_all_workers()
123{
124 while true
125 do
126 found=""
127
128 # First send SIGTERM to let workers exit gracefully
129 for ((i = 1; i <= NWORKERS; i++))
130 do
131 [ -z ${worker_pids[$i]:-""} ] && continue
132
133 found="yes"
134
135 if ! kill -0 ${worker_pids[$i]} >/dev/null 2>&1
136 then
137 worker_pids[$i]=""
138 continue
139 fi
140
141 kill -SIGTERM ${worker_pids[$i]} >/dev/null 2>&1 || true
142 done
143
144 [ -z "$found" ] && break
145
146 sleep 1
147
148 # Now kill with SIGKILL
149 for ((i = 1; i <= NWORKERS; i++))
150 do
151 [ -z ${worker_pids[$i]:-""} ] && continue
152
153 if ! kill -0 ${worker_pids[$i]} >/dev/null 2>&1
154 then
155 wait ${worker_pids[$i]} >/dev/null 2>&1 || true
156 worker_pids[$i]=""
157 continue
158 fi
159
160 kill -SIGKILL ${worker_pids[$i]} >/dev/null 2>&1 || true
161 wait ${worker_pids[$i]} >/dev/null 2>&1 || true
162 release_port_locks ${worker_pids[$i]}
163 worker_pids[$i]=""
164 done
165 done
166}
167
168########################################################################
169# Handler called from a fatal signal handler trap
170########################################################################
171function terminate()
172{
173 echo "Terminated, cleaning up..."
174
175 # The following will call cleanup_on_exit()
176 exit 2
177}
178
179########################################################################
180# Display the test run summary and exit
181########################################################################
182function print_status_and_exit()
183{
184 local test_time=$((`now` - TEST_START_TIME))
185 cat <<EOF
186==============================================================================
187Spent $TOTAL_TIME of $test_time seconds executing testcases
188
189SUMMARY: $TOTAL_COUNT run, $SUCCESSFUL_COUNT successful, $SKIPPED_COUNT skipped, $FAILED_COUNT failed
190
191EOF
192
193 if [ -n "$SKIPPED_TESTS" ]
194 then
195 echo "Skipped tests: $SKIPPED_TESTS"
196 echo
197 fi
198
199 if [ -n "$FAILED_TESTS" ]
200 then
201 echo "Failed tests: $FAILED_TESTS"
202 echo
203 fi
204
205 echo "See results/ for detailed output"
206
207 if [ "$FAILED_COUNT" = 0 ]
208 then
209 exit 0
210 fi
211
212 exit 1
213}
214
215########################################################################
216# Cleanup procedure invoked on process exit
217########################################################################
218function cleanup_on_exit()
219{
220 kill_servers $TEST_VAR_ROOT
221
222 remove_var_dirs
223
224 release_port_locks $$
225
226 kill_all_workers
227
228 cleanup_all_workers
28}229}
29230
30function find_program()231function find_program()
@@ -52,12 +253,11 @@
52 fi253 fi
53}254}
54255
256########################################################################
257# Explore environment and setup global variables
258########################################################################
55function set_vars()259function set_vars()
56{260{
57 TEST_BASEDIR=${TEST_BASEDIR:-"$PWD"}
58 MYSQL_BASEDIR=${MYSQL_BASEDIR:-"$PWD/server"}
59 PORT_BASE=$((3306 + $RANDOM))
60
61 if gnutar --version > /dev/null 2>&1261 if gnutar --version > /dev/null 2>&1
62 then262 then
63 TAR=gnutar263 TAR=gnutar
@@ -88,7 +288,7 @@
88 fi288 fi
89 DYLD_LIBRARY_PATH="$LD_LIBRARY_PATH"289 DYLD_LIBRARY_PATH="$LD_LIBRARY_PATH"
90290
91 export TEST_BASEDIR PORT_BASE TAR MYSQL_BASEDIR MYSQL MYSQLD MYSQLADMIN \291 export TAR MYSQL_BASEDIR MYSQL MYSQLD MYSQLADMIN \
92MYSQL_INSTALL_DB PATH LD_LIBRARY_PATH DYLD_LIBRARY_PATH MYSQLDUMP292MYSQL_INSTALL_DB PATH LD_LIBRARY_PATH DYLD_LIBRARY_PATH MYSQLDUMP
93}293}
94294
@@ -229,7 +429,7 @@
229 return 1429 return 1
230 fi430 fi
231431
232 stop_server432 stop_server >>$OUTFILE 2>&1
233433
234 export MYSQL_VERSION MYSQL_VERSION_COMMENT MYSQL_FLAVOR \434 export MYSQL_VERSION MYSQL_VERSION_COMMENT MYSQL_FLAVOR \
235 INNODB_VERSION XTRADB_VERSION INNODB_FLAVOR \435 INNODB_VERSION XTRADB_VERSION INNODB_FLAVOR \
@@ -237,39 +437,362 @@
237 DEFAULT_IBDATA_SIZE XB_BUILD437 DEFAULT_IBDATA_SIZE XB_BUILD
238}438}
239439
240export SKIPPED_EXIT_CODE=200440###########################################################################
441# Kill all server processes started by a worker specified with its var root
442# directory
443###########################################################################
444function kill_servers()
445{
446 local var_root=$1
447 local file
448
449 [ -d $var_root ] || return 0
450
451 cd $var_root
452
453 for file in mysqld*.pid
454 do
455 if [ -f $file ]
456 then
457 vlog "Found a leftover mysqld processes with PID `cat $file`, \
458stopping it"
459 kill -9 `cat $file` 2>/dev/null || true
460 rm -f $file
461 fi
462 done
463
464 cd - >/dev/null 2>&1
465}
466
467###########################################################################
468# Kill all server processes started by a worker specified with its number
469###########################################################################
470function kill_servers_for_worker()
471{
472 local worker=$1
473
474 kill_servers $TEST_BASEDIR/var/w$worker
475}
476
477################################################################################
478# Clean up all workers (except DEBUG_WORKER if set) We can't use worker* arrays
479# here and examine the directory structure, because the same functions is called
480# on startup when we want to cleanup all workers started on previous invokations
481################################################################################
482function cleanup_all_workers() { local worker
483
484 for worker_dir in $TEST_BASEDIR/var/w+([0-9])
485 do
486 [ -d $worker_dir ] || continue
487 [[ $worker_dir =~ w([0-9]+)$ ]] || continue
488
489 worker=${BASH_REMATCH[1]}
490
491 if [ "$worker" = "$DEBUG_WORKER" ]
492 then
493 echo
494 echo "Skipping cleanup for worker #$worker due to debug mode."
495 echo "You can do post-mortem analysis by examining test data in \
496$worker_dir"
497 echo "and the server process if it was running at the failure time."
498 continue
499 fi
500
501 cleanup_worker $worker
502 done
503}
504########################################################################
505# Clean up a specified worker
506########################################################################
507function cleanup_worker()
508{
509 local worker=$1
510 local tmpdir
511
512 kill_servers_for_worker $worker >>$OUTFILE 2>&1
513
514 # It is possible that a file is created while rm is in progress
515 # which results in "rm: cannot remove ...: Directory not empty
516 # hence the loop below
517 while true
518 do
519 # Fix permissions as some tests modify them so the following 'rm' fails
520 chmod -R 0700 $TEST_BASEDIR/var/w$worker >/dev/null 2>&1
521 rm -rf $TEST_BASEDIR/var/w$worker && break
522 done
523
524 tmpdir=${worker_tmpdirs[$worker]:-""}
525 if [ -n "$tmpdir" ]
526 then
527 rm -rf $tmpdir
528 fi
529}
530
531########################################################################
532# Return the number of seconds since the Epoch, UTC
533########################################################################
534function now()
535{
536 date '+%s'
537}
538
539########################################################################
540# Process the exit code of a specified worker
541########################################################################
542function reap_worker()
543{
544 local worker=$1
545 local pid=${worker_pids[$worker]}
546 local skip_file=${worker_skip_files[$worker]}
547 local tpath=${worker_names[$worker]}
548 local tname=`basename $tpath .sh`
549 local test_time=$((`now` - worker_stime[$worker]))
550 local status_file=${worker_status_files[$worker]}
551 local rc
552
553 if [ -f "$status_file" ]
554 then
555 rc=`cat $status_file`
556 # Assume exit code 1 if status file is empty
557 rc=${rc:-"1"}
558 else
559 # Assume exit code 1 if status file does not exist
560 rc="1"
561 fi
562
563 printf "%-40s w%d\t" $tname $worker
564
565 ((TOTAL_TIME+=test_time))
566
567 # Have to call subunit_start_test here, as currently tests cannot be
568 # interleaved in the subunit output
569 subunit_start_test $tpath "${worker_stime_txt[$worker]}" >> $SUBUNIT_OUT
570
571 if [ $rc -eq 0 ]
572 then
573 echo "[passed] $test_time"
574
575 SUCCESSFUL_COUNT=$((SUCCESSFUL_COUNT + 1))
576 subunit_pass_test $tpath >> $SUBUNIT_OUT
577
578 cleanup_worker $worker
579 elif [ $rc -eq $SKIPPED_EXIT_CODE ]
580 then
581 sreason=""
582 test -r $skip_file && sreason=`cat $skip_file`
583
584 SKIPPED_COUNT=$((SKIPPED_COUNT + 1))
585 SKIPPED_TESTS="$SKIPPED_TESTS $tname"
586
587 echo "[skipped] $sreason"
588
589 subunit_skip_test $tpath >> $SUBUNIT_OUT
590
591 cleanup_worker $worker
592 else
593 echo "[failed] $test_time"
594
595 (
596 (echo "Something went wrong running $tpath. Exited with $rc";
597 echo; echo; cat ${worker_outfiles[$worker]}
598 ) | subunit_fail_test $tpath
599 ) >> $SUBUNIT_OUT
600
601 FAILED_COUNT=$((FAILED_COUNT + 1))
602 FAILED_TESTS="$FAILED_TESTS $tname"
603
604 # Return 0 on failed tests in the -f mode
605 if [ -z "$force" ]
606 then
607
608 if [ -z "$DEBUG" ]
609 then
610 cleanup_worker $worker
611 else
612 DEBUG_WORKER=$worker
613 fi
614
615 return 1
616 else
617 cleanup_worker $worker
618
619 return 0
620 fi
621 fi
622
623}
624
625#############################################################################
626# Check if a specified worker has exceed TEST_TIMEOUT and if so, terminate it
627#############################################################################
628function check_timeout_for_worker()
629{
630 local worker=$1
631 local tpath=${worker_names[$worker]}
632 local tname=`basename $tpath .sh`
633
634 if (( `now` - worker_stime[$worker] > TEST_TIMEOUT ))
635 then
636 kill_worker $worker
637 printf "%-40s w%d\t" $tname $worker
638 echo "[failed] Timed out after $TEST_TIMEOUT seconds."
639
640 (
641 # Have to call subunit_start_test here, as currently tests cannot be
642 # interleaved in the subunit output
643 subunit_start_test $tpath "${worker_stime_txt[$worker]}"
644
645 (echo "Timeout exceeded running $tpath.";
646 echo; echo; cat ${worker_outfiles[$worker]}
647 ) | subunit_fail_test $tpath
648 ) >> $SUBUNIT_OUT
649
650 FAILED_COUNT=$((FAILED_COUNT + 1))
651 FAILED_TESTS="$FAILED_TESTS $tname"
652
653 # Return 0 on failed tests in the -f mode
654 if [ -z "$force" ]
655 then
656
657 if [ -z "$DEBUG" ]
658 then
659 cleanup_worker $worker
660 else
661 DEBUG_WORKER=$worker
662 fi
663
664 return 1
665 else
666 cleanup_worker $worker
667
668 return 0
669 fi
670 fi
671}
672#########################################################################
673# Wait for all currently running worker to finish
674#########################################################################
675function reap_all_workers()
676{
677 while true
678 do
679 found=""
680
681 for ((i = 1; i <= NWORKERS; i++))
682 do
683 [ -z ${worker_pids[$i]:-""} ] && continue
684
685 found="yes"
686
687 # Check if it's alive
688 if kill -0 ${worker_pids[$i]} >/dev/null 2>&1
689 then
690 check_timeout_for_worker $i || print_status_and_exit
691 continue
692 fi
693
694 reap_worker $i || print_status_and_exit
695
696 worker_pids[$i]=""
697 done
698
699 [ -z "$found" ] && break
700
701 sleep 1
702 done
703}
704
705########################################################################
706# Release all port locks reserved by the current process
707# Used by the EXIT trap (in both normal and abnormal shell termination)
708########################################################################
709function release_port_locks()
710{
711 local process=$1
712 local lockfile
713
714 # Suppress errors when no port lock files are found
715 shopt -s nullglob
716
717 for lockfile in /tmp/xtrabackup_port_lock.*
718 do
719 if [ "`cat $lockfile 2>/dev/null`" = $process ]
720 then
721 rm -rf $lockfile
722 fi
723 done
724
725 shopt -u nullglob
726}
727
728########################################################################
729# Report status and release port locks on exit
730########################################################################
731function cleanup_on_test_exit()
732{
733 local rc=$?
734
735 echo $rc > $STATUS_FILE
736
737 release_port_locks $$
738}
739
740########################################################################
741# Script body
742########################################################################
743
744TEST_START_TIME=`now`
241745
242tname=""746tname=""
243XTRACE_OPTION=""747XTRACE_OPTION=""
244XB_BUILD="autodetect"748XB_BUILD="autodetect"
245force=""749force=""
246KEEP_RESULTS=0
247SUBUNIT_OUT=test_results.subunit750SUBUNIT_OUT=test_results.subunit
248751NWORKERS=
249while getopts "fgh?:t:s:d:c:b:nr:" options; do752DEBUG_WORKER=""
250 case $options in753
251 f ) force="yes";;754while getopts "fgh?:t:s:d:c:j:T:" options; do
252 t ) tname="$OPTARG";;755 case $options in
253 g ) XTRACE_OPTION="-x"; DEBUG=on;;756 f ) force="yes";;
254 h ) usage; exit;;757 t )
255 s ) tname="$OPTARG/*.sh";;758
256 d ) export MYSQL_BASEDIR="$OPTARG";;759 tname="$OPTARG";
257 b ) TEST_BASEDIR="$OPTARG";;760 if ! [ -r "$tname" ]
258 c ) XB_BUILD="$OPTARG";;761 then
259 n ) KEEP_RESULTS=1;;762 echo "Cannot find test $tname."
260 r ) SUBUNIT_OUT="$OPTARG";;763 exit -1
261 ? ) echo "Use \`$0 -h' for the list of available options."764 fi
765 ;;
766
767 g ) DEBUG=on;;
768 h ) usage; exit;;
769 s ) tname="$OPTARG/*.sh";;
770 d ) export MYSQL_BASEDIR="$OPTARG";;
771 c ) XB_BUILD="$OPTARG";;
772 j )
773
774 if [[ ! $OPTARG =~ ^[0-9]+$ || $NWORKERS < 1 ]]
775 then
776 echo "Wrong -j argument: $OPTARG"
777 exit -1
778 fi
779 NWORKERS="$OPTARG"
780 ;;
781
782 T )
783 if [[ ! $OPTARG =~ ^[0-9]+$ ]]
784 then
785 echo "Wrong -T argument: $OPTARG"
786 exit -1
787 fi
788 TEST_TIMEOUT="$OPTARG"
789 ;;
790
791 ? ) echo "Use \`$0 -h' for the list of available options."
262 exit -1;;792 exit -1;;
263 esac793 esac
264done794done
265795
266if [ $KEEP_RESULTS -eq 0 ];
267then
268 rm -rf results
269 rm -f $SUBUNIT_OUT
270fi
271mkdir results
272
273set_vars796set_vars
274797
275if [ -n "$tname" ]798if [ -n "$tname" ]
@@ -279,13 +802,17 @@
279 tests="t/*.sh"802 tests="t/*.sh"
280fi803fi
281804
282failed_count=0
283failed_tests=
284total_count=0
285
286export OUTFILE="$PWD/results/setup"805export OUTFILE="$PWD/results/setup"
287806
288clean >>$OUTFILE 2>&1807rm -rf results
808mkdir results
809
810cleanup_all_workers >>$OUTFILE 2>&1
811
812rm -rf var test_results.subunit
813mkdir var
814
815echo "Detecting server version..." | tee -a $OUTFILE
289816
290if ! get_version_info817if ! get_version_info
291then818then
@@ -297,69 +824,99 @@
297 tee -a $OUTFILE824 tee -a $OUTFILE
298825
299echo "Using '`basename $XB_BIN`' as xtrabackup binary" | tee -a $OUTFILE826echo "Using '`basename $XB_BIN`' as xtrabackup binary" | tee -a $OUTFILE
827
828[ -z "$NWORKERS" ] && autocalc_nworkers
829
830if [ "$NWORKERS" -gt 1 ]
831then
832 echo "Using $NWORKERS parallel workers" | tee -a $OUTFILE
833fi
300echo | tee -a $OUTFILE834echo | tee -a $OUTFILE
301835
302kill_leftovers >>$OUTFILE 2>&1836cat <<EOF
303clean >>$OUTFILE 2>&1837==============================================================================
304838TEST WORKER RESULT TIME(s) or COMMENT
305source subunit.sh839------------------------------------------------------------------------------
306840EOF
307echo "========================================================================"
308841
309for t in $tests842for t in $tests
310do843do
311 total_count=$((total_count+1))844 # Check if we have available workers
312845 found=""
313 printf "%-40s" $t846
314 subunit_start_test $t >> $SUBUNIT_OUT847 while [ -z "$found" ]
848 do
849 for ((i = 1; i <= NWORKERS; i++))
850 do
851 if [ -z ${worker_pids[$i]:-""} ]
852 then
853 found="yes"
854 break
855 else
856 # Check if it's alive
857 if kill -0 ${worker_pids[$i]} >/dev/null 2>&1
858 then
859 check_timeout_for_worker $i || print_status_and_exit
860 continue
861 fi
862 reap_worker $i || print_status_and_exit
863
864 worker_pids[$i]=""
865 found="yes"
866
867 break
868 fi
869 done
870
871 if [ -z "$found" ]
872 then
873 sleep 1
874 fi
875 done
876
877 worker=$i
878
879 TOTAL_COUNT=$((TOTAL_COUNT+1))
880
315 name=`basename $t .sh`881 name=`basename $t .sh`
316 export OUTFILE="$PWD/results/$name"882 worker_names[$worker]=$t
317 export SKIPPED_REASON="$PWD/results/$name.skipped"883 worker_outfiles[$worker]="$PWD/results/$name"
318 bash $XTRACE_OPTION $t > $OUTFILE 2>&1884 worker_skip_files[$worker]="$PWD/results/$name.skipped"
319 rc=$?885 worker_status_files[$worker]="$PWD/results/$name.status"
320886 # Create a unique TMPDIR for each worker so that it can be removed as a part
321 if [[ -z "$DEBUG" || -n "$force" ]]887 # of the cleanup procedure. Server socket files will also be created there.
322 then888 worker_tmpdirs[$worker]="`mktemp -d -t xbtemp.XXXXXX`"
323 kill_leftovers >>$OUTFILE 2>&1889
324 clean >>$OUTFILE 2>&1890 (
325 fi891 set -eu
326892 if [ -n "$DEBUG" ]
327 if [ $rc -eq 0 ]
328 then
329 echo "[passed]"
330 subunit_pass_test $t >> $SUBUNIT_OUT
331 elif [ $rc -eq $SKIPPED_EXIT_CODE ]
332 then
333 sreason=""
334 test -r $SKIPPED_REASON && sreason=`cat $SKIPPED_REASON`
335 echo "[skipped] $sreason"
336 subunit_skip_test $t >> $SUBUNIT_OUT
337 else
338 echo "[failed]"
339
340 (
341 (echo "Something went wrong running $t. Exited with $rc";
342 echo; echo; cat $OUTFILE
343 ) | subunit_fail_test $t
344 ) >> $SUBUNIT_OUT
345
346 failed_count=$((failed_count+1))
347 failed_tests="$failed_tests $t"
348 result=1
349 if [ -z "$force" ]
350 then893 then
351 break;894 set -x
352 fi895 fi
353 fi 896
897 trap "cleanup_on_test_exit" EXIT
898
899 . inc/common.sh
900
901 export OUTFILE=${worker_outfiles[$worker]}
902 export SKIPPED_REASON=${worker_skip_files[$worker]}
903 export TEST_VAR_ROOT=$TEST_BASEDIR/var/w$worker
904 export TMPDIR=${worker_tmpdirs[$worker]}
905 export STATUS_FILE=${worker_status_files[$worker]}
906
907 mkdir $TEST_VAR_ROOT
908
909 . $t
910 ) > ${worker_outfiles[$worker]} 2>&1 &
911
912 worker_pids[$worker]=$!
913 worker_stime[$worker]="`now`"
914 # Used in subunit reports
915 worker_stime_txt[$worker]="`date -u '+%Y-%m-%d %H:%M:%S'`"
354done916done
355917
356echo "========================================================================"918# Wait for in-progress workers to finish
357echo919reap_all_workers
358920
359if [ $result -eq 1 ]921print_status_and_exit
360then922
361 echo
362 echo "$failed_count/$total_count tests have failed: $failed_tests"
363 echo "See results/ for detailed output"
364 exit -1
365fi
366923
=== modified file 'test/subunit.sh'
--- test/subunit.sh 2011-06-12 09:57:00 +0000
+++ test/subunit.sh 2013-07-04 07:51:31 +0000
@@ -15,8 +15,11 @@
15#15#
1616
17subunit_start_test () {17subunit_start_test () {
18 local stime=$2
18 # emit the current protocol start-marker for test $119 # emit the current protocol start-marker for test $1
19 echo "time: `date -u '+%Y-%m-%d %H:%M:%S'`"20 # adjust time by the number of seconds to execute the test to get the actual
21 # start time
22 echo "time: $stime"
20 echo "test: $1"23 echo "test: $1"
21}24}
2225
2326
=== modified file 'test/t/bug1085099.sh'
--- test/t/bug1085099.sh 2013-03-06 10:04:13 +0000
+++ test/t/bug1085099.sh 2013-07-04 07:51:31 +0000
@@ -13,9 +13,7 @@
13# Create a new tmpdir13# Create a new tmpdir
14mkdir $topdir/new_tmpdir14mkdir $topdir/new_tmpdir
1515
16# Make the default tmpdir inaccessible and make sure permissions are restored on16# Make the default tmpdir inaccessible
17# failure
18trap "chmod 755 $MYSQLD_TMPDIR" INT TERM EXIT
19chmod 000 $MYSQLD_TMPDIR17chmod 000 $MYSQLD_TMPDIR
2018
21innobackupex --tmpdir=$topdir/new_tmpdir --no-timestamp $topdir/backup19innobackupex --tmpdir=$topdir/new_tmpdir --no-timestamp $topdir/backup
2220
=== modified file 'test/t/bug664986.sh'
--- test/t/bug664986.sh 2013-03-03 11:01:19 +0000
+++ test/t/bug664986.sh 2013-07-04 07:51:31 +0000
@@ -15,14 +15,6 @@
1515
16EOF16EOF
1717
18# Make sure we restore permissions to not leave stale files in Jenkins
19# on a test failure
20trap "vlog restoring directories and files permissions ; \
21 chmod 777 $MYSQLD_DATADIR/test_bug664986_innodb; \
22 chmod 777 $MYSQLD_DATADIR/test_bug664986_myisam; \
23 chmod 644 $MYSQLD_DATADIR/test_bug664986_innodb/*; \
24 chmod 644 $MYSQLD_DATADIR/test_bug664986_myisam/*" INT TERM EXIT
25
26# Test that wrong directory permissions result in a backup failure18# Test that wrong directory permissions result in a backup failure
27# for both InnoDB and non-InnoDB files19# for both InnoDB and non-InnoDB files
28chmod 000 $MYSQLD_DATADIR/test_bug664986_innodb20chmod 000 $MYSQLD_DATADIR/test_bug664986_innodb
2921
=== modified file 'test/t/bug996493.sh'
--- test/t/bug996493.sh 2012-11-29 04:37:56 +0000
+++ test/t/bug996493.sh 2013-07-04 07:51:31 +0000
@@ -20,9 +20,6 @@
20vlog "Remove my.cnf"20vlog "Remove my.cnf"
21mv $topdir/my.cnf $topdir/my.cnf.bak21mv $topdir/my.cnf $topdir/my.cnf.bak
2222
23trap "vlog restoring $topdir/my.cnf ; \
24mv $topdir/my.cnf.bak $topdir/my.cnf" INT TERM EXIT
25
26vlog "Apply log"23vlog "Apply log"
27# Do not run innobackupex, because it pass option --defaults-file24# Do not run innobackupex, because it pass option --defaults-file
28# which we should avoid. Our goal is to test that backup-my.cnf25# which we should avoid. Our goal is to test that backup-my.cnf
@@ -31,7 +28,6 @@
3128
32vlog "Get my.cnf back"29vlog "Get my.cnf back"
33mv $topdir/my.cnf.bak $topdir/my.cnf30mv $topdir/my.cnf.bak $topdir/my.cnf
34trap "vlog test exit" INT TERM EXIT
3531
36vlog "Copy back"32vlog "Copy back"
37innobackupex --copy-back $backup_dir33innobackupex --copy-back $backup_dir
3834
=== modified file 'test/t/compact_compressed.sh'
--- test/t/compact_compressed.sh 2013-01-14 11:02:59 +0000
+++ test/t/compact_compressed.sh 2013-07-04 07:51:31 +0000
@@ -11,8 +11,13 @@
1111
12# Use innodb_strict_mode so that failure to use compression results in an 12# Use innodb_strict_mode so that failure to use compression results in an
13# error rather than a warning13# error rather than a warning
14mysqld_additional_args="--innodb_strict_mode --innodb_file_per_table \14MYSQLD_EXTRA_MY_CNF_OPTS="
15--innodb_file_format=Barracuda"15innodb_strict_mode
16innodb_file_per_table
17innodb_file_format=Barracuda
18# Set the minimal log file size to minimize xtrabackup_logfile
19# Recovering compressed pages is extremely slow with UNIV_ZIP_DEBUG
20innodb_log_file_size=1M"
1621
17#22#
18# Test compact backup of a compressed tablespace with a specific page size23# Test compact backup of a compressed tablespace with a specific page size
@@ -26,7 +31,7 @@
26 echo "Testing compact backup with compressed page size=${page_size}KB "31 echo "Testing compact backup with compressed page size=${page_size}KB "
27 echo "************************************************************************"32 echo "************************************************************************"
2833
29 start_server ${mysqld_additional_args}34 start_server
3035
31 load_dbase_schema sakila36 load_dbase_schema sakila
32 load_dbase_data sakila37 load_dbase_data sakila
@@ -52,7 +57,7 @@
5257
53 rm -r $mysql_datadir58 rm -r $mysql_datadir
5459
55 innobackupex --apply-log --rebuild-indexes $backup_dir60 innobackupex --apply-log --rebuild-indexes --rebuild-threads=2 $backup_dir
5661
57 vlog "Restoring MySQL datadir"62 vlog "Restoring MySQL datadir"
58 mkdir -p $mysql_datadir63 mkdir -p $mysql_datadir
@@ -63,7 +68,7 @@
63 verify_db_state sakila68 verify_db_state sakila
6469
65 stop_server70 stop_server
66 clean71 remove_var_dirs
67}72}
6873
6974
7075
=== modified file 'test/t/ib_stream_incremental.sh'
--- test/t/ib_stream_incremental.sh 2012-06-05 12:35:33 +0000
+++ test/t/ib_stream_incremental.sh 2013-07-04 07:51:31 +0000
@@ -98,7 +98,7 @@
98 exit -198 exit -1
99 fi99 fi
100 100
101 clean101 remove_var_dirs
102}102}
103103
104stream_format="xbstream"104stream_format="xbstream"
105105
=== modified file 'test/t/remote_tablespaces.sh'
--- test/t/remote_tablespaces.sh 2013-04-23 06:38:06 +0000
+++ test/t/remote_tablespaces.sh 2013-07-04 07:51:31 +0000
@@ -12,7 +12,7 @@
1212
13start_server --innodb_file_per_table13start_server --innodb_file_per_table
1414
15remote_dir=$TEST_BASEDIR/var1/remote_dir15remote_dir=$TEST_VAR_ROOT/var1/remote_dir
1616
17$MYSQL $MYSQL_ARGS test <<EOF17$MYSQL $MYSQL_ARGS test <<EOF
18CREATE TABLE t(id INT AUTO_INCREMENT PRIMARY KEY, c INT)18CREATE TABLE t(id INT AUTO_INCREMENT PRIMARY KEY, c INT)
1919
=== modified file 'test/t/undo_tablespaces.sh'
--- test/t/undo_tablespaces.sh 2013-04-27 18:46:54 +0000
+++ test/t/undo_tablespaces.sh 2013-07-04 07:51:31 +0000
@@ -23,7 +23,7 @@
23EOF23EOF
24}24}
2525
26undo_directory=$TEST_BASEDIR/var1/undo_dir26undo_directory=$TEST_VAR_ROOT/var1/undo_dir
2727
28MYSQLD_EXTRA_MY_CNF_OPTS="28MYSQLD_EXTRA_MY_CNF_OPTS="
29innodb_file_per_table=129innodb_file_per_table=1
3030
=== modified file 'test/t/xb_encrypt.sh'
--- test/t/xb_encrypt.sh 2013-03-11 19:11:29 +0000
+++ test/t/xb_encrypt.sh 2013-07-04 07:51:31 +0000
@@ -5,8 +5,6 @@
5encrypt_algo="AES256"5encrypt_algo="AES256"
6encrypt_key="percona_xtrabackup_is_awesome___"6encrypt_key="percona_xtrabackup_is_awesome___"
77
8echo -n "Percona XtraBackup is awesome!!!" > $encrypt_key_file
9
10innobackupex_options="--encrypt=$encrypt_algo --encrypt-key=$encrypt_key --encrypt-threads=4 --encrypt-chunk-size=8K"8innobackupex_options="--encrypt=$encrypt_algo --encrypt-key=$encrypt_key --encrypt-threads=4 --encrypt-chunk-size=8K"
11data_decrypt_cmd="for i in *.xbcrypt; do \9data_decrypt_cmd="for i in *.xbcrypt; do \
12xbcrypt -d -a $encrypt_algo -k $encrypt_key < \$i > \${i:0:\${#i}-8}; \10xbcrypt -d -a $encrypt_algo -k $encrypt_key < \$i > \${i:0:\${#i}-8}; \
1311
=== modified file 'test/t/xb_part_range.sh'
--- test/t/xb_part_range.sh 2012-07-06 05:13:15 +0000
+++ test/t/xb_part_range.sh 2013-07-04 07:51:31 +0000
@@ -1,19 +1,9 @@
1. inc/common.sh1. inc/common.sh
2. inc/ib_part.sh
23
3start_server4start_server
45
5function check_partitioning()6require_partitioning
6{
7 $MYSQL $MYSQL_ARGS -Ns -e "show variables like 'have_partitioning'"
8}
9
10PARTITION_CHECK=`check_partitioning`
11
12if [ -z "$PARTITION_CHECK" ]; then
13 echo "Requires Partitioning." > $SKIPPED_REASON
14 stop_server
15 exit $SKIPPED_EXIT_CODE
16fi
177
18run_cmd $MYSQL $MYSQL_ARGS test <<EOF8run_cmd $MYSQL $MYSQL_ARGS test <<EOF
19CREATE TABLE test (9CREATE TABLE test (
2010
=== modified file 'test/t/xb_perm_basic.sh'
--- test/t/xb_perm_basic.sh 2012-10-15 16:14:59 +0000
+++ test/t/xb_perm_basic.sh 2013-07-04 07:51:31 +0000
@@ -4,6 +4,4 @@
4start_server4start_server
55
6chmod -R 500 $mysql_datadir6chmod -R 500 $mysql_datadir
7trap "vlog restoring permissions on datadir $mysql_datadir ; \
8chmod -R 700 $mysql_datadir" INT TERM EXIT
9innobackupex --no-timestamp $topdir/backup7innobackupex --no-timestamp $topdir/backup
108
=== modified file 'test/t/xb_perm_stream.sh'
--- test/t/xb_perm_stream.sh 2012-10-15 16:14:59 +0000
+++ test/t/xb_perm_stream.sh 2013-07-04 07:51:31 +0000
@@ -5,7 +5,5 @@
55
6# Take backup6# Take backup
7chmod -R 500 $mysql_datadir7chmod -R 500 $mysql_datadir
8trap "vlog restoring permissions on datadir $mysql_datadir ; \
9chmod -R 700 $mysql_datadir" INT TERM EXIT
10mkdir -p $topdir/backup8mkdir -p $topdir/backup
11innobackupex --stream=tar $topdir/backup > $topdir/backup/out.tar9innobackupex --stream=tar $topdir/backup > $topdir/backup/out.tar
1210
=== modified file 'test/t/xb_stats_datadir.sh'
--- test/t/xb_stats_datadir.sh 2013-05-02 13:05:59 +0000
+++ test/t/xb_stats_datadir.sh 2013-07-04 07:51:31 +0000
@@ -5,12 +5,11 @@
55
6. inc/common.sh6. inc/common.sh
77
8mkdir ${TEST_BASEDIR}/logs8logdir=${TEST_VAR_ROOT}/logs
99mkdir $logdir
10trap "rm -rf ${TEST_BASEDIR}/logs" INT TERM EXIT
1110
12MYSQLD_EXTRA_MY_CNF_OPTS="11MYSQLD_EXTRA_MY_CNF_OPTS="
13innodb_log_group_home_dir=${TEST_BASEDIR}/logs12innodb_log_group_home_dir=$logdir
14"13"
1514
16start_server15start_server
@@ -28,6 +27,6 @@
28# we pass all necessary options as an arguments, so if someday this27# we pass all necessary options as an arguments, so if someday this
29# will be changed, test still will work28# will be changed, test still will work
30xtrabackup --stats --datadir=${MYSQLD_DATADIR} \29xtrabackup --stats --datadir=${MYSQLD_DATADIR} \
31 --innodb_log_group_home_dir=${TEST_BASEDIR}/logs30 --innodb_log_group_home_dir=$logdir
3231
33vlog "stats did not fail"32vlog "stats did not fail"
3433
=== removed file 'test/testrun.c'
--- test/testrun.c 2013-06-14 00:59:24 +0000
+++ test/testrun.c 1970-01-01 00:00:00 +0000
@@ -1,405 +0,0 @@
1/*
2 * testrun.c - a parallel test runner for the XtraBackup test suite
3 */
4/* BEGIN LICENSE
5 * Copyright (C) 2012 Percona Ireland Ltd.
6 *
7 * Written by Stewart Smith
8 *
9 * This program is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2, as published
11 * by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranties of
15 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
16 * PURPOSE. See the GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 * END LICENSE */
21
22#include <stdio.h>
23#include <unistd.h>
24#include <dirent.h>
25#include <string.h>
26#include <limits.h>
27#include <stdlib.h>
28#include <sys/select.h>
29
30#include <sys/stat.h>
31#include <sys/types.h>
32#include <sys/wait.h>
33#include <fcntl.h>
34#include <assert.h>
35
36#include <signal.h>
37
38struct testcase
39{
40 char *name;
41 char *buf;
42 size_t end_of_buf;
43 size_t bufsz;
44};
45
46pid_t *childpid;
47int nchildpid=0;
48
49static void kill_children(int sig)
50{
51 int i;
52 int status;
53
54 (void)sig;
55
56 fprintf(stderr, "Killing child processes...\n");
57
58 for(i=0; i<nchildpid; i++)
59 if(childpid[i] > 0)
60 {
61 kill(childpid[i], SIGKILL);
62 wait(&status);
63 }
64
65 exit(EXIT_SUCCESS);
66}
67
68int collect_testcases_filter(const struct dirent *a)
69{
70 int l;
71
72 if (a->d_name[0] == '.')
73 return 0;
74
75 l= strlen(a->d_name);
76
77 if (l > 2 && strncmp(a->d_name + l - 3, ".sh", 3)==0)
78 return 1;
79
80 return 0;
81}
82
83static int collect_testcases(const char* suitedir, struct testcase **cases)
84{
85 struct dirent **namelist;
86 int n;
87 int i;
88
89 n= scandir(suitedir, &namelist, collect_testcases_filter, alphasort);
90
91 *cases= (struct testcase*) malloc(sizeof(struct testcase)*n);
92
93 for(i=0; i<n; i++)
94 {
95 (*cases)[i].name= strdup(namelist[i]->d_name);
96 (*cases)[i].buf= NULL;
97 (*cases)[i].end_of_buf= 0;
98 (*cases)[i].bufsz= 0;
99 free(namelist[i]);
100 }
101
102 free(namelist);
103
104 return n;
105}
106
107static void free_testcases(struct testcase *cases, int n)
108{
109 while (n>0)
110 {
111 free(cases[--n].name);
112 }
113 free(cases);
114}
115
116static int run_testcase_in_child(int nr, struct testcase *t, pid_t *cpid, const char* xbtarget)
117{
118 int fd[2];
119
120 printf("[%d] LAUNCHING - %s\n", nr, t->name);
121
122 if (pipe(fd) == -1)
123 {
124 perror("pipe");
125 exit(EXIT_FAILURE);
126 }
127
128 *cpid= fork();
129 if (*cpid == 0)
130 {
131 /* child */
132 close(fd[0]);
133
134 char tname[500];
135 snprintf(tname, sizeof(tname), "t/%s",t->name);
136
137 char basedir[PATH_MAX];
138 char cwd[PATH_MAX];
139 snprintf(basedir, sizeof(basedir), "%s/var/%d", getcwd(cwd,sizeof(cwd)), nr);
140
141 mkdir("var",0700);
142 mkdir(basedir,0700);
143
144 char logname[PATH_MAX];
145 snprintf(logname, sizeof(logname), "%s/var/%d.log", getcwd(cwd,sizeof(cwd)), nr);
146
147 int logfd= open(logname, O_WRONLY|O_APPEND|O_CREAT, 0600);
148 dup2(logfd, STDOUT_FILENO);
149 dup2(logfd, STDERR_FILENO);
150 close(logfd);
151
152 char subunitfd[50];
153 snprintf(subunitfd, sizeof(subunitfd), "/dev/fd/%d", fd[1]);
154
155 char* xbtarget_param;
156 if (xbtarget)
157 xbtarget_param= strdup(xbtarget);
158 else
159 xbtarget_param= NULL;
160
161 char *const newargv[] = {"testrun.sh", "-n",
162 "-t", tname,
163 "-b", basedir,
164 "-r", subunitfd,
165 (xbtarget)? "-c" : NULL, xbtarget_param,
166 NULL };
167 char *newenviron[] = { NULL };
168 execve(newargv[0], newargv, newenviron);
169 perror("execve");
170 exit(EXIT_FAILURE);
171 }
172 else
173 {
174 /* parent */
175 close(fd[1]);
176 fcntl(fd[0], F_SETFL, O_NONBLOCK);
177 return fd[0];
178 }
179}
180
181static inline void subunit_progress_sign(int fd, int n, char *sign)
182{
183 char *buf;
184 const char* fmt= "progress: %s%d\n";
185 size_t sz= 1+strlen(fmt)+100;
186 size_t l;
187
188 buf= (char*)malloc(sz);
189
190 l= snprintf(buf, sz, fmt, sign, n);
191 assert(l < sz);
192
193 write(fd, buf, l);
194
195 free(buf);
196}
197
198static void run_testcases(struct testcase *testcases, int nrcases,
199 int njobs, int timeout, const char* xbtarget)
200{
201 int childfd[njobs];
202 int nfds= 0;
203 int retval;
204 pid_t chpid[njobs];
205 int status;
206 int next_testcase= 0;
207 int i;
208 fd_set rfds;
209 fd_set efds;
210 struct timeval tv;
211 int nchildren;
212 int childtest[njobs];
213
214 int subunitfd= open("test_results.subunit", O_TRUNC|O_WRONLY|O_APPEND|O_CREAT, 0600);
215 subunit_progress_sign(subunitfd, nrcases, "");
216
217 if (nrcases < njobs)
218 njobs= nrcases;
219
220 childpid= chpid;
221 nchildpid= njobs;
222
223 for(i=0; i<njobs; i++)
224 {
225 childtest[i]=next_testcase++;
226 childfd[i]= run_testcase_in_child(i, &testcases[childtest[i]], &childpid[i], xbtarget);
227 }
228
229 fflush(stdout);
230
231loop:
232 FD_ZERO(&efds);
233 FD_ZERO(&rfds);
234
235 nchildren=0;
236
237 for (i=0; i<njobs; i++)
238 {
239 if (childfd[i] != -1)
240 {
241 FD_SET(childfd[i], &efds);
242 FD_SET(childfd[i], &rfds);
243 nfds= (childfd[i] > nfds)? childfd[i] : nfds;
244 nchildren++;
245 }
246 }
247
248 tv.tv_sec= timeout;
249 tv.tv_usec= 0;
250
251 retval = select(nfds+1, &rfds, NULL, &efds, &tv);
252
253 if (retval == -1)
254 perror("select()");
255 else if (retval)
256 {
257 int childexited=0;
258
259 for (i=0; i<njobs; i++)
260 {
261 if(childfd[i] != -1
262 && (FD_ISSET(childfd[i], &efds) || FD_ISSET(childfd[i], &rfds)))
263 {
264 ssize_t r=0;
265
266 do {
267 struct testcase *t= &testcases[childtest[i]];
268
269 if(t->bufsz == t->end_of_buf)
270 {
271 t->bufsz+=4000;
272 t->buf= (char*)realloc(t->buf, t->bufsz);
273 }
274
275 r= read(childfd[i], t->buf+t->end_of_buf, t->bufsz - t->end_of_buf);
276 if (r>0)
277 t->end_of_buf+= r;
278 } while(r>0);
279
280 pid_t waited= waitpid(childpid[i], &status, WNOHANG);
281 if (!(WIFEXITED(status) || WIFSIGNALED(status)))
282 continue;
283
284 if (waited != childpid[i])
285 continue;
286
287 write(subunitfd, testcases[childtest[i]].buf,
288 testcases[childtest[i]].end_of_buf);
289
290 close(childfd[i]);
291 printf("[%d] completed %s status %d\n",
292 i, testcases[childtest[i]].name, WEXITSTATUS(status));
293 childfd[i]=-1;
294 nchildren--;
295
296 if (next_testcase < nrcases)
297 {
298 childtest[i]=next_testcase++;
299 childfd[i]= run_testcase_in_child(i, &testcases[childtest[i]], &childpid[i], xbtarget);
300 nfds= (childfd[i] > nfds)? childfd[i] : nfds;
301 nchildren++;
302 }
303 printf("\nnrchildren= %d, %d tests remaining\n",
304 nchildren, nrcases-next_testcase);
305 childexited=1;
306 fflush(stdout);
307 }
308 }
309 if (childexited)
310 {
311 printf ("Running: ");
312 for(i=0; i<njobs; i++)
313 if (childfd[i] != -1)
314 printf("%s ",testcases[childtest[i]].name);
315 printf("\n");
316 }
317 }
318 else
319 {
320 printf("Timeout\n");
321 kill_children(SIGKILL);
322 exit(EXIT_FAILURE);
323 }
324
325 if (nchildren==0)
326 goto end;
327
328 goto loop;
329
330end:
331
332 close(subunitfd);
333 return;
334}
335
336int main(int argc, char* argv[])
337{
338 const char* suitedir= "t/";
339 int njobs= 4;
340 int opt;
341 int nrcases;
342 struct testcase *testcases;
343 int timeout= 600;
344 const char* xbtarget= NULL;
345
346 struct sigaction sa;
347
348 sa.sa_flags= 0;
349 sigemptyset(&sa.sa_mask);
350 sa.sa_handler = kill_children;
351 sigaction(SIGHUP, &sa, NULL);
352 sigaction(SIGINT, &sa, NULL);
353 sigaction(SIGQUIT, &sa, NULL);
354
355#ifdef _SC_NPROCESSORS_ONLN
356 njobs= sysconf(_SC_NPROCESSORS_ONLN);
357#endif
358
359#ifdef _SC_PHYS_PAGES
360 long nrpages= sysconf(_SC_PHYS_PAGES);
361 long pagesize= sysconf(_SC_PAGESIZE);
362 long pages_per_job= (128*(1 << 20)) / pagesize;
363 nrpages= nrpages/2;
364 if ((pages_per_job * njobs) > nrpages)
365 njobs= nrpages / pages_per_job;
366#endif
367
368 if (njobs == 0)
369 njobs= 1;
370
371 while ((opt = getopt(argc, argv, "j:s:t:c:")) != -1)
372 {
373 switch (opt) {
374 case 'c':
375 xbtarget= optarg;
376 break;
377 case 's':
378 suitedir= optarg;
379 break;
380 case 'j':
381 njobs= atoi(optarg);
382 break;
383 case 't':
384 timeout= atoi(optarg);
385 break;
386 default:
387 fprintf(stderr, "Usage: %s [-s suite] [-j parallel] [-t timeout]\n",
388 argv[0]);
389 exit(EXIT_FAILURE);
390 }
391 }
392
393 printf("%s running with: -s %s -j %d -t %d\n\n",
394 argv[0], suitedir,njobs, timeout);
395
396 nrcases= collect_testcases(suitedir, &testcases);
397
398 printf("Found %d testcases\n", nrcases);
399
400 run_testcases(testcases, nrcases, njobs, timeout, xbtarget);
401
402 free_testcases(testcases, nrcases);
403
404 return 0;
405}

Subscribers

People subscribed via source and target branches

to all changes: