diff --git a/t/lib/bash/collect.sh b/t/lib/bash/collect.sh index 5ef21120..5dd3487d 100644 --- a/t/lib/bash/collect.sh +++ b/t/lib/bash/collect.sh @@ -23,7 +23,7 @@ p="$PT_TMPDIR/collect/2011_12_05" # Default collect, no extras like gdb, tcpdump, etc. collect "$PT_TMPDIR/collect" "2011_12_05" > $p-output 2>&1 -wait_for_files "$p-hostname" "$p-opentables2" "$p-variables" "$p-df" +wait_for_files "$p-hostname" "$p-opentables2" "$p-variables" "$p-df" "$p-innodbstatus2" # Even if this system doesn't have all the cmds, collect should still # have created some files for cmds that (hopefully) all systems have. @@ -68,6 +68,7 @@ cmd_ok \ "Finds MySQL error log" if [[ "$SANDBOX_VERSION" > "5.0" ]]; then + wait_for_files "$p-log_error" cmd_ok \ "grep -qE 'Memory status|Open streams|Begin safemalloc' $p-log_error" \ "debug" diff --git a/t/lib/bash/collect_mysql_info.sh b/t/lib/bash/collect_mysql_info.sh index 4bb4557d..6bdfc5c2 100644 --- a/t/lib/bash/collect_mysql_info.sh +++ b/t/lib/bash/collect_mysql_info.sh @@ -85,6 +85,7 @@ is \ "$cnf_file" \ "/tmp/12345/my.sandbox.cnf" \ "find_my_cnf_file gets the correct file" +[ $? -ne 0 ] && diag "$p/mysqld-instances" res=$(find_my_cnf_file "$samples/ps-mysqld-001.txt") is "$res" "/tmp/12345/my.sandbox.cnf" "ps-mysqld-001.txt" diff --git a/t/pt-query-digest/read_timeout.t b/t/pt-query-digest/read_timeout.t index 48a363ad..bd4c386a 100644 --- a/t/pt-query-digest/read_timeout.t +++ b/t/pt-query-digest/read_timeout.t @@ -21,8 +21,9 @@ use POSIX qw(mkfifo); # ######################################################################### my $pid_file = '/tmp/mqd.pid'; my $fifo = '/tmp/mqd.fifo'; -unlink $pid_file and diag("Unlinking existing $pid_file"); -unlink $fifo and diag("Unlinking existing $fifo"); + +unlink $pid_file if $pid_file; +unlink $fifo if $fifo; my ($start, $end, $waited, $timeout); SKIP: { @@ -40,7 +41,7 @@ SKIP: { ); $end = time; $waited = $end - $start; - if ( $timeout ) { + if ( $timeout && -f $pid_file ) { # mqd ran longer than --read-timeout chomp(my $pid = slurp_file($pid_file)); kill SIGTERM => $pid if $pid; @@ -52,7 +53,7 @@ SKIP: { ); } -unlink $pid_file; +unlink $pid_file if $pid_file; mkfifo $fifo, 0700; system("$trunk/t/pt-query-digest/samples/write-to-fifo.pl $fifo 4 &"); @@ -66,7 +67,7 @@ $timeout = wait_for( ); $end = time; $waited = $end - $start; -if ( $timeout ) { +if ( $timeout && $pid_file ) { # mqd ran longer than --read-timeout chomp(my $pid = slurp_file($pid_file)); kill SIGTERM => $pid if $pid; @@ -77,8 +78,8 @@ ok( sprintf("--read-timeout waited %.1f seconds reading a file", $waited) ); -unlink $pid_file; -unlink $fifo; +unlink $pid_file if $pid_file; +unlink $fifo if $fifo; # ############################################################################# # Done. diff --git a/util/test-bash-functions b/util/test-bash-functions index 133aab74..2616c7c8 100755 --- a/util/test-bash-functions +++ b/util/test-bash-functions @@ -204,13 +204,24 @@ wait_for_files() { for file in "$@"; do local slept=0 while ! [ -f $file ]; do - sleep 0.1; + sleep 0.2; slept=$((slept + 1)) - [ $slept -ge 50 ] && break # 5s + [ $slept -ge 150 ] && break # 30s done done } +diag() { + if [ $# -eq 1 -a -f "$1" ]; then + echo "# $1:" + awk '{print "# " $0}' "$1" + else + for line in "$@"; do + echo "# $line" + done + fi +} + # ############################################################################ # Script starts here # ############################################################################