Merge lp:~akopytov/percona-xtrabackup/test-suite-cleanups-2.1 into lp:percona-xtrabackup/2.1
- test-suite-cleanups-2.1
- Merge into 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 | ||||||||||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
George Ormond Lorch III (community) | g2 | Approve | |
Stewart Smith | Pending | ||
Review via email: mp+172963@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) wrote : | # |
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
1 | === modified file 'patches/innodb56.patch' | |||
2 | --- patches/innodb56.patch 2013-07-01 12:21:20 +0000 | |||
3 | +++ patches/innodb56.patch 2013-07-04 07:51:31 +0000 | |||
4 | @@ -1431,4 +1431,20 @@ | |||
5 | 1431 | int main() | 1431 | int main() |
6 | 1432 | { | 1432 | { |
7 | 1433 | extern void __attribute__((weak)) foo(void); | 1433 | extern void __attribute__((weak)) foo(void); |
9 | 1434 | 1434 | --- a/mysys/my_thr_init.c | |
10 | 1435 | +++ b/mysys/my_thr_init.c | ||
11 | 1436 | @@ -462,8 +462,12 @@ | ||
12 | 1437 | |||
13 | 1438 | extern void **my_thread_var_dbug() | ||
14 | 1439 | { | ||
15 | 1440 | - struct st_my_thread_var *tmp= | ||
16 | 1441 | - my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys); | ||
17 | 1442 | + struct st_my_thread_var *tmp; | ||
18 | 1443 | + | ||
19 | 1444 | + if (!my_thread_global_init_done) | ||
20 | 1445 | + return NULL; | ||
21 | 1446 | + | ||
22 | 1447 | + tmp= my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys); | ||
23 | 1448 | return tmp && tmp->init ? &tmp->dbug : 0; | ||
24 | 1449 | } | ||
25 | 1450 | #endif /* DBUG_OFF */ | ||
26 | 1435 | 1451 | ||
27 | === modified file 'src/xtrabackup.cc' | |||
28 | --- src/xtrabackup.cc 2013-06-18 14:49:01 +0000 | |||
29 | +++ src/xtrabackup.cc 2013-07-04 07:51:31 +0000 | |||
30 | @@ -3835,6 +3835,8 @@ | |||
31 | 3835 | 3835 | ||
32 | 3836 | ulint fold; | 3836 | ulint fold; |
33 | 3837 | 3837 | ||
34 | 3838 | bool checkpoint_found; | ||
35 | 3839 | |||
36 | 3838 | max_no = ut_dulint_zero; | 3840 | max_no = ut_dulint_zero; |
37 | 3839 | 3841 | ||
38 | 3840 | if (!xb_init_log_block_size()) { | 3842 | if (!xb_init_log_block_size()) { |
39 | @@ -3949,6 +3951,8 @@ | |||
40 | 3949 | // ' ', 4); | 3951 | // ' ', 4); |
41 | 3950 | } | 3952 | } |
42 | 3951 | 3953 | ||
43 | 3954 | checkpoint_found = false; | ||
44 | 3955 | |||
45 | 3952 | /* read last checkpoint lsn */ | 3956 | /* read last checkpoint lsn */ |
46 | 3953 | for (field = LOG_CHECKPOINT_1; field <= LOG_CHECKPOINT_2; | 3957 | for (field = LOG_CHECKPOINT_1; field <= LOG_CHECKPOINT_2; |
47 | 3954 | field += LOG_CHECKPOINT_2 - LOG_CHECKPOINT_1) { | 3958 | field += LOG_CHECKPOINT_2 - LOG_CHECKPOINT_1) { |
48 | @@ -3961,25 +3965,13 @@ | |||
49 | 3961 | if (ut_dulint_cmp(checkpoint_no, max_no) >= 0) { | 3965 | if (ut_dulint_cmp(checkpoint_no, max_no) >= 0) { |
50 | 3962 | max_no = checkpoint_no; | 3966 | max_no = checkpoint_no; |
51 | 3963 | max_lsn = MACH_READ_64(log_buf + field + LOG_CHECKPOINT_LSN); | 3967 | max_lsn = MACH_READ_64(log_buf + field + LOG_CHECKPOINT_LSN); |
65 | 3964 | /* | 3968 | checkpoint_found = true; |
53 | 3965 | mach_write_to_4(log_buf + field + LOG_CHECKPOINT_OFFSET, | ||
54 | 3966 | LOG_FILE_HDR_SIZE + ut_dulint_minus(max_lsn, | ||
55 | 3967 | ut_dulint_align_down(max_lsn,OS_FILE_LOG_BLOCK_SIZE))); | ||
56 | 3968 | |||
57 | 3969 | ulint fold; | ||
58 | 3970 | fold = ut_fold_binary(log_buf + field, LOG_CHECKPOINT_CHECKSUM_1); | ||
59 | 3971 | mach_write_to_4(log_buf + field + LOG_CHECKPOINT_CHECKSUM_1, fold); | ||
60 | 3972 | |||
61 | 3973 | fold = ut_fold_binary(log_buf + field + LOG_CHECKPOINT_LSN, | ||
62 | 3974 | LOG_CHECKPOINT_CHECKSUM_2 - LOG_CHECKPOINT_LSN); | ||
63 | 3975 | mach_write_to_4(log_buf + field + LOG_CHECKPOINT_CHECKSUM_2, fold); | ||
64 | 3976 | */ | ||
66 | 3977 | } | 3969 | } |
67 | 3978 | not_consistent: | 3970 | not_consistent: |
68 | 3979 | ; | 3971 | ; |
69 | 3980 | } | 3972 | } |
70 | 3981 | 3973 | ||
72 | 3982 | if (ut_dulint_cmp(max_no, ut_dulint_zero) == 0) { | 3974 | if (!checkpoint_found) { |
73 | 3983 | msg("xtrabackup: No valid checkpoint found.\n"); | 3975 | msg("xtrabackup: No valid checkpoint found.\n"); |
74 | 3984 | goto error; | 3976 | goto error; |
75 | 3985 | } | 3977 | } |
76 | 3986 | 3978 | ||
77 | === modified file 'test/inc/common.sh' | |||
78 | --- test/inc/common.sh 2013-06-28 15:23:23 +0000 | |||
79 | +++ test/inc/common.sh 2013-07-04 07:51:31 +0000 | |||
80 | @@ -16,9 +16,12 @@ | |||
81 | 16 | } | 16 | } |
82 | 17 | 17 | ||
83 | 18 | 18 | ||
85 | 19 | function clean() | 19 | ######################################################################## |
86 | 20 | # Remove server var* directories from the worker's var root | ||
87 | 21 | ######################################################################## | ||
88 | 22 | function remove_var_dirs() | ||
89 | 20 | { | 23 | { |
91 | 21 | rm -rf ${TEST_BASEDIR}/var[0-9] | 24 | rm -rf ${TEST_VAR_ROOT}/var[0-9] |
92 | 22 | } | 25 | } |
93 | 23 | 26 | ||
94 | 24 | function die() | 27 | function die() |
95 | @@ -34,29 +37,33 @@ | |||
96 | 34 | $MYSQL_INSTALL_DB --defaults-file=${MYSQLD_VARDIR}/my.cnf \ | 37 | $MYSQL_INSTALL_DB --defaults-file=${MYSQLD_VARDIR}/my.cnf \ |
97 | 35 | --basedir=${MYSQL_BASEDIR} \ | 38 | --basedir=${MYSQL_BASEDIR} \ |
98 | 36 | ${MYSQLD_EXTRA_ARGS} | 39 | ${MYSQLD_EXTRA_ARGS} |
100 | 37 | cd - | 40 | cd - >/dev/null 2>&1 |
101 | 38 | } | 41 | } |
102 | 39 | 42 | ||
103 | 40 | ######################################################################## | 43 | ######################################################################## |
105 | 41 | # Checks whether MySQL is alive | 44 | # Checks whether MySQL with the PID specified as an argument is alive |
106 | 42 | ######################################################################## | 45 | ######################################################################## |
107 | 43 | function mysql_ping() | 46 | function mysql_ping() |
108 | 44 | { | 47 | { |
111 | 45 | $MYSQLADMIN $MYSQL_ARGS --wait=100 ping >/dev/null 2>&1 || return 1 | 48 | local pid=$1 |
112 | 46 | } | 49 | local attempts=60 |
113 | 50 | local i | ||
114 | 47 | 51 | ||
119 | 48 | function kill_leftovers() | 52 | for ((i=1; i<=attempts; i++)) |
116 | 49 | { | ||
117 | 50 | local file | ||
118 | 51 | for file in ${TEST_BASEDIR}/mysqld*.pid | ||
120 | 52 | do | 53 | do |
127 | 53 | if [ -f $file ] | 54 | $MYSQLADMIN $MYSQL_ARGS ping >/dev/null 2>&1 && return 0 |
128 | 54 | then | 55 | sleep 1 |
129 | 55 | vlog "Found a leftover mysqld processes with PID `cat $file`, stopping it" | 56 | # Is the server process still alive? |
130 | 56 | kill -9 `cat $file` 2>/dev/null || true | 57 | if ! kill -0 $pid >/dev/null 2>&1 |
131 | 57 | rm -f $file | 58 | then |
132 | 58 | fi | 59 | vlog "Server process PID=$pid died." |
133 | 60 | wait $pid | ||
134 | 61 | return 1 | ||
135 | 62 | fi | ||
136 | 63 | vlog "Made $i attempts to connect to server" | ||
137 | 59 | done | 64 | done |
138 | 65 | |||
139 | 66 | return 1 | ||
140 | 60 | } | 67 | } |
141 | 61 | 68 | ||
142 | 62 | function run_cmd() | 69 | function run_cmd() |
143 | @@ -123,21 +130,14 @@ | |||
144 | 123 | local port | 130 | local port |
145 | 124 | local lockfile | 131 | local lockfile |
146 | 125 | 132 | ||
148 | 126 | for (( port=PORT_BASE+id; port < 65535; port++)) | 133 | for (( port=3307 + RANDOM; port < 65535; port++)) |
149 | 127 | do | 134 | do |
150 | 128 | lockfile="/tmp/xtrabackup_port_lock.$port" | 135 | lockfile="/tmp/xtrabackup_port_lock.$port" |
151 | 129 | # Try to atomically lock the current port number | 136 | # Try to atomically lock the current port number |
153 | 130 | if ! set -C > $lockfile | 137 | if ! (set -C; > $lockfile) |
154 | 131 | then | 138 | then |
162 | 132 | set +C | 139 | continue; |
156 | 133 | # check if the process still exists | ||
157 | 134 | if kill -0 "`cat $lockfile`" | ||
158 | 135 | then | ||
159 | 136 | continue; | ||
160 | 137 | fi | ||
161 | 138 | # stale file, overwrite it with the current PID | ||
163 | 139 | fi | 140 | fi |
164 | 140 | set +C | ||
165 | 141 | echo $$ > $lockfile | 141 | echo $$ > $lockfile |
166 | 142 | if ! nc -z -w1 localhost $port >/dev/null 2>&1 | 142 | if ! nc -z -w1 localhost $port >/dev/null 2>&1 |
167 | 143 | then | 143 | then |
168 | @@ -173,14 +173,14 @@ | |||
169 | 173 | fi | 173 | fi |
170 | 174 | 174 | ||
171 | 175 | SRV_MYSQLD_IDS[$id]="$id" | 175 | SRV_MYSQLD_IDS[$id]="$id" |
173 | 176 | local vardir="${TEST_BASEDIR}/var${id}" | 176 | local vardir="${TEST_VAR_ROOT}/var${id}" |
174 | 177 | SRV_MYSQLD_VARDIR[$id]="$vardir" | 177 | SRV_MYSQLD_VARDIR[$id]="$vardir" |
175 | 178 | SRV_MYSQLD_DATADIR[$id]="$vardir/data" | 178 | SRV_MYSQLD_DATADIR[$id]="$vardir/data" |
176 | 179 | SRV_MYSQLD_TMPDIR[$id]="$vardir/tmp" | 179 | SRV_MYSQLD_TMPDIR[$id]="$vardir/tmp" |
178 | 180 | SRV_MYSQLD_PIDFILE[$id]="${TEST_BASEDIR}/mysqld${id}.pid" | 180 | SRV_MYSQLD_PIDFILE[$id]="${TEST_VAR_ROOT}/mysqld${id}.pid" |
179 | 181 | SRV_MYSQLD_ERRFILE[$id]="$vardir/data/mysqld${id}.err" | 181 | SRV_MYSQLD_ERRFILE[$id]="$vardir/data/mysqld${id}.err" |
180 | 182 | SRV_MYSQLD_PORT[$id]=`get_free_port $id` | 182 | SRV_MYSQLD_PORT[$id]=`get_free_port $id` |
182 | 183 | SRV_MYSQLD_SOCKET[$id]=`mktemp -t xtrabackup.mysql.sock.XXXXXX` | 183 | SRV_MYSQLD_SOCKET[$id]=`mktemp -t mysql.sock.XXXXXX` |
183 | 184 | } | 184 | } |
184 | 185 | 185 | ||
185 | 186 | ######################################################################## | 186 | ######################################################################## |
186 | @@ -245,27 +245,36 @@ | |||
187 | 245 | function start_server_with_id() | 245 | function start_server_with_id() |
188 | 246 | { | 246 | { |
189 | 247 | local id=$1 | 247 | local id=$1 |
190 | 248 | local attempts=0 | ||
191 | 249 | local max_attempts=5 | ||
192 | 248 | shift | 250 | shift |
193 | 249 | 251 | ||
194 | 250 | vlog "Starting server with id=$id..." | 252 | vlog "Starting server with id=$id..." |
195 | 251 | 253 | ||
213 | 252 | init_server_variables $id | 254 | while true |
214 | 253 | switch_server $id | 255 | do |
215 | 254 | 256 | init_server_variables $id | |
216 | 255 | if [ ! -d "$MYSQLD_VARDIR" ] | 257 | switch_server $id |
217 | 256 | then | 258 | |
218 | 257 | vlog "Creating server root directory: $MYSQLD_VARDIR" | 259 | if [ ! -d "$MYSQLD_VARDIR" ] |
219 | 258 | mkdir "$MYSQLD_VARDIR" | 260 | then |
220 | 259 | fi | 261 | vlog "Creating server root directory: $MYSQLD_VARDIR" |
221 | 260 | if [ ! -d "$MYSQLD_TMPDIR" ] | 262 | mkdir "$MYSQLD_VARDIR" |
222 | 261 | then | 263 | fi |
223 | 262 | vlog "Creating server temporary directory: $MYSQLD_TMPDIR" | 264 | if [ ! -d "$MYSQLD_TMPDIR" ] |
224 | 263 | mkdir "$MYSQLD_TMPDIR" | 265 | then |
225 | 264 | fi | 266 | vlog "Creating server temporary directory: $MYSQLD_TMPDIR" |
226 | 265 | 267 | mkdir "$MYSQLD_TMPDIR" | |
227 | 266 | # Create the configuration file used by mysql_install_db, the server | 268 | fi |
228 | 267 | # and the xtrabackup binary | 269 | |
229 | 268 | cat > ${MYSQLD_VARDIR}/my.cnf <<EOF | 270 | if [ -f "$MYSQLD_ERRFILE" ] |
230 | 271 | then | ||
231 | 272 | rm "$MYSQLD_ERRFILE" | ||
232 | 273 | fi | ||
233 | 274 | |||
234 | 275 | # Create the configuration file used by mysql_install_db, the server | ||
235 | 276 | # and the xtrabackup binary | ||
236 | 277 | cat > ${MYSQLD_VARDIR}/my.cnf <<EOF | ||
237 | 269 | [mysqld] | 278 | [mysqld] |
238 | 270 | socket=${MYSQLD_SOCKET} | 279 | socket=${MYSQLD_SOCKET} |
239 | 271 | port=${MYSQLD_PORT} | 280 | port=${MYSQLD_PORT} |
240 | @@ -285,22 +294,42 @@ | |||
241 | 285 | user=root | 294 | user=root |
242 | 286 | EOF | 295 | EOF |
243 | 287 | 296 | ||
260 | 288 | # Create datadir and call mysql_install_db if it doesn't exist | 297 | # Create datadir and call mysql_install_db if it doesn't exist |
261 | 289 | if [ ! -d "$MYSQLD_DATADIR" ] | 298 | if [ ! -d "$MYSQLD_DATADIR" ] |
262 | 290 | then | 299 | then |
263 | 291 | vlog "Creating server data directory: $MYSQLD_DATADIR" | 300 | vlog "Creating server data directory: $MYSQLD_DATADIR" |
264 | 292 | mkdir -p "$MYSQLD_DATADIR" | 301 | mkdir -p "$MYSQLD_DATADIR" |
265 | 293 | call_mysql_install_db | 302 | call_mysql_install_db |
266 | 294 | fi | 303 | fi |
267 | 295 | 304 | ||
268 | 296 | # Start the server | 305 | # Start the server |
269 | 297 | echo "Starting ${MYSQLD} ${MYSQLD_ARGS} $* " | 306 | echo "Starting ${MYSQLD} ${MYSQLD_ARGS} $* " |
270 | 298 | ${MYSQLD} ${MYSQLD_ARGS} $* & | 307 | ${MYSQLD} ${MYSQLD_ARGS} $* & |
271 | 299 | if ! mysql_ping | 308 | if ! mysql_ping $! |
272 | 300 | then | 309 | then |
273 | 301 | die "Can't start the server!" | 310 | if grep "another mysqld server running on port" $MYSQLD_ERRFILE |
274 | 302 | fi | 311 | then |
275 | 303 | vlog "Server with id=$id has been started on port $MYSQLD_PORT, \ | 312 | if ((++attempts < max_attempts)) |
276 | 313 | then | ||
277 | 314 | vlog "Made $attempts attempts to find a free port" | ||
278 | 315 | reset_server_variables $id | ||
279 | 316 | free_reserved_port $MYSQLD_PORT | ||
280 | 317 | continue | ||
281 | 318 | else | ||
282 | 319 | vlog "Failed to find a free port after $attempts attempts" | ||
283 | 320 | fi | ||
284 | 321 | fi | ||
285 | 322 | vlog "Can't start the server. Server log (if exists):" | ||
286 | 323 | vlog "----------------" | ||
287 | 324 | cat ${MYSQLD_ERRFILE} >&2 || true | ||
288 | 325 | vlog "----------------" | ||
289 | 326 | exit -1 | ||
290 | 327 | else | ||
291 | 328 | break | ||
292 | 329 | fi | ||
293 | 330 | done | ||
294 | 331 | |||
295 | 332 | vlog "Server with id=$id has been started on port $MYSQLD_PORT, \ | ||
296 | 304 | socket $MYSQLD_SOCKET" | 333 | socket $MYSQLD_SOCKET" |
297 | 305 | } | 334 | } |
298 | 306 | 335 | ||
299 | @@ -317,7 +346,9 @@ | |||
300 | 317 | 346 | ||
301 | 318 | if [ -f "${MYSQLD_PIDFILE}" ] | 347 | if [ -f "${MYSQLD_PIDFILE}" ] |
302 | 319 | then | 348 | then |
304 | 320 | kill -9 `cat ${MYSQLD_PIDFILE}` | 349 | local pid=`cat $MYSQLD_PIDFILE` |
305 | 350 | kill -9 $pid | ||
306 | 351 | wait $pid || true | ||
307 | 321 | rm -f ${MYSQLD_PIDFILE} | 352 | rm -f ${MYSQLD_PIDFILE} |
308 | 322 | else | 353 | else |
309 | 323 | vlog "Server PID file '${MYSQLD_PIDFILE}' doesn't exist!" | 354 | vlog "Server PID file '${MYSQLD_PIDFILE}' doesn't exist!" |
310 | @@ -484,7 +515,8 @@ | |||
311 | 484 | ########################################################################## | 515 | ########################################################################## |
312 | 485 | function record_db_state() | 516 | function record_db_state() |
313 | 486 | { | 517 | { |
315 | 487 | $MYSQLDUMP $MYSQL_ARGS -t --compact $1 >"$topdir/tmp/$1_old.sql" | 518 | $MYSQLDUMP $MYSQL_ARGS -t --compact --skip-extended-insert \ |
316 | 519 | $1 >"$topdir/tmp/$1_old.sql" | ||
317 | 488 | } | 520 | } |
318 | 489 | 521 | ||
319 | 490 | 522 | ||
320 | @@ -494,7 +526,8 @@ | |||
321 | 494 | ########################################################################## | 526 | ########################################################################## |
322 | 495 | function verify_db_state() | 527 | function verify_db_state() |
323 | 496 | { | 528 | { |
325 | 497 | $MYSQLDUMP $MYSQL_ARGS -t --compact $1 >"$topdir/tmp/$1_new.sql" | 529 | $MYSQLDUMP $MYSQL_ARGS -t --compact --skip-extended-insert \ |
326 | 530 | $1 >"$topdir/tmp/$1_new.sql" | ||
327 | 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" |
328 | 499 | } | 532 | } |
329 | 500 | 533 | ||
330 | @@ -514,14 +547,14 @@ | |||
331 | 514 | return ${PIPESTATUS[0]} | 547 | return ${PIPESTATUS[0]} |
332 | 515 | } | 548 | } |
333 | 516 | 549 | ||
334 | 517 | readonly xb_performed_bmp_inc_backup="xtrabackup: using the full scan for incremental backup" | ||
335 | 518 | readonly xb_performed_full_scan_inc_backup="xtrabackup: using the changed page bitmap" | ||
336 | 519 | |||
337 | 520 | #################################################### | 550 | #################################################### |
338 | 521 | # Helper functions for testing incremental backups # | 551 | # Helper functions for testing incremental backups # |
339 | 522 | #################################################### | 552 | #################################################### |
340 | 523 | function check_full_scan_inc_backup() | 553 | function check_full_scan_inc_backup() |
341 | 524 | { | 554 | { |
342 | 555 | local xb_performed_bmp_inc_backup="xtrabackup: using the full scan for incremental backup" | ||
343 | 556 | local xb_performed_full_scan_inc_backup="xtrabackup: using the changed page bitmap" | ||
344 | 557 | |||
345 | 525 | if ! grep -q "$xb_performed_bmp_inc_backup" $OUTFILE ; | 558 | if ! grep -q "$xb_performed_bmp_inc_backup" $OUTFILE ; |
346 | 526 | then | 559 | then |
347 | 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." |
348 | @@ -536,6 +569,9 @@ | |||
349 | 536 | 569 | ||
350 | 537 | function check_bitmap_inc_backup() | 570 | function check_bitmap_inc_backup() |
351 | 538 | { | 571 | { |
352 | 572 | local xb_performed_bmp_inc_backup="xtrabackup: using the full scan for incremental backup" | ||
353 | 573 | local xb_performed_full_scan_inc_backup="xtrabackup: using the changed page bitmap" | ||
354 | 574 | |||
355 | 539 | if ! grep -q "$xb_performed_full_scan_inc_backup" $OUTFILE ; | 575 | if ! grep -q "$xb_performed_full_scan_inc_backup" $OUTFILE ; |
356 | 540 | then | 576 | then |
357 | 541 | vlog "xtrabackup did not use bitmaps for the incremental backup." | 577 | vlog "xtrabackup did not use bitmaps for the incremental backup." |
358 | 542 | 578 | ||
359 | === removed file 'test/run.sh' | |||
360 | --- test/run.sh 2012-11-30 04:28:06 +0000 | |||
361 | +++ test/run.sh 1970-01-01 00:00:00 +0000 | |||
362 | @@ -1,14 +0,0 @@ | |||
363 | 1 | #!/bin/bash | ||
364 | 2 | |||
365 | 3 | XB_BUILD="autodetect" | ||
366 | 4 | while getopts "fc:" options; do | ||
367 | 5 | case $options in | ||
368 | 6 | c ) XB_BUILD="$OPTARG";; | ||
369 | 7 | f ) ;; # ignored | ||
370 | 8 | esac | ||
371 | 9 | done | ||
372 | 10 | |||
373 | 11 | rm -rf results/ var/ test_results.subunit | ||
374 | 12 | |||
375 | 13 | CFLAGS=-g make testrun | ||
376 | 14 | ./testrun -c $XB_BUILD | ||
377 | 15 | 0 | ||
378 | === renamed file 'test/testrun.sh' => 'test/run.sh' | |||
379 | --- test/testrun.sh 2013-05-17 11:07:26 +0000 | |||
380 | +++ test/run.sh 2013-07-04 07:51:31 +0000 | |||
381 | @@ -2,14 +2,39 @@ | |||
382 | 2 | 2 | ||
383 | 3 | export DEBUG= | 3 | export DEBUG= |
384 | 4 | 4 | ||
385 | 5 | shopt -s extglob | ||
386 | 6 | |||
387 | 7 | set +e | ||
388 | 8 | |||
389 | 5 | . inc/common.sh | 9 | . inc/common.sh |
394 | 6 | 10 | . subunit.sh | |
395 | 7 | trap kill_leftovers 1 2 3 15 | 11 | |
396 | 8 | 12 | trap cleanup_on_exit EXIT | |
397 | 9 | set +e | 13 | trap terminate SIGHUP SIGINT SIGQUIT SIGTERM |
398 | 10 | 14 | ||
399 | 11 | result=0 | 15 | result=0 |
400 | 12 | 16 | ||
401 | 17 | # Default test timeout in seconds | ||
402 | 18 | TEST_TIMEOUT=600 | ||
403 | 19 | |||
404 | 20 | # Magic exit code to indicate a skipped test | ||
405 | 21 | export SKIPPED_EXIT_CODE=200 | ||
406 | 22 | |||
407 | 23 | # Default server installation directory (-d option) | ||
408 | 24 | MYSQL_BASEDIR=${MYSQL_BASEDIR:-"$PWD/server"} | ||
409 | 25 | |||
410 | 26 | TEST_BASEDIR="$PWD" | ||
411 | 27 | TEST_VAR_ROOT="$TEST_BASEDIR/var" | ||
412 | 28 | |||
413 | 29 | # Global statistics | ||
414 | 30 | FAILED_COUNT=0 | ||
415 | 31 | FAILED_TESTS= | ||
416 | 32 | SKIPPED_COUNT=0 | ||
417 | 33 | SKIPPED_TESTS= | ||
418 | 34 | SUCCESSFUL_COUNT=0 | ||
419 | 35 | TOTAL_COUNT=0 | ||
420 | 36 | TOTAL_TIME=0 | ||
421 | 37 | |||
422 | 13 | function usage() | 38 | function usage() |
423 | 14 | { | 39 | { |
424 | 15 | cat <<EOF | 40 | cat <<EOF |
425 | @@ -24,7 +49,183 @@ | |||
426 | 24 | -c conf XtraBackup build configuration as specified to build.sh. | 49 | -c conf XtraBackup build configuration as specified to build.sh. |
427 | 25 | Default is 'autodetect', i.e. xtrabackup binary is determined based | 50 | Default is 'autodetect', i.e. xtrabackup binary is determined based |
428 | 26 | on the MySQL version. | 51 | on the MySQL version. |
430 | 27 | EOF | 52 | -j N Run tests in N parallel processes. |
431 | 53 | -T seconds Test timeout (default is $TEST_TIMEOUT seconds). | ||
432 | 54 | EOF | ||
433 | 55 | } | ||
434 | 56 | |||
435 | 57 | ############################################################################### | ||
436 | 58 | # Calculate the number of parallel workers automatically based on the number of | ||
437 | 59 | # available cores | ||
438 | 60 | ############################################################################### | ||
439 | 61 | function autocalc_nworkers() | ||
440 | 62 | { | ||
441 | 63 | if [ -r /proc/cpuinfo ] | ||
442 | 64 | then | ||
443 | 65 | NWORKERS=`grep processor /proc/cpuinfo | wc -l` | ||
444 | 66 | elif which sysctl >/dev/null 2>&1 | ||
445 | 67 | then | ||
446 | 68 | NWORKERS=`sysctl -n hw.ncpu` | ||
447 | 69 | fi | ||
448 | 70 | |||
449 | 71 | if [[ ! $NWORKERS =~ ^[0-9]+$ || $NWORKERS < 1 ]] | ||
450 | 72 | then | ||
451 | 73 | echo "Cannot determine the number of available CPU cures!" | ||
452 | 74 | exit -1 | ||
453 | 75 | fi | ||
454 | 76 | |||
455 | 77 | if [ "$NWORKERS" -gt 16 ] | ||
456 | 78 | then | ||
457 | 79 | echo "Autodetected number of cores: $NWORKERS" | ||
458 | 80 | echo "Limiting to 16 to avoid excessive resource consumption" | ||
459 | 81 | |||
460 | 82 | NWORKERS=16 | ||
461 | 83 | fi | ||
462 | 84 | } | ||
463 | 85 | |||
464 | 86 | ############################################################################### | ||
465 | 87 | # Kill a specified worker | ||
466 | 88 | ############################################################################### | ||
467 | 89 | function kill_worker() | ||
468 | 90 | { | ||
469 | 91 | local worker=$1 | ||
470 | 92 | local pid=${worker_pids[$worker]} | ||
471 | 93 | |||
472 | 94 | worker_pids[$worker]="" | ||
473 | 95 | |||
474 | 96 | if ! kill -0 $pid >/dev/null 2>&1 | ||
475 | 97 | then | ||
476 | 98 | wait $pid >/dev/null 2>&1 || true | ||
477 | 99 | return 0 | ||
478 | 100 | fi | ||
479 | 101 | |||
480 | 102 | # First send SIGTERM to let worker exit gracefully | ||
481 | 103 | kill -SIGTERM $pid >/dev/null 2>&1 || true | ||
482 | 104 | |||
483 | 105 | sleep 1 | ||
484 | 106 | |||
485 | 107 | if ! kill -0 $pid >/dev/null 2>&1 | ||
486 | 108 | then | ||
487 | 109 | wait $pid >/dev/null 2>&1 || true | ||
488 | 110 | return 0 | ||
489 | 111 | fi | ||
490 | 112 | |||
491 | 113 | # Now kill with SIGKILL | ||
492 | 114 | kill -SIGKILL $pid >/dev/null 2>&1 || true | ||
493 | 115 | wait $pid >/dev/null 2>&1 || true | ||
494 | 116 | release_port_locks $pid | ||
495 | 117 | } | ||
496 | 118 | |||
497 | 119 | ######################################################################## | ||
498 | 120 | # Kill all running workers | ||
499 | 121 | ######################################################################## | ||
500 | 122 | function kill_all_workers() | ||
501 | 123 | { | ||
502 | 124 | while true | ||
503 | 125 | do | ||
504 | 126 | found="" | ||
505 | 127 | |||
506 | 128 | # First send SIGTERM to let workers exit gracefully | ||
507 | 129 | for ((i = 1; i <= NWORKERS; i++)) | ||
508 | 130 | do | ||
509 | 131 | [ -z ${worker_pids[$i]:-""} ] && continue | ||
510 | 132 | |||
511 | 133 | found="yes" | ||
512 | 134 | |||
513 | 135 | if ! kill -0 ${worker_pids[$i]} >/dev/null 2>&1 | ||
514 | 136 | then | ||
515 | 137 | worker_pids[$i]="" | ||
516 | 138 | continue | ||
517 | 139 | fi | ||
518 | 140 | |||
519 | 141 | kill -SIGTERM ${worker_pids[$i]} >/dev/null 2>&1 || true | ||
520 | 142 | done | ||
521 | 143 | |||
522 | 144 | [ -z "$found" ] && break | ||
523 | 145 | |||
524 | 146 | sleep 1 | ||
525 | 147 | |||
526 | 148 | # Now kill with SIGKILL | ||
527 | 149 | for ((i = 1; i <= NWORKERS; i++)) | ||
528 | 150 | do | ||
529 | 151 | [ -z ${worker_pids[$i]:-""} ] && continue | ||
530 | 152 | |||
531 | 153 | if ! kill -0 ${worker_pids[$i]} >/dev/null 2>&1 | ||
532 | 154 | then | ||
533 | 155 | wait ${worker_pids[$i]} >/dev/null 2>&1 || true | ||
534 | 156 | worker_pids[$i]="" | ||
535 | 157 | continue | ||
536 | 158 | fi | ||
537 | 159 | |||
538 | 160 | kill -SIGKILL ${worker_pids[$i]} >/dev/null 2>&1 || true | ||
539 | 161 | wait ${worker_pids[$i]} >/dev/null 2>&1 || true | ||
540 | 162 | release_port_locks ${worker_pids[$i]} | ||
541 | 163 | worker_pids[$i]="" | ||
542 | 164 | done | ||
543 | 165 | done | ||
544 | 166 | } | ||
545 | 167 | |||
546 | 168 | ######################################################################## | ||
547 | 169 | # Handler called from a fatal signal handler trap | ||
548 | 170 | ######################################################################## | ||
549 | 171 | function terminate() | ||
550 | 172 | { | ||
551 | 173 | echo "Terminated, cleaning up..." | ||
552 | 174 | |||
553 | 175 | # The following will call cleanup_on_exit() | ||
554 | 176 | exit 2 | ||
555 | 177 | } | ||
556 | 178 | |||
557 | 179 | ######################################################################## | ||
558 | 180 | # Display the test run summary and exit | ||
559 | 181 | ######################################################################## | ||
560 | 182 | function print_status_and_exit() | ||
561 | 183 | { | ||
562 | 184 | local test_time=$((`now` - TEST_START_TIME)) | ||
563 | 185 | cat <<EOF | ||
564 | 186 | ============================================================================== | ||
565 | 187 | Spent $TOTAL_TIME of $test_time seconds executing testcases | ||
566 | 188 | |||
567 | 189 | SUMMARY: $TOTAL_COUNT run, $SUCCESSFUL_COUNT successful, $SKIPPED_COUNT skipped, $FAILED_COUNT failed | ||
568 | 190 | |||
569 | 191 | EOF | ||
570 | 192 | |||
571 | 193 | if [ -n "$SKIPPED_TESTS" ] | ||
572 | 194 | then | ||
573 | 195 | echo "Skipped tests: $SKIPPED_TESTS" | ||
574 | 196 | echo | ||
575 | 197 | fi | ||
576 | 198 | |||
577 | 199 | if [ -n "$FAILED_TESTS" ] | ||
578 | 200 | then | ||
579 | 201 | echo "Failed tests: $FAILED_TESTS" | ||
580 | 202 | echo | ||
581 | 203 | fi | ||
582 | 204 | |||
583 | 205 | echo "See results/ for detailed output" | ||
584 | 206 | |||
585 | 207 | if [ "$FAILED_COUNT" = 0 ] | ||
586 | 208 | then | ||
587 | 209 | exit 0 | ||
588 | 210 | fi | ||
589 | 211 | |||
590 | 212 | exit 1 | ||
591 | 213 | } | ||
592 | 214 | |||
593 | 215 | ######################################################################## | ||
594 | 216 | # Cleanup procedure invoked on process exit | ||
595 | 217 | ######################################################################## | ||
596 | 218 | function cleanup_on_exit() | ||
597 | 219 | { | ||
598 | 220 | kill_servers $TEST_VAR_ROOT | ||
599 | 221 | |||
600 | 222 | remove_var_dirs | ||
601 | 223 | |||
602 | 224 | release_port_locks $$ | ||
603 | 225 | |||
604 | 226 | kill_all_workers | ||
605 | 227 | |||
606 | 228 | cleanup_all_workers | ||
607 | 28 | } | 229 | } |
608 | 29 | 230 | ||
609 | 30 | function find_program() | 231 | function find_program() |
610 | @@ -52,12 +253,11 @@ | |||
611 | 52 | fi | 253 | fi |
612 | 53 | } | 254 | } |
613 | 54 | 255 | ||
614 | 256 | ######################################################################## | ||
615 | 257 | # Explore environment and setup global variables | ||
616 | 258 | ######################################################################## | ||
617 | 55 | function set_vars() | 259 | function set_vars() |
618 | 56 | { | 260 | { |
619 | 57 | TEST_BASEDIR=${TEST_BASEDIR:-"$PWD"} | ||
620 | 58 | MYSQL_BASEDIR=${MYSQL_BASEDIR:-"$PWD/server"} | ||
621 | 59 | PORT_BASE=$((3306 + $RANDOM)) | ||
622 | 60 | |||
623 | 61 | if gnutar --version > /dev/null 2>&1 | 261 | if gnutar --version > /dev/null 2>&1 |
624 | 62 | then | 262 | then |
625 | 63 | TAR=gnutar | 263 | TAR=gnutar |
626 | @@ -88,7 +288,7 @@ | |||
627 | 88 | fi | 288 | fi |
628 | 89 | DYLD_LIBRARY_PATH="$LD_LIBRARY_PATH" | 289 | DYLD_LIBRARY_PATH="$LD_LIBRARY_PATH" |
629 | 90 | 290 | ||
631 | 91 | export TEST_BASEDIR PORT_BASE TAR MYSQL_BASEDIR MYSQL MYSQLD MYSQLADMIN \ | 291 | export TAR MYSQL_BASEDIR MYSQL MYSQLD MYSQLADMIN \ |
632 | 92 | MYSQL_INSTALL_DB PATH LD_LIBRARY_PATH DYLD_LIBRARY_PATH MYSQLDUMP | 292 | MYSQL_INSTALL_DB PATH LD_LIBRARY_PATH DYLD_LIBRARY_PATH MYSQLDUMP |
633 | 93 | } | 293 | } |
634 | 94 | 294 | ||
635 | @@ -229,7 +429,7 @@ | |||
636 | 229 | return 1 | 429 | return 1 |
637 | 230 | fi | 430 | fi |
638 | 231 | 431 | ||
640 | 232 | stop_server | 432 | stop_server >>$OUTFILE 2>&1 |
641 | 233 | 433 | ||
642 | 234 | export MYSQL_VERSION MYSQL_VERSION_COMMENT MYSQL_FLAVOR \ | 434 | export MYSQL_VERSION MYSQL_VERSION_COMMENT MYSQL_FLAVOR \ |
643 | 235 | INNODB_VERSION XTRADB_VERSION INNODB_FLAVOR \ | 435 | INNODB_VERSION XTRADB_VERSION INNODB_FLAVOR \ |
644 | @@ -237,39 +437,362 @@ | |||
645 | 237 | DEFAULT_IBDATA_SIZE XB_BUILD | 437 | DEFAULT_IBDATA_SIZE XB_BUILD |
646 | 238 | } | 438 | } |
647 | 239 | 439 | ||
649 | 240 | export SKIPPED_EXIT_CODE=200 | 440 | ########################################################################### |
650 | 441 | # Kill all server processes started by a worker specified with its var root | ||
651 | 442 | # directory | ||
652 | 443 | ########################################################################### | ||
653 | 444 | function kill_servers() | ||
654 | 445 | { | ||
655 | 446 | local var_root=$1 | ||
656 | 447 | local file | ||
657 | 448 | |||
658 | 449 | [ -d $var_root ] || return 0 | ||
659 | 450 | |||
660 | 451 | cd $var_root | ||
661 | 452 | |||
662 | 453 | for file in mysqld*.pid | ||
663 | 454 | do | ||
664 | 455 | if [ -f $file ] | ||
665 | 456 | then | ||
666 | 457 | vlog "Found a leftover mysqld processes with PID `cat $file`, \ | ||
667 | 458 | stopping it" | ||
668 | 459 | kill -9 `cat $file` 2>/dev/null || true | ||
669 | 460 | rm -f $file | ||
670 | 461 | fi | ||
671 | 462 | done | ||
672 | 463 | |||
673 | 464 | cd - >/dev/null 2>&1 | ||
674 | 465 | } | ||
675 | 466 | |||
676 | 467 | ########################################################################### | ||
677 | 468 | # Kill all server processes started by a worker specified with its number | ||
678 | 469 | ########################################################################### | ||
679 | 470 | function kill_servers_for_worker() | ||
680 | 471 | { | ||
681 | 472 | local worker=$1 | ||
682 | 473 | |||
683 | 474 | kill_servers $TEST_BASEDIR/var/w$worker | ||
684 | 475 | } | ||
685 | 476 | |||
686 | 477 | ################################################################################ | ||
687 | 478 | # Clean up all workers (except DEBUG_WORKER if set) We can't use worker* arrays | ||
688 | 479 | # here and examine the directory structure, because the same functions is called | ||
689 | 480 | # on startup when we want to cleanup all workers started on previous invokations | ||
690 | 481 | ################################################################################ | ||
691 | 482 | function cleanup_all_workers() { local worker | ||
692 | 483 | |||
693 | 484 | for worker_dir in $TEST_BASEDIR/var/w+([0-9]) | ||
694 | 485 | do | ||
695 | 486 | [ -d $worker_dir ] || continue | ||
696 | 487 | [[ $worker_dir =~ w([0-9]+)$ ]] || continue | ||
697 | 488 | |||
698 | 489 | worker=${BASH_REMATCH[1]} | ||
699 | 490 | |||
700 | 491 | if [ "$worker" = "$DEBUG_WORKER" ] | ||
701 | 492 | then | ||
702 | 493 | echo | ||
703 | 494 | echo "Skipping cleanup for worker #$worker due to debug mode." | ||
704 | 495 | echo "You can do post-mortem analysis by examining test data in \ | ||
705 | 496 | $worker_dir" | ||
706 | 497 | echo "and the server process if it was running at the failure time." | ||
707 | 498 | continue | ||
708 | 499 | fi | ||
709 | 500 | |||
710 | 501 | cleanup_worker $worker | ||
711 | 502 | done | ||
712 | 503 | } | ||
713 | 504 | ######################################################################## | ||
714 | 505 | # Clean up a specified worker | ||
715 | 506 | ######################################################################## | ||
716 | 507 | function cleanup_worker() | ||
717 | 508 | { | ||
718 | 509 | local worker=$1 | ||
719 | 510 | local tmpdir | ||
720 | 511 | |||
721 | 512 | kill_servers_for_worker $worker >>$OUTFILE 2>&1 | ||
722 | 513 | |||
723 | 514 | # It is possible that a file is created while rm is in progress | ||
724 | 515 | # which results in "rm: cannot remove ...: Directory not empty | ||
725 | 516 | # hence the loop below | ||
726 | 517 | while true | ||
727 | 518 | do | ||
728 | 519 | # Fix permissions as some tests modify them so the following 'rm' fails | ||
729 | 520 | chmod -R 0700 $TEST_BASEDIR/var/w$worker >/dev/null 2>&1 | ||
730 | 521 | rm -rf $TEST_BASEDIR/var/w$worker && break | ||
731 | 522 | done | ||
732 | 523 | |||
733 | 524 | tmpdir=${worker_tmpdirs[$worker]:-""} | ||
734 | 525 | if [ -n "$tmpdir" ] | ||
735 | 526 | then | ||
736 | 527 | rm -rf $tmpdir | ||
737 | 528 | fi | ||
738 | 529 | } | ||
739 | 530 | |||
740 | 531 | ######################################################################## | ||
741 | 532 | # Return the number of seconds since the Epoch, UTC | ||
742 | 533 | ######################################################################## | ||
743 | 534 | function now() | ||
744 | 535 | { | ||
745 | 536 | date '+%s' | ||
746 | 537 | } | ||
747 | 538 | |||
748 | 539 | ######################################################################## | ||
749 | 540 | # Process the exit code of a specified worker | ||
750 | 541 | ######################################################################## | ||
751 | 542 | function reap_worker() | ||
752 | 543 | { | ||
753 | 544 | local worker=$1 | ||
754 | 545 | local pid=${worker_pids[$worker]} | ||
755 | 546 | local skip_file=${worker_skip_files[$worker]} | ||
756 | 547 | local tpath=${worker_names[$worker]} | ||
757 | 548 | local tname=`basename $tpath .sh` | ||
758 | 549 | local test_time=$((`now` - worker_stime[$worker])) | ||
759 | 550 | local status_file=${worker_status_files[$worker]} | ||
760 | 551 | local rc | ||
761 | 552 | |||
762 | 553 | if [ -f "$status_file" ] | ||
763 | 554 | then | ||
764 | 555 | rc=`cat $status_file` | ||
765 | 556 | # Assume exit code 1 if status file is empty | ||
766 | 557 | rc=${rc:-"1"} | ||
767 | 558 | else | ||
768 | 559 | # Assume exit code 1 if status file does not exist | ||
769 | 560 | rc="1" | ||
770 | 561 | fi | ||
771 | 562 | |||
772 | 563 | printf "%-40s w%d\t" $tname $worker | ||
773 | 564 | |||
774 | 565 | ((TOTAL_TIME+=test_time)) | ||
775 | 566 | |||
776 | 567 | # Have to call subunit_start_test here, as currently tests cannot be | ||
777 | 568 | # interleaved in the subunit output | ||
778 | 569 | subunit_start_test $tpath "${worker_stime_txt[$worker]}" >> $SUBUNIT_OUT | ||
779 | 570 | |||
780 | 571 | if [ $rc -eq 0 ] | ||
781 | 572 | then | ||
782 | 573 | echo "[passed] $test_time" | ||
783 | 574 | |||
784 | 575 | SUCCESSFUL_COUNT=$((SUCCESSFUL_COUNT + 1)) | ||
785 | 576 | subunit_pass_test $tpath >> $SUBUNIT_OUT | ||
786 | 577 | |||
787 | 578 | cleanup_worker $worker | ||
788 | 579 | elif [ $rc -eq $SKIPPED_EXIT_CODE ] | ||
789 | 580 | then | ||
790 | 581 | sreason="" | ||
791 | 582 | test -r $skip_file && sreason=`cat $skip_file` | ||
792 | 583 | |||
793 | 584 | SKIPPED_COUNT=$((SKIPPED_COUNT + 1)) | ||
794 | 585 | SKIPPED_TESTS="$SKIPPED_TESTS $tname" | ||
795 | 586 | |||
796 | 587 | echo "[skipped] $sreason" | ||
797 | 588 | |||
798 | 589 | subunit_skip_test $tpath >> $SUBUNIT_OUT | ||
799 | 590 | |||
800 | 591 | cleanup_worker $worker | ||
801 | 592 | else | ||
802 | 593 | echo "[failed] $test_time" | ||
803 | 594 | |||
804 | 595 | ( | ||
805 | 596 | (echo "Something went wrong running $tpath. Exited with $rc"; | ||
806 | 597 | echo; echo; cat ${worker_outfiles[$worker]} | ||
807 | 598 | ) | subunit_fail_test $tpath | ||
808 | 599 | ) >> $SUBUNIT_OUT | ||
809 | 600 | |||
810 | 601 | FAILED_COUNT=$((FAILED_COUNT + 1)) | ||
811 | 602 | FAILED_TESTS="$FAILED_TESTS $tname" | ||
812 | 603 | |||
813 | 604 | # Return 0 on failed tests in the -f mode | ||
814 | 605 | if [ -z "$force" ] | ||
815 | 606 | then | ||
816 | 607 | |||
817 | 608 | if [ -z "$DEBUG" ] | ||
818 | 609 | then | ||
819 | 610 | cleanup_worker $worker | ||
820 | 611 | else | ||
821 | 612 | DEBUG_WORKER=$worker | ||
822 | 613 | fi | ||
823 | 614 | |||
824 | 615 | return 1 | ||
825 | 616 | else | ||
826 | 617 | cleanup_worker $worker | ||
827 | 618 | |||
828 | 619 | return 0 | ||
829 | 620 | fi | ||
830 | 621 | fi | ||
831 | 622 | |||
832 | 623 | } | ||
833 | 624 | |||
834 | 625 | ############################################################################# | ||
835 | 626 | # Check if a specified worker has exceed TEST_TIMEOUT and if so, terminate it | ||
836 | 627 | ############################################################################# | ||
837 | 628 | function check_timeout_for_worker() | ||
838 | 629 | { | ||
839 | 630 | local worker=$1 | ||
840 | 631 | local tpath=${worker_names[$worker]} | ||
841 | 632 | local tname=`basename $tpath .sh` | ||
842 | 633 | |||
843 | 634 | if (( `now` - worker_stime[$worker] > TEST_TIMEOUT )) | ||
844 | 635 | then | ||
845 | 636 | kill_worker $worker | ||
846 | 637 | printf "%-40s w%d\t" $tname $worker | ||
847 | 638 | echo "[failed] Timed out after $TEST_TIMEOUT seconds." | ||
848 | 639 | |||
849 | 640 | ( | ||
850 | 641 | # Have to call subunit_start_test here, as currently tests cannot be | ||
851 | 642 | # interleaved in the subunit output | ||
852 | 643 | subunit_start_test $tpath "${worker_stime_txt[$worker]}" | ||
853 | 644 | |||
854 | 645 | (echo "Timeout exceeded running $tpath."; | ||
855 | 646 | echo; echo; cat ${worker_outfiles[$worker]} | ||
856 | 647 | ) | subunit_fail_test $tpath | ||
857 | 648 | ) >> $SUBUNIT_OUT | ||
858 | 649 | |||
859 | 650 | FAILED_COUNT=$((FAILED_COUNT + 1)) | ||
860 | 651 | FAILED_TESTS="$FAILED_TESTS $tname" | ||
861 | 652 | |||
862 | 653 | # Return 0 on failed tests in the -f mode | ||
863 | 654 | if [ -z "$force" ] | ||
864 | 655 | then | ||
865 | 656 | |||
866 | 657 | if [ -z "$DEBUG" ] | ||
867 | 658 | then | ||
868 | 659 | cleanup_worker $worker | ||
869 | 660 | else | ||
870 | 661 | DEBUG_WORKER=$worker | ||
871 | 662 | fi | ||
872 | 663 | |||
873 | 664 | return 1 | ||
874 | 665 | else | ||
875 | 666 | cleanup_worker $worker | ||
876 | 667 | |||
877 | 668 | return 0 | ||
878 | 669 | fi | ||
879 | 670 | fi | ||
880 | 671 | } | ||
881 | 672 | ######################################################################### | ||
882 | 673 | # Wait for all currently running worker to finish | ||
883 | 674 | ######################################################################### | ||
884 | 675 | function reap_all_workers() | ||
885 | 676 | { | ||
886 | 677 | while true | ||
887 | 678 | do | ||
888 | 679 | found="" | ||
889 | 680 | |||
890 | 681 | for ((i = 1; i <= NWORKERS; i++)) | ||
891 | 682 | do | ||
892 | 683 | [ -z ${worker_pids[$i]:-""} ] && continue | ||
893 | 684 | |||
894 | 685 | found="yes" | ||
895 | 686 | |||
896 | 687 | # Check if it's alive | ||
897 | 688 | if kill -0 ${worker_pids[$i]} >/dev/null 2>&1 | ||
898 | 689 | then | ||
899 | 690 | check_timeout_for_worker $i || print_status_and_exit | ||
900 | 691 | continue | ||
901 | 692 | fi | ||
902 | 693 | |||
903 | 694 | reap_worker $i || print_status_and_exit | ||
904 | 695 | |||
905 | 696 | worker_pids[$i]="" | ||
906 | 697 | done | ||
907 | 698 | |||
908 | 699 | [ -z "$found" ] && break | ||
909 | 700 | |||
910 | 701 | sleep 1 | ||
911 | 702 | done | ||
912 | 703 | } | ||
913 | 704 | |||
914 | 705 | ######################################################################## | ||
915 | 706 | # Release all port locks reserved by the current process | ||
916 | 707 | # Used by the EXIT trap (in both normal and abnormal shell termination) | ||
917 | 708 | ######################################################################## | ||
918 | 709 | function release_port_locks() | ||
919 | 710 | { | ||
920 | 711 | local process=$1 | ||
921 | 712 | local lockfile | ||
922 | 713 | |||
923 | 714 | # Suppress errors when no port lock files are found | ||
924 | 715 | shopt -s nullglob | ||
925 | 716 | |||
926 | 717 | for lockfile in /tmp/xtrabackup_port_lock.* | ||
927 | 718 | do | ||
928 | 719 | if [ "`cat $lockfile 2>/dev/null`" = $process ] | ||
929 | 720 | then | ||
930 | 721 | rm -rf $lockfile | ||
931 | 722 | fi | ||
932 | 723 | done | ||
933 | 724 | |||
934 | 725 | shopt -u nullglob | ||
935 | 726 | } | ||
936 | 727 | |||
937 | 728 | ######################################################################## | ||
938 | 729 | # Report status and release port locks on exit | ||
939 | 730 | ######################################################################## | ||
940 | 731 | function cleanup_on_test_exit() | ||
941 | 732 | { | ||
942 | 733 | local rc=$? | ||
943 | 734 | |||
944 | 735 | echo $rc > $STATUS_FILE | ||
945 | 736 | |||
946 | 737 | release_port_locks $$ | ||
947 | 738 | } | ||
948 | 739 | |||
949 | 740 | ######################################################################## | ||
950 | 741 | # Script body | ||
951 | 742 | ######################################################################## | ||
952 | 743 | |||
953 | 744 | TEST_START_TIME=`now` | ||
954 | 241 | 745 | ||
955 | 242 | tname="" | 746 | tname="" |
956 | 243 | XTRACE_OPTION="" | 747 | XTRACE_OPTION="" |
957 | 244 | XB_BUILD="autodetect" | 748 | XB_BUILD="autodetect" |
958 | 245 | force="" | 749 | force="" |
959 | 246 | KEEP_RESULTS=0 | ||
960 | 247 | SUBUNIT_OUT=test_results.subunit | 750 | SUBUNIT_OUT=test_results.subunit |
975 | 248 | 751 | NWORKERS= | |
976 | 249 | while getopts "fgh?:t:s:d:c:b:nr:" options; do | 752 | DEBUG_WORKER="" |
977 | 250 | case $options in | 753 | |
978 | 251 | f ) force="yes";; | 754 | while getopts "fgh?:t:s:d:c:j:T:" options; do |
979 | 252 | t ) tname="$OPTARG";; | 755 | case $options in |
980 | 253 | g ) XTRACE_OPTION="-x"; DEBUG=on;; | 756 | f ) force="yes";; |
981 | 254 | h ) usage; exit;; | 757 | t ) |
982 | 255 | s ) tname="$OPTARG/*.sh";; | 758 | |
983 | 256 | d ) export MYSQL_BASEDIR="$OPTARG";; | 759 | tname="$OPTARG"; |
984 | 257 | b ) TEST_BASEDIR="$OPTARG";; | 760 | if ! [ -r "$tname" ] |
985 | 258 | c ) XB_BUILD="$OPTARG";; | 761 | then |
986 | 259 | n ) KEEP_RESULTS=1;; | 762 | echo "Cannot find test $tname." |
987 | 260 | r ) SUBUNIT_OUT="$OPTARG";; | 763 | exit -1 |
988 | 261 | ? ) echo "Use \`$0 -h' for the list of available options." | 764 | fi |
989 | 765 | ;; | ||
990 | 766 | |||
991 | 767 | g ) DEBUG=on;; | ||
992 | 768 | h ) usage; exit;; | ||
993 | 769 | s ) tname="$OPTARG/*.sh";; | ||
994 | 770 | d ) export MYSQL_BASEDIR="$OPTARG";; | ||
995 | 771 | c ) XB_BUILD="$OPTARG";; | ||
996 | 772 | j ) | ||
997 | 773 | |||
998 | 774 | if [[ ! $OPTARG =~ ^[0-9]+$ || $NWORKERS < 1 ]] | ||
999 | 775 | then | ||
1000 | 776 | echo "Wrong -j argument: $OPTARG" | ||
1001 | 777 | exit -1 | ||
1002 | 778 | fi | ||
1003 | 779 | NWORKERS="$OPTARG" | ||
1004 | 780 | ;; | ||
1005 | 781 | |||
1006 | 782 | T ) | ||
1007 | 783 | if [[ ! $OPTARG =~ ^[0-9]+$ ]] | ||
1008 | 784 | then | ||
1009 | 785 | echo "Wrong -T argument: $OPTARG" | ||
1010 | 786 | exit -1 | ||
1011 | 787 | fi | ||
1012 | 788 | TEST_TIMEOUT="$OPTARG" | ||
1013 | 789 | ;; | ||
1014 | 790 | |||
1015 | 791 | ? ) echo "Use \`$0 -h' for the list of available options." | ||
1016 | 262 | exit -1;; | 792 | exit -1;; |
1018 | 263 | esac | 793 | esac |
1019 | 264 | done | 794 | done |
1020 | 265 | 795 | ||
1021 | 266 | if [ $KEEP_RESULTS -eq 0 ]; | ||
1022 | 267 | then | ||
1023 | 268 | rm -rf results | ||
1024 | 269 | rm -f $SUBUNIT_OUT | ||
1025 | 270 | fi | ||
1026 | 271 | mkdir results | ||
1027 | 272 | |||
1028 | 273 | set_vars | 796 | set_vars |
1029 | 274 | 797 | ||
1030 | 275 | if [ -n "$tname" ] | 798 | if [ -n "$tname" ] |
1031 | @@ -279,13 +802,17 @@ | |||
1032 | 279 | tests="t/*.sh" | 802 | tests="t/*.sh" |
1033 | 280 | fi | 803 | fi |
1034 | 281 | 804 | ||
1035 | 282 | failed_count=0 | ||
1036 | 283 | failed_tests= | ||
1037 | 284 | total_count=0 | ||
1038 | 285 | |||
1039 | 286 | export OUTFILE="$PWD/results/setup" | 805 | export OUTFILE="$PWD/results/setup" |
1040 | 287 | 806 | ||
1042 | 288 | clean >>$OUTFILE 2>&1 | 807 | rm -rf results |
1043 | 808 | mkdir results | ||
1044 | 809 | |||
1045 | 810 | cleanup_all_workers >>$OUTFILE 2>&1 | ||
1046 | 811 | |||
1047 | 812 | rm -rf var test_results.subunit | ||
1048 | 813 | mkdir var | ||
1049 | 814 | |||
1050 | 815 | echo "Detecting server version..." | tee -a $OUTFILE | ||
1051 | 289 | 816 | ||
1052 | 290 | if ! get_version_info | 817 | if ! get_version_info |
1053 | 291 | then | 818 | then |
1054 | @@ -297,69 +824,99 @@ | |||
1055 | 297 | tee -a $OUTFILE | 824 | tee -a $OUTFILE |
1056 | 298 | 825 | ||
1057 | 299 | echo "Using '`basename $XB_BIN`' as xtrabackup binary" | tee -a $OUTFILE | 826 | echo "Using '`basename $XB_BIN`' as xtrabackup binary" | tee -a $OUTFILE |
1058 | 827 | |||
1059 | 828 | [ -z "$NWORKERS" ] && autocalc_nworkers | ||
1060 | 829 | |||
1061 | 830 | if [ "$NWORKERS" -gt 1 ] | ||
1062 | 831 | then | ||
1063 | 832 | echo "Using $NWORKERS parallel workers" | tee -a $OUTFILE | ||
1064 | 833 | fi | ||
1065 | 300 | echo | tee -a $OUTFILE | 834 | echo | tee -a $OUTFILE |
1066 | 301 | 835 | ||
1073 | 302 | kill_leftovers >>$OUTFILE 2>&1 | 836 | cat <<EOF |
1074 | 303 | clean >>$OUTFILE 2>&1 | 837 | ============================================================================== |
1075 | 304 | 838 | TEST WORKER RESULT TIME(s) or COMMENT | |
1076 | 305 | source subunit.sh | 839 | ------------------------------------------------------------------------------ |
1077 | 306 | 840 | EOF | |
1072 | 307 | echo "========================================================================" | ||
1078 | 308 | 841 | ||
1079 | 309 | for t in $tests | 842 | for t in $tests |
1080 | 310 | do | 843 | do |
1085 | 311 | total_count=$((total_count+1)) | 844 | # Check if we have available workers |
1086 | 312 | 845 | found="" | |
1087 | 313 | printf "%-40s" $t | 846 | |
1088 | 314 | subunit_start_test $t >> $SUBUNIT_OUT | 847 | while [ -z "$found" ] |
1089 | 848 | do | ||
1090 | 849 | for ((i = 1; i <= NWORKERS; i++)) | ||
1091 | 850 | do | ||
1092 | 851 | if [ -z ${worker_pids[$i]:-""} ] | ||
1093 | 852 | then | ||
1094 | 853 | found="yes" | ||
1095 | 854 | break | ||
1096 | 855 | else | ||
1097 | 856 | # Check if it's alive | ||
1098 | 857 | if kill -0 ${worker_pids[$i]} >/dev/null 2>&1 | ||
1099 | 858 | then | ||
1100 | 859 | check_timeout_for_worker $i || print_status_and_exit | ||
1101 | 860 | continue | ||
1102 | 861 | fi | ||
1103 | 862 | reap_worker $i || print_status_and_exit | ||
1104 | 863 | |||
1105 | 864 | worker_pids[$i]="" | ||
1106 | 865 | found="yes" | ||
1107 | 866 | |||
1108 | 867 | break | ||
1109 | 868 | fi | ||
1110 | 869 | done | ||
1111 | 870 | |||
1112 | 871 | if [ -z "$found" ] | ||
1113 | 872 | then | ||
1114 | 873 | sleep 1 | ||
1115 | 874 | fi | ||
1116 | 875 | done | ||
1117 | 876 | |||
1118 | 877 | worker=$i | ||
1119 | 878 | |||
1120 | 879 | TOTAL_COUNT=$((TOTAL_COUNT+1)) | ||
1121 | 880 | |||
1122 | 315 | name=`basename $t .sh` | 881 | name=`basename $t .sh` |
1157 | 316 | export OUTFILE="$PWD/results/$name" | 882 | worker_names[$worker]=$t |
1158 | 317 | export SKIPPED_REASON="$PWD/results/$name.skipped" | 883 | worker_outfiles[$worker]="$PWD/results/$name" |
1159 | 318 | bash $XTRACE_OPTION $t > $OUTFILE 2>&1 | 884 | worker_skip_files[$worker]="$PWD/results/$name.skipped" |
1160 | 319 | rc=$? | 885 | worker_status_files[$worker]="$PWD/results/$name.status" |
1161 | 320 | 886 | # Create a unique TMPDIR for each worker so that it can be removed as a part | |
1162 | 321 | if [[ -z "$DEBUG" || -n "$force" ]] | 887 | # of the cleanup procedure. Server socket files will also be created there. |
1163 | 322 | then | 888 | worker_tmpdirs[$worker]="`mktemp -d -t xbtemp.XXXXXX`" |
1164 | 323 | kill_leftovers >>$OUTFILE 2>&1 | 889 | |
1165 | 324 | clean >>$OUTFILE 2>&1 | 890 | ( |
1166 | 325 | fi | 891 | set -eu |
1167 | 326 | 892 | if [ -n "$DEBUG" ] | |
1134 | 327 | if [ $rc -eq 0 ] | ||
1135 | 328 | then | ||
1136 | 329 | echo "[passed]" | ||
1137 | 330 | subunit_pass_test $t >> $SUBUNIT_OUT | ||
1138 | 331 | elif [ $rc -eq $SKIPPED_EXIT_CODE ] | ||
1139 | 332 | then | ||
1140 | 333 | sreason="" | ||
1141 | 334 | test -r $SKIPPED_REASON && sreason=`cat $SKIPPED_REASON` | ||
1142 | 335 | echo "[skipped] $sreason" | ||
1143 | 336 | subunit_skip_test $t >> $SUBUNIT_OUT | ||
1144 | 337 | else | ||
1145 | 338 | echo "[failed]" | ||
1146 | 339 | |||
1147 | 340 | ( | ||
1148 | 341 | (echo "Something went wrong running $t. Exited with $rc"; | ||
1149 | 342 | echo; echo; cat $OUTFILE | ||
1150 | 343 | ) | subunit_fail_test $t | ||
1151 | 344 | ) >> $SUBUNIT_OUT | ||
1152 | 345 | |||
1153 | 346 | failed_count=$((failed_count+1)) | ||
1154 | 347 | failed_tests="$failed_tests $t" | ||
1155 | 348 | result=1 | ||
1156 | 349 | if [ -z "$force" ] | ||
1168 | 350 | then | 893 | then |
1170 | 351 | break; | 894 | set -x |
1171 | 352 | fi | 895 | fi |
1173 | 353 | fi | 896 | |
1174 | 897 | trap "cleanup_on_test_exit" EXIT | ||
1175 | 898 | |||
1176 | 899 | . inc/common.sh | ||
1177 | 900 | |||
1178 | 901 | export OUTFILE=${worker_outfiles[$worker]} | ||
1179 | 902 | export SKIPPED_REASON=${worker_skip_files[$worker]} | ||
1180 | 903 | export TEST_VAR_ROOT=$TEST_BASEDIR/var/w$worker | ||
1181 | 904 | export TMPDIR=${worker_tmpdirs[$worker]} | ||
1182 | 905 | export STATUS_FILE=${worker_status_files[$worker]} | ||
1183 | 906 | |||
1184 | 907 | mkdir $TEST_VAR_ROOT | ||
1185 | 908 | |||
1186 | 909 | . $t | ||
1187 | 910 | ) > ${worker_outfiles[$worker]} 2>&1 & | ||
1188 | 911 | |||
1189 | 912 | worker_pids[$worker]=$! | ||
1190 | 913 | worker_stime[$worker]="`now`" | ||
1191 | 914 | # Used in subunit reports | ||
1192 | 915 | worker_stime_txt[$worker]="`date -u '+%Y-%m-%d %H:%M:%S'`" | ||
1193 | 354 | done | 916 | done |
1194 | 355 | 917 | ||
1205 | 356 | echo "========================================================================" | 918 | # Wait for in-progress workers to finish |
1206 | 357 | echo | 919 | reap_all_workers |
1207 | 358 | 920 | ||
1208 | 359 | if [ $result -eq 1 ] | 921 | print_status_and_exit |
1209 | 360 | then | 922 | |
1200 | 361 | echo | ||
1201 | 362 | echo "$failed_count/$total_count tests have failed: $failed_tests" | ||
1202 | 363 | echo "See results/ for detailed output" | ||
1203 | 364 | exit -1 | ||
1204 | 365 | fi | ||
1210 | 366 | 923 | ||
1211 | === modified file 'test/subunit.sh' | |||
1212 | --- test/subunit.sh 2011-06-12 09:57:00 +0000 | |||
1213 | +++ test/subunit.sh 2013-07-04 07:51:31 +0000 | |||
1214 | @@ -15,8 +15,11 @@ | |||
1215 | 15 | # | 15 | # |
1216 | 16 | 16 | ||
1217 | 17 | subunit_start_test () { | 17 | subunit_start_test () { |
1218 | 18 | local stime=$2 | ||
1219 | 18 | # emit the current protocol start-marker for test $1 | 19 | # emit the current protocol start-marker for test $1 |
1221 | 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 |
1222 | 21 | # start time | ||
1223 | 22 | echo "time: $stime" | ||
1224 | 20 | echo "test: $1" | 23 | echo "test: $1" |
1225 | 21 | } | 24 | } |
1226 | 22 | 25 | ||
1227 | 23 | 26 | ||
1228 | === modified file 'test/t/bug1085099.sh' | |||
1229 | --- test/t/bug1085099.sh 2013-03-06 10:04:13 +0000 | |||
1230 | +++ test/t/bug1085099.sh 2013-07-04 07:51:31 +0000 | |||
1231 | @@ -13,9 +13,7 @@ | |||
1232 | 13 | # Create a new tmpdir | 13 | # Create a new tmpdir |
1233 | 14 | mkdir $topdir/new_tmpdir | 14 | mkdir $topdir/new_tmpdir |
1234 | 15 | 15 | ||
1238 | 16 | # Make the default tmpdir inaccessible and make sure permissions are restored on | 16 | # Make the default tmpdir inaccessible |
1236 | 17 | # failure | ||
1237 | 18 | trap "chmod 755 $MYSQLD_TMPDIR" INT TERM EXIT | ||
1239 | 19 | chmod 000 $MYSQLD_TMPDIR | 17 | chmod 000 $MYSQLD_TMPDIR |
1240 | 20 | 18 | ||
1241 | 21 | innobackupex --tmpdir=$topdir/new_tmpdir --no-timestamp $topdir/backup | 19 | innobackupex --tmpdir=$topdir/new_tmpdir --no-timestamp $topdir/backup |
1242 | 22 | 20 | ||
1243 | === modified file 'test/t/bug664986.sh' | |||
1244 | --- test/t/bug664986.sh 2013-03-03 11:01:19 +0000 | |||
1245 | +++ test/t/bug664986.sh 2013-07-04 07:51:31 +0000 | |||
1246 | @@ -15,14 +15,6 @@ | |||
1247 | 15 | 15 | ||
1248 | 16 | EOF | 16 | EOF |
1249 | 17 | 17 | ||
1250 | 18 | # Make sure we restore permissions to not leave stale files in Jenkins | ||
1251 | 19 | # on a test failure | ||
1252 | 20 | trap "vlog restoring directories and files permissions ; \ | ||
1253 | 21 | chmod 777 $MYSQLD_DATADIR/test_bug664986_innodb; \ | ||
1254 | 22 | chmod 777 $MYSQLD_DATADIR/test_bug664986_myisam; \ | ||
1255 | 23 | chmod 644 $MYSQLD_DATADIR/test_bug664986_innodb/*; \ | ||
1256 | 24 | chmod 644 $MYSQLD_DATADIR/test_bug664986_myisam/*" INT TERM EXIT | ||
1257 | 25 | |||
1258 | 26 | # Test that wrong directory permissions result in a backup failure | 18 | # Test that wrong directory permissions result in a backup failure |
1259 | 27 | # for both InnoDB and non-InnoDB files | 19 | # for both InnoDB and non-InnoDB files |
1260 | 28 | chmod 000 $MYSQLD_DATADIR/test_bug664986_innodb | 20 | chmod 000 $MYSQLD_DATADIR/test_bug664986_innodb |
1261 | 29 | 21 | ||
1262 | === modified file 'test/t/bug996493.sh' | |||
1263 | --- test/t/bug996493.sh 2012-11-29 04:37:56 +0000 | |||
1264 | +++ test/t/bug996493.sh 2013-07-04 07:51:31 +0000 | |||
1265 | @@ -20,9 +20,6 @@ | |||
1266 | 20 | vlog "Remove my.cnf" | 20 | vlog "Remove my.cnf" |
1267 | 21 | mv $topdir/my.cnf $topdir/my.cnf.bak | 21 | mv $topdir/my.cnf $topdir/my.cnf.bak |
1268 | 22 | 22 | ||
1269 | 23 | trap "vlog restoring $topdir/my.cnf ; \ | ||
1270 | 24 | mv $topdir/my.cnf.bak $topdir/my.cnf" INT TERM EXIT | ||
1271 | 25 | |||
1272 | 26 | vlog "Apply log" | 23 | vlog "Apply log" |
1273 | 27 | # Do not run innobackupex, because it pass option --defaults-file | 24 | # Do not run innobackupex, because it pass option --defaults-file |
1274 | 28 | # which we should avoid. Our goal is to test that backup-my.cnf | 25 | # which we should avoid. Our goal is to test that backup-my.cnf |
1275 | @@ -31,7 +28,6 @@ | |||
1276 | 31 | 28 | ||
1277 | 32 | vlog "Get my.cnf back" | 29 | vlog "Get my.cnf back" |
1278 | 33 | mv $topdir/my.cnf.bak $topdir/my.cnf | 30 | mv $topdir/my.cnf.bak $topdir/my.cnf |
1279 | 34 | trap "vlog test exit" INT TERM EXIT | ||
1280 | 35 | 31 | ||
1281 | 36 | vlog "Copy back" | 32 | vlog "Copy back" |
1282 | 37 | innobackupex --copy-back $backup_dir | 33 | innobackupex --copy-back $backup_dir |
1283 | 38 | 34 | ||
1284 | === modified file 'test/t/compact_compressed.sh' | |||
1285 | --- test/t/compact_compressed.sh 2013-01-14 11:02:59 +0000 | |||
1286 | +++ test/t/compact_compressed.sh 2013-07-04 07:51:31 +0000 | |||
1287 | @@ -11,8 +11,13 @@ | |||
1288 | 11 | 11 | ||
1289 | 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 |
1290 | 13 | # error rather than a warning | 13 | # error rather than a warning |
1293 | 14 | mysqld_additional_args="--innodb_strict_mode --innodb_file_per_table \ | 14 | MYSQLD_EXTRA_MY_CNF_OPTS=" |
1294 | 15 | --innodb_file_format=Barracuda" | 15 | innodb_strict_mode |
1295 | 16 | innodb_file_per_table | ||
1296 | 17 | innodb_file_format=Barracuda | ||
1297 | 18 | # Set the minimal log file size to minimize xtrabackup_logfile | ||
1298 | 19 | # Recovering compressed pages is extremely slow with UNIV_ZIP_DEBUG | ||
1299 | 20 | innodb_log_file_size=1M" | ||
1300 | 16 | 21 | ||
1301 | 17 | # | 22 | # |
1302 | 18 | # Test compact backup of a compressed tablespace with a specific page size | 23 | # Test compact backup of a compressed tablespace with a specific page size |
1303 | @@ -26,7 +31,7 @@ | |||
1304 | 26 | echo "Testing compact backup with compressed page size=${page_size}KB " | 31 | echo "Testing compact backup with compressed page size=${page_size}KB " |
1305 | 27 | echo "************************************************************************" | 32 | echo "************************************************************************" |
1306 | 28 | 33 | ||
1308 | 29 | start_server ${mysqld_additional_args} | 34 | start_server |
1309 | 30 | 35 | ||
1310 | 31 | load_dbase_schema sakila | 36 | load_dbase_schema sakila |
1311 | 32 | load_dbase_data sakila | 37 | load_dbase_data sakila |
1312 | @@ -52,7 +57,7 @@ | |||
1313 | 52 | 57 | ||
1314 | 53 | rm -r $mysql_datadir | 58 | rm -r $mysql_datadir |
1315 | 54 | 59 | ||
1317 | 55 | innobackupex --apply-log --rebuild-indexes $backup_dir | 60 | innobackupex --apply-log --rebuild-indexes --rebuild-threads=2 $backup_dir |
1318 | 56 | 61 | ||
1319 | 57 | vlog "Restoring MySQL datadir" | 62 | vlog "Restoring MySQL datadir" |
1320 | 58 | mkdir -p $mysql_datadir | 63 | mkdir -p $mysql_datadir |
1321 | @@ -63,7 +68,7 @@ | |||
1322 | 63 | verify_db_state sakila | 68 | verify_db_state sakila |
1323 | 64 | 69 | ||
1324 | 65 | stop_server | 70 | stop_server |
1326 | 66 | clean | 71 | remove_var_dirs |
1327 | 67 | } | 72 | } |
1328 | 68 | 73 | ||
1329 | 69 | 74 | ||
1330 | 70 | 75 | ||
1331 | === modified file 'test/t/ib_stream_incremental.sh' | |||
1332 | --- test/t/ib_stream_incremental.sh 2012-06-05 12:35:33 +0000 | |||
1333 | +++ test/t/ib_stream_incremental.sh 2013-07-04 07:51:31 +0000 | |||
1334 | @@ -98,7 +98,7 @@ | |||
1335 | 98 | exit -1 | 98 | exit -1 |
1336 | 99 | fi | 99 | fi |
1337 | 100 | 100 | ||
1339 | 101 | clean | 101 | remove_var_dirs |
1340 | 102 | } | 102 | } |
1341 | 103 | 103 | ||
1342 | 104 | stream_format="xbstream" | 104 | stream_format="xbstream" |
1343 | 105 | 105 | ||
1344 | === modified file 'test/t/remote_tablespaces.sh' | |||
1345 | --- test/t/remote_tablespaces.sh 2013-04-23 06:38:06 +0000 | |||
1346 | +++ test/t/remote_tablespaces.sh 2013-07-04 07:51:31 +0000 | |||
1347 | @@ -12,7 +12,7 @@ | |||
1348 | 12 | 12 | ||
1349 | 13 | start_server --innodb_file_per_table | 13 | start_server --innodb_file_per_table |
1350 | 14 | 14 | ||
1352 | 15 | remote_dir=$TEST_BASEDIR/var1/remote_dir | 15 | remote_dir=$TEST_VAR_ROOT/var1/remote_dir |
1353 | 16 | 16 | ||
1354 | 17 | $MYSQL $MYSQL_ARGS test <<EOF | 17 | $MYSQL $MYSQL_ARGS test <<EOF |
1355 | 18 | CREATE TABLE t(id INT AUTO_INCREMENT PRIMARY KEY, c INT) | 18 | CREATE TABLE t(id INT AUTO_INCREMENT PRIMARY KEY, c INT) |
1356 | 19 | 19 | ||
1357 | === modified file 'test/t/undo_tablespaces.sh' | |||
1358 | --- test/t/undo_tablespaces.sh 2013-04-27 18:46:54 +0000 | |||
1359 | +++ test/t/undo_tablespaces.sh 2013-07-04 07:51:31 +0000 | |||
1360 | @@ -23,7 +23,7 @@ | |||
1361 | 23 | EOF | 23 | EOF |
1362 | 24 | } | 24 | } |
1363 | 25 | 25 | ||
1365 | 26 | undo_directory=$TEST_BASEDIR/var1/undo_dir | 26 | undo_directory=$TEST_VAR_ROOT/var1/undo_dir |
1366 | 27 | 27 | ||
1367 | 28 | MYSQLD_EXTRA_MY_CNF_OPTS=" | 28 | MYSQLD_EXTRA_MY_CNF_OPTS=" |
1368 | 29 | innodb_file_per_table=1 | 29 | innodb_file_per_table=1 |
1369 | 30 | 30 | ||
1370 | === modified file 'test/t/xb_encrypt.sh' | |||
1371 | --- test/t/xb_encrypt.sh 2013-03-11 19:11:29 +0000 | |||
1372 | +++ test/t/xb_encrypt.sh 2013-07-04 07:51:31 +0000 | |||
1373 | @@ -5,8 +5,6 @@ | |||
1374 | 5 | encrypt_algo="AES256" | 5 | encrypt_algo="AES256" |
1375 | 6 | encrypt_key="percona_xtrabackup_is_awesome___" | 6 | encrypt_key="percona_xtrabackup_is_awesome___" |
1376 | 7 | 7 | ||
1377 | 8 | echo -n "Percona XtraBackup is awesome!!!" > $encrypt_key_file | ||
1378 | 9 | |||
1379 | 10 | innobackupex_options="--encrypt=$encrypt_algo --encrypt-key=$encrypt_key --encrypt-threads=4 --encrypt-chunk-size=8K" | 8 | innobackupex_options="--encrypt=$encrypt_algo --encrypt-key=$encrypt_key --encrypt-threads=4 --encrypt-chunk-size=8K" |
1380 | 11 | data_decrypt_cmd="for i in *.xbcrypt; do \ | 9 | data_decrypt_cmd="for i in *.xbcrypt; do \ |
1381 | 12 | xbcrypt -d -a $encrypt_algo -k $encrypt_key < \$i > \${i:0:\${#i}-8}; \ | 10 | xbcrypt -d -a $encrypt_algo -k $encrypt_key < \$i > \${i:0:\${#i}-8}; \ |
1382 | 13 | 11 | ||
1383 | === modified file 'test/t/xb_part_range.sh' | |||
1384 | --- test/t/xb_part_range.sh 2012-07-06 05:13:15 +0000 | |||
1385 | +++ test/t/xb_part_range.sh 2013-07-04 07:51:31 +0000 | |||
1386 | @@ -1,19 +1,9 @@ | |||
1387 | 1 | . inc/common.sh | 1 | . inc/common.sh |
1388 | 2 | . inc/ib_part.sh | ||
1389 | 2 | 3 | ||
1390 | 3 | start_server | 4 | start_server |
1391 | 4 | 5 | ||
1404 | 5 | function check_partitioning() | 6 | require_partitioning |
1393 | 6 | { | ||
1394 | 7 | $MYSQL $MYSQL_ARGS -Ns -e "show variables like 'have_partitioning'" | ||
1395 | 8 | } | ||
1396 | 9 | |||
1397 | 10 | PARTITION_CHECK=`check_partitioning` | ||
1398 | 11 | |||
1399 | 12 | if [ -z "$PARTITION_CHECK" ]; then | ||
1400 | 13 | echo "Requires Partitioning." > $SKIPPED_REASON | ||
1401 | 14 | stop_server | ||
1402 | 15 | exit $SKIPPED_EXIT_CODE | ||
1403 | 16 | fi | ||
1405 | 17 | 7 | ||
1406 | 18 | run_cmd $MYSQL $MYSQL_ARGS test <<EOF | 8 | run_cmd $MYSQL $MYSQL_ARGS test <<EOF |
1407 | 19 | CREATE TABLE test ( | 9 | CREATE TABLE test ( |
1408 | 20 | 10 | ||
1409 | === modified file 'test/t/xb_perm_basic.sh' | |||
1410 | --- test/t/xb_perm_basic.sh 2012-10-15 16:14:59 +0000 | |||
1411 | +++ test/t/xb_perm_basic.sh 2013-07-04 07:51:31 +0000 | |||
1412 | @@ -4,6 +4,4 @@ | |||
1413 | 4 | start_server | 4 | start_server |
1414 | 5 | 5 | ||
1415 | 6 | chmod -R 500 $mysql_datadir | 6 | chmod -R 500 $mysql_datadir |
1416 | 7 | trap "vlog restoring permissions on datadir $mysql_datadir ; \ | ||
1417 | 8 | chmod -R 700 $mysql_datadir" INT TERM EXIT | ||
1418 | 9 | innobackupex --no-timestamp $topdir/backup | 7 | innobackupex --no-timestamp $topdir/backup |
1419 | 10 | 8 | ||
1420 | === modified file 'test/t/xb_perm_stream.sh' | |||
1421 | --- test/t/xb_perm_stream.sh 2012-10-15 16:14:59 +0000 | |||
1422 | +++ test/t/xb_perm_stream.sh 2013-07-04 07:51:31 +0000 | |||
1423 | @@ -5,7 +5,5 @@ | |||
1424 | 5 | 5 | ||
1425 | 6 | # Take backup | 6 | # Take backup |
1426 | 7 | chmod -R 500 $mysql_datadir | 7 | chmod -R 500 $mysql_datadir |
1427 | 8 | trap "vlog restoring permissions on datadir $mysql_datadir ; \ | ||
1428 | 9 | chmod -R 700 $mysql_datadir" INT TERM EXIT | ||
1429 | 10 | mkdir -p $topdir/backup | 8 | mkdir -p $topdir/backup |
1430 | 11 | innobackupex --stream=tar $topdir/backup > $topdir/backup/out.tar | 9 | innobackupex --stream=tar $topdir/backup > $topdir/backup/out.tar |
1431 | 12 | 10 | ||
1432 | === modified file 'test/t/xb_stats_datadir.sh' | |||
1433 | --- test/t/xb_stats_datadir.sh 2013-05-02 13:05:59 +0000 | |||
1434 | +++ test/t/xb_stats_datadir.sh 2013-07-04 07:51:31 +0000 | |||
1435 | @@ -5,12 +5,11 @@ | |||
1436 | 5 | 5 | ||
1437 | 6 | . inc/common.sh | 6 | . inc/common.sh |
1438 | 7 | 7 | ||
1442 | 8 | mkdir ${TEST_BASEDIR}/logs | 8 | logdir=${TEST_VAR_ROOT}/logs |
1443 | 9 | 9 | mkdir $logdir | |
1441 | 10 | trap "rm -rf ${TEST_BASEDIR}/logs" INT TERM EXIT | ||
1444 | 11 | 10 | ||
1445 | 12 | MYSQLD_EXTRA_MY_CNF_OPTS=" | 11 | MYSQLD_EXTRA_MY_CNF_OPTS=" |
1447 | 13 | innodb_log_group_home_dir=${TEST_BASEDIR}/logs | 12 | innodb_log_group_home_dir=$logdir |
1448 | 14 | " | 13 | " |
1449 | 15 | 14 | ||
1450 | 16 | start_server | 15 | start_server |
1451 | @@ -28,6 +27,6 @@ | |||
1452 | 28 | # we pass all necessary options as an arguments, so if someday this | 27 | # we pass all necessary options as an arguments, so if someday this |
1453 | 29 | # will be changed, test still will work | 28 | # will be changed, test still will work |
1454 | 30 | xtrabackup --stats --datadir=${MYSQLD_DATADIR} \ | 29 | xtrabackup --stats --datadir=${MYSQLD_DATADIR} \ |
1456 | 31 | --innodb_log_group_home_dir=${TEST_BASEDIR}/logs | 30 | --innodb_log_group_home_dir=$logdir |
1457 | 32 | 31 | ||
1458 | 33 | vlog "stats did not fail" | 32 | vlog "stats did not fail" |
1459 | 34 | 33 | ||
1460 | === removed file 'test/testrun.c' | |||
1461 | --- test/testrun.c 2013-06-14 00:59:24 +0000 | |||
1462 | +++ test/testrun.c 1970-01-01 00:00:00 +0000 | |||
1463 | @@ -1,405 +0,0 @@ | |||
1464 | 1 | /* | ||
1465 | 2 | * testrun.c - a parallel test runner for the XtraBackup test suite | ||
1466 | 3 | */ | ||
1467 | 4 | /* BEGIN LICENSE | ||
1468 | 5 | * Copyright (C) 2012 Percona Ireland Ltd. | ||
1469 | 6 | * | ||
1470 | 7 | * Written by Stewart Smith | ||
1471 | 8 | * | ||
1472 | 9 | * This program is free software: you can redistribute it and/or modify it | ||
1473 | 10 | * under the terms of the GNU General Public License version 2, as published | ||
1474 | 11 | * by the Free Software Foundation. | ||
1475 | 12 | * | ||
1476 | 13 | * This program is distributed in the hope that it will be useful, but | ||
1477 | 14 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1478 | 15 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1479 | 16 | * PURPOSE. See the GNU General Public License for more details. | ||
1480 | 17 | * | ||
1481 | 18 | * You should have received a copy of the GNU General Public License along | ||
1482 | 19 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1483 | 20 | * END LICENSE */ | ||
1484 | 21 | |||
1485 | 22 | #include <stdio.h> | ||
1486 | 23 | #include <unistd.h> | ||
1487 | 24 | #include <dirent.h> | ||
1488 | 25 | #include <string.h> | ||
1489 | 26 | #include <limits.h> | ||
1490 | 27 | #include <stdlib.h> | ||
1491 | 28 | #include <sys/select.h> | ||
1492 | 29 | |||
1493 | 30 | #include <sys/stat.h> | ||
1494 | 31 | #include <sys/types.h> | ||
1495 | 32 | #include <sys/wait.h> | ||
1496 | 33 | #include <fcntl.h> | ||
1497 | 34 | #include <assert.h> | ||
1498 | 35 | |||
1499 | 36 | #include <signal.h> | ||
1500 | 37 | |||
1501 | 38 | struct testcase | ||
1502 | 39 | { | ||
1503 | 40 | char *name; | ||
1504 | 41 | char *buf; | ||
1505 | 42 | size_t end_of_buf; | ||
1506 | 43 | size_t bufsz; | ||
1507 | 44 | }; | ||
1508 | 45 | |||
1509 | 46 | pid_t *childpid; | ||
1510 | 47 | int nchildpid=0; | ||
1511 | 48 | |||
1512 | 49 | static void kill_children(int sig) | ||
1513 | 50 | { | ||
1514 | 51 | int i; | ||
1515 | 52 | int status; | ||
1516 | 53 | |||
1517 | 54 | (void)sig; | ||
1518 | 55 | |||
1519 | 56 | fprintf(stderr, "Killing child processes...\n"); | ||
1520 | 57 | |||
1521 | 58 | for(i=0; i<nchildpid; i++) | ||
1522 | 59 | if(childpid[i] > 0) | ||
1523 | 60 | { | ||
1524 | 61 | kill(childpid[i], SIGKILL); | ||
1525 | 62 | wait(&status); | ||
1526 | 63 | } | ||
1527 | 64 | |||
1528 | 65 | exit(EXIT_SUCCESS); | ||
1529 | 66 | } | ||
1530 | 67 | |||
1531 | 68 | int collect_testcases_filter(const struct dirent *a) | ||
1532 | 69 | { | ||
1533 | 70 | int l; | ||
1534 | 71 | |||
1535 | 72 | if (a->d_name[0] == '.') | ||
1536 | 73 | return 0; | ||
1537 | 74 | |||
1538 | 75 | l= strlen(a->d_name); | ||
1539 | 76 | |||
1540 | 77 | if (l > 2 && strncmp(a->d_name + l - 3, ".sh", 3)==0) | ||
1541 | 78 | return 1; | ||
1542 | 79 | |||
1543 | 80 | return 0; | ||
1544 | 81 | } | ||
1545 | 82 | |||
1546 | 83 | static int collect_testcases(const char* suitedir, struct testcase **cases) | ||
1547 | 84 | { | ||
1548 | 85 | struct dirent **namelist; | ||
1549 | 86 | int n; | ||
1550 | 87 | int i; | ||
1551 | 88 | |||
1552 | 89 | n= scandir(suitedir, &namelist, collect_testcases_filter, alphasort); | ||
1553 | 90 | |||
1554 | 91 | *cases= (struct testcase*) malloc(sizeof(struct testcase)*n); | ||
1555 | 92 | |||
1556 | 93 | for(i=0; i<n; i++) | ||
1557 | 94 | { | ||
1558 | 95 | (*cases)[i].name= strdup(namelist[i]->d_name); | ||
1559 | 96 | (*cases)[i].buf= NULL; | ||
1560 | 97 | (*cases)[i].end_of_buf= 0; | ||
1561 | 98 | (*cases)[i].bufsz= 0; | ||
1562 | 99 | free(namelist[i]); | ||
1563 | 100 | } | ||
1564 | 101 | |||
1565 | 102 | free(namelist); | ||
1566 | 103 | |||
1567 | 104 | return n; | ||
1568 | 105 | } | ||
1569 | 106 | |||
1570 | 107 | static void free_testcases(struct testcase *cases, int n) | ||
1571 | 108 | { | ||
1572 | 109 | while (n>0) | ||
1573 | 110 | { | ||
1574 | 111 | free(cases[--n].name); | ||
1575 | 112 | } | ||
1576 | 113 | free(cases); | ||
1577 | 114 | } | ||
1578 | 115 | |||
1579 | 116 | static int run_testcase_in_child(int nr, struct testcase *t, pid_t *cpid, const char* xbtarget) | ||
1580 | 117 | { | ||
1581 | 118 | int fd[2]; | ||
1582 | 119 | |||
1583 | 120 | printf("[%d] LAUNCHING - %s\n", nr, t->name); | ||
1584 | 121 | |||
1585 | 122 | if (pipe(fd) == -1) | ||
1586 | 123 | { | ||
1587 | 124 | perror("pipe"); | ||
1588 | 125 | exit(EXIT_FAILURE); | ||
1589 | 126 | } | ||
1590 | 127 | |||
1591 | 128 | *cpid= fork(); | ||
1592 | 129 | if (*cpid == 0) | ||
1593 | 130 | { | ||
1594 | 131 | /* child */ | ||
1595 | 132 | close(fd[0]); | ||
1596 | 133 | |||
1597 | 134 | char tname[500]; | ||
1598 | 135 | snprintf(tname, sizeof(tname), "t/%s",t->name); | ||
1599 | 136 | |||
1600 | 137 | char basedir[PATH_MAX]; | ||
1601 | 138 | char cwd[PATH_MAX]; | ||
1602 | 139 | snprintf(basedir, sizeof(basedir), "%s/var/%d", getcwd(cwd,sizeof(cwd)), nr); | ||
1603 | 140 | |||
1604 | 141 | mkdir("var",0700); | ||
1605 | 142 | mkdir(basedir,0700); | ||
1606 | 143 | |||
1607 | 144 | char logname[PATH_MAX]; | ||
1608 | 145 | snprintf(logname, sizeof(logname), "%s/var/%d.log", getcwd(cwd,sizeof(cwd)), nr); | ||
1609 | 146 | |||
1610 | 147 | int logfd= open(logname, O_WRONLY|O_APPEND|O_CREAT, 0600); | ||
1611 | 148 | dup2(logfd, STDOUT_FILENO); | ||
1612 | 149 | dup2(logfd, STDERR_FILENO); | ||
1613 | 150 | close(logfd); | ||
1614 | 151 | |||
1615 | 152 | char subunitfd[50]; | ||
1616 | 153 | snprintf(subunitfd, sizeof(subunitfd), "/dev/fd/%d", fd[1]); | ||
1617 | 154 | |||
1618 | 155 | char* xbtarget_param; | ||
1619 | 156 | if (xbtarget) | ||
1620 | 157 | xbtarget_param= strdup(xbtarget); | ||
1621 | 158 | else | ||
1622 | 159 | xbtarget_param= NULL; | ||
1623 | 160 | |||
1624 | 161 | char *const newargv[] = {"testrun.sh", "-n", | ||
1625 | 162 | "-t", tname, | ||
1626 | 163 | "-b", basedir, | ||
1627 | 164 | "-r", subunitfd, | ||
1628 | 165 | (xbtarget)? "-c" : NULL, xbtarget_param, | ||
1629 | 166 | NULL }; | ||
1630 | 167 | char *newenviron[] = { NULL }; | ||
1631 | 168 | execve(newargv[0], newargv, newenviron); | ||
1632 | 169 | perror("execve"); | ||
1633 | 170 | exit(EXIT_FAILURE); | ||
1634 | 171 | } | ||
1635 | 172 | else | ||
1636 | 173 | { | ||
1637 | 174 | /* parent */ | ||
1638 | 175 | close(fd[1]); | ||
1639 | 176 | fcntl(fd[0], F_SETFL, O_NONBLOCK); | ||
1640 | 177 | return fd[0]; | ||
1641 | 178 | } | ||
1642 | 179 | } | ||
1643 | 180 | |||
1644 | 181 | static inline void subunit_progress_sign(int fd, int n, char *sign) | ||
1645 | 182 | { | ||
1646 | 183 | char *buf; | ||
1647 | 184 | const char* fmt= "progress: %s%d\n"; | ||
1648 | 185 | size_t sz= 1+strlen(fmt)+100; | ||
1649 | 186 | size_t l; | ||
1650 | 187 | |||
1651 | 188 | buf= (char*)malloc(sz); | ||
1652 | 189 | |||
1653 | 190 | l= snprintf(buf, sz, fmt, sign, n); | ||
1654 | 191 | assert(l < sz); | ||
1655 | 192 | |||
1656 | 193 | write(fd, buf, l); | ||
1657 | 194 | |||
1658 | 195 | free(buf); | ||
1659 | 196 | } | ||
1660 | 197 | |||
1661 | 198 | static void run_testcases(struct testcase *testcases, int nrcases, | ||
1662 | 199 | int njobs, int timeout, const char* xbtarget) | ||
1663 | 200 | { | ||
1664 | 201 | int childfd[njobs]; | ||
1665 | 202 | int nfds= 0; | ||
1666 | 203 | int retval; | ||
1667 | 204 | pid_t chpid[njobs]; | ||
1668 | 205 | int status; | ||
1669 | 206 | int next_testcase= 0; | ||
1670 | 207 | int i; | ||
1671 | 208 | fd_set rfds; | ||
1672 | 209 | fd_set efds; | ||
1673 | 210 | struct timeval tv; | ||
1674 | 211 | int nchildren; | ||
1675 | 212 | int childtest[njobs]; | ||
1676 | 213 | |||
1677 | 214 | int subunitfd= open("test_results.subunit", O_TRUNC|O_WRONLY|O_APPEND|O_CREAT, 0600); | ||
1678 | 215 | subunit_progress_sign(subunitfd, nrcases, ""); | ||
1679 | 216 | |||
1680 | 217 | if (nrcases < njobs) | ||
1681 | 218 | njobs= nrcases; | ||
1682 | 219 | |||
1683 | 220 | childpid= chpid; | ||
1684 | 221 | nchildpid= njobs; | ||
1685 | 222 | |||
1686 | 223 | for(i=0; i<njobs; i++) | ||
1687 | 224 | { | ||
1688 | 225 | childtest[i]=next_testcase++; | ||
1689 | 226 | childfd[i]= run_testcase_in_child(i, &testcases[childtest[i]], &childpid[i], xbtarget); | ||
1690 | 227 | } | ||
1691 | 228 | |||
1692 | 229 | fflush(stdout); | ||
1693 | 230 | |||
1694 | 231 | loop: | ||
1695 | 232 | FD_ZERO(&efds); | ||
1696 | 233 | FD_ZERO(&rfds); | ||
1697 | 234 | |||
1698 | 235 | nchildren=0; | ||
1699 | 236 | |||
1700 | 237 | for (i=0; i<njobs; i++) | ||
1701 | 238 | { | ||
1702 | 239 | if (childfd[i] != -1) | ||
1703 | 240 | { | ||
1704 | 241 | FD_SET(childfd[i], &efds); | ||
1705 | 242 | FD_SET(childfd[i], &rfds); | ||
1706 | 243 | nfds= (childfd[i] > nfds)? childfd[i] : nfds; | ||
1707 | 244 | nchildren++; | ||
1708 | 245 | } | ||
1709 | 246 | } | ||
1710 | 247 | |||
1711 | 248 | tv.tv_sec= timeout; | ||
1712 | 249 | tv.tv_usec= 0; | ||
1713 | 250 | |||
1714 | 251 | retval = select(nfds+1, &rfds, NULL, &efds, &tv); | ||
1715 | 252 | |||
1716 | 253 | if (retval == -1) | ||
1717 | 254 | perror("select()"); | ||
1718 | 255 | else if (retval) | ||
1719 | 256 | { | ||
1720 | 257 | int childexited=0; | ||
1721 | 258 | |||
1722 | 259 | for (i=0; i<njobs; i++) | ||
1723 | 260 | { | ||
1724 | 261 | if(childfd[i] != -1 | ||
1725 | 262 | && (FD_ISSET(childfd[i], &efds) || FD_ISSET(childfd[i], &rfds))) | ||
1726 | 263 | { | ||
1727 | 264 | ssize_t r=0; | ||
1728 | 265 | |||
1729 | 266 | do { | ||
1730 | 267 | struct testcase *t= &testcases[childtest[i]]; | ||
1731 | 268 | |||
1732 | 269 | if(t->bufsz == t->end_of_buf) | ||
1733 | 270 | { | ||
1734 | 271 | t->bufsz+=4000; | ||
1735 | 272 | t->buf= (char*)realloc(t->buf, t->bufsz); | ||
1736 | 273 | } | ||
1737 | 274 | |||
1738 | 275 | r= read(childfd[i], t->buf+t->end_of_buf, t->bufsz - t->end_of_buf); | ||
1739 | 276 | if (r>0) | ||
1740 | 277 | t->end_of_buf+= r; | ||
1741 | 278 | } while(r>0); | ||
1742 | 279 | |||
1743 | 280 | pid_t waited= waitpid(childpid[i], &status, WNOHANG); | ||
1744 | 281 | if (!(WIFEXITED(status) || WIFSIGNALED(status))) | ||
1745 | 282 | continue; | ||
1746 | 283 | |||
1747 | 284 | if (waited != childpid[i]) | ||
1748 | 285 | continue; | ||
1749 | 286 | |||
1750 | 287 | write(subunitfd, testcases[childtest[i]].buf, | ||
1751 | 288 | testcases[childtest[i]].end_of_buf); | ||
1752 | 289 | |||
1753 | 290 | close(childfd[i]); | ||
1754 | 291 | printf("[%d] completed %s status %d\n", | ||
1755 | 292 | i, testcases[childtest[i]].name, WEXITSTATUS(status)); | ||
1756 | 293 | childfd[i]=-1; | ||
1757 | 294 | nchildren--; | ||
1758 | 295 | |||
1759 | 296 | if (next_testcase < nrcases) | ||
1760 | 297 | { | ||
1761 | 298 | childtest[i]=next_testcase++; | ||
1762 | 299 | childfd[i]= run_testcase_in_child(i, &testcases[childtest[i]], &childpid[i], xbtarget); | ||
1763 | 300 | nfds= (childfd[i] > nfds)? childfd[i] : nfds; | ||
1764 | 301 | nchildren++; | ||
1765 | 302 | } | ||
1766 | 303 | printf("\nnrchildren= %d, %d tests remaining\n", | ||
1767 | 304 | nchildren, nrcases-next_testcase); | ||
1768 | 305 | childexited=1; | ||
1769 | 306 | fflush(stdout); | ||
1770 | 307 | } | ||
1771 | 308 | } | ||
1772 | 309 | if (childexited) | ||
1773 | 310 | { | ||
1774 | 311 | printf ("Running: "); | ||
1775 | 312 | for(i=0; i<njobs; i++) | ||
1776 | 313 | if (childfd[i] != -1) | ||
1777 | 314 | printf("%s ",testcases[childtest[i]].name); | ||
1778 | 315 | printf("\n"); | ||
1779 | 316 | } | ||
1780 | 317 | } | ||
1781 | 318 | else | ||
1782 | 319 | { | ||
1783 | 320 | printf("Timeout\n"); | ||
1784 | 321 | kill_children(SIGKILL); | ||
1785 | 322 | exit(EXIT_FAILURE); | ||
1786 | 323 | } | ||
1787 | 324 | |||
1788 | 325 | if (nchildren==0) | ||
1789 | 326 | goto end; | ||
1790 | 327 | |||
1791 | 328 | goto loop; | ||
1792 | 329 | |||
1793 | 330 | end: | ||
1794 | 331 | |||
1795 | 332 | close(subunitfd); | ||
1796 | 333 | return; | ||
1797 | 334 | } | ||
1798 | 335 | |||
1799 | 336 | int main(int argc, char* argv[]) | ||
1800 | 337 | { | ||
1801 | 338 | const char* suitedir= "t/"; | ||
1802 | 339 | int njobs= 4; | ||
1803 | 340 | int opt; | ||
1804 | 341 | int nrcases; | ||
1805 | 342 | struct testcase *testcases; | ||
1806 | 343 | int timeout= 600; | ||
1807 | 344 | const char* xbtarget= NULL; | ||
1808 | 345 | |||
1809 | 346 | struct sigaction sa; | ||
1810 | 347 | |||
1811 | 348 | sa.sa_flags= 0; | ||
1812 | 349 | sigemptyset(&sa.sa_mask); | ||
1813 | 350 | sa.sa_handler = kill_children; | ||
1814 | 351 | sigaction(SIGHUP, &sa, NULL); | ||
1815 | 352 | sigaction(SIGINT, &sa, NULL); | ||
1816 | 353 | sigaction(SIGQUIT, &sa, NULL); | ||
1817 | 354 | |||
1818 | 355 | #ifdef _SC_NPROCESSORS_ONLN | ||
1819 | 356 | njobs= sysconf(_SC_NPROCESSORS_ONLN); | ||
1820 | 357 | #endif | ||
1821 | 358 | |||
1822 | 359 | #ifdef _SC_PHYS_PAGES | ||
1823 | 360 | long nrpages= sysconf(_SC_PHYS_PAGES); | ||
1824 | 361 | long pagesize= sysconf(_SC_PAGESIZE); | ||
1825 | 362 | long pages_per_job= (128*(1 << 20)) / pagesize; | ||
1826 | 363 | nrpages= nrpages/2; | ||
1827 | 364 | if ((pages_per_job * njobs) > nrpages) | ||
1828 | 365 | njobs= nrpages / pages_per_job; | ||
1829 | 366 | #endif | ||
1830 | 367 | |||
1831 | 368 | if (njobs == 0) | ||
1832 | 369 | njobs= 1; | ||
1833 | 370 | |||
1834 | 371 | while ((opt = getopt(argc, argv, "j:s:t:c:")) != -1) | ||
1835 | 372 | { | ||
1836 | 373 | switch (opt) { | ||
1837 | 374 | case 'c': | ||
1838 | 375 | xbtarget= optarg; | ||
1839 | 376 | break; | ||
1840 | 377 | case 's': | ||
1841 | 378 | suitedir= optarg; | ||
1842 | 379 | break; | ||
1843 | 380 | case 'j': | ||
1844 | 381 | njobs= atoi(optarg); | ||
1845 | 382 | break; | ||
1846 | 383 | case 't': | ||
1847 | 384 | timeout= atoi(optarg); | ||
1848 | 385 | break; | ||
1849 | 386 | default: | ||
1850 | 387 | fprintf(stderr, "Usage: %s [-s suite] [-j parallel] [-t timeout]\n", | ||
1851 | 388 | argv[0]); | ||
1852 | 389 | exit(EXIT_FAILURE); | ||
1853 | 390 | } | ||
1854 | 391 | } | ||
1855 | 392 | |||
1856 | 393 | printf("%s running with: -s %s -j %d -t %d\n\n", | ||
1857 | 394 | argv[0], suitedir,njobs, timeout); | ||
1858 | 395 | |||
1859 | 396 | nrcases= collect_testcases(suitedir, &testcases); | ||
1860 | 397 | |||
1861 | 398 | printf("Found %d testcases\n", nrcases); | ||
1862 | 399 | |||
1863 | 400 | run_testcases(testcases, nrcases, njobs, timeout, xbtarget); | ||
1864 | 401 | |||
1865 | 402 | free_testcases(testcases, nrcases); | ||
1866 | 403 | |||
1867 | 404 | return 0; | ||
1868 | 405 | } |
http:// jenkins. percona. com/view/ XtraBackup/ job/percona- xtrabackup- 2.1-param/ 360/
Same comments on remaining failures as in the 2.0 MP.