diff --git a/t/lib/Daemon.t b/t/lib/Daemon.t index 80737a27..4e2f2ca2 100644 --- a/t/lib/Daemon.t +++ b/t/lib/Daemon.t @@ -24,8 +24,8 @@ my $d = new Daemon(o=>$o); my $pid_file = '/tmp/daemonizes.pl.pid'; my $log_file = '/tmp/daemonizes.output'; sub rm_tmp_files() { - 1 while unlink $pid_file; - 1 while unlink $log_file; + -e $pid_file && (unlink $pid_file || die "Error removing $pid_file"); + -e $log_file && (unlink $log_file || die "Error removing $log_file"); } # ############################################################################ @@ -124,8 +124,8 @@ SKIP: { 'Reopens STDIN to /dev/null' ); - TODO: { - local $::TODO = "?"; + SKIP: { + skip "-t is not reliable", 1; rm_tmp_files(); system("echo foo | $cmd 5 --daemonize --pid $pid_file --log $log_file"); PerconaTest::wait_for_files($pid_file, $log_file); @@ -169,29 +169,35 @@ ok( my (undef, $tempfile) = tempfile(); system("$cmd 5 --daemonize --log $log_file --pid $pid_file 2>$tempfile"); -PerconaTest::wait_for_files($log_file); +PerconaTest::wait_for_files($log_file, $pid_file); + $output = `ps wx | grep '$cmd 5' | grep -v grep`; chomp(my $new_pid = slurp_file($pid_file)); -sleep 1; + like( $output, qr/$cmd/, 'Runs when PID file exists but old process is dead (issue 419)' ); + like( slurp_file($tempfile), qr/$pid, is not running/, 'Says that old PID is not running (issue 419)' ); + ok( $pid != $new_pid, 'Overwrites PID file with new PID (issue 419)' ); + +PerconaTest::wait_until(sub { !-e $pid_file }); ok( !-f $pid_file, 'Re-used PID file still removed (issue 419)' ); -diag(`rm -rf /tmp/pre-daemonizes`); + +diag(`rm $tempfile >/dev/null`); # ############################################################################ # Check that it actually checks the running process. diff --git a/t/pt-table-sync/bidirectional.t b/t/pt-table-sync/bidirectional.t index 50b7d951..4dde1a13 100644 --- a/t/pt-table-sync/bidirectional.t +++ b/t/pt-table-sync/bidirectional.t @@ -534,7 +534,8 @@ SKIP: { # ############################################################################# # Done. # ############################################################################# -diag(`$trunk/sandbox/stop-sandbox 2900 >/dev/null`); diag(`$trunk/sandbox/stop-sandbox 2901 >/dev/null`); +diag(`$trunk/sandbox/stop-sandbox 2900 >/dev/null`); +$sb->wipe_clean($c1_dbh); ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); exit; diff --git a/t/pt-table-sync/issue_1065.t b/t/pt-table-sync/issue_1065.t index 5a0636f7..ea61787f 100644 --- a/t/pt-table-sync/issue_1065.t +++ b/t/pt-table-sync/issue_1065.t @@ -58,5 +58,6 @@ like( # ############################################################################# # Done. # ############################################################################# +$sb->wipe_clean($master_dbh); ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); exit;