~percona-toolkit-dev/percona-toolkit/fix-1062563-1063912-ptc-pxc-bugs

« back to all changes in this revision

Viewing changes to t/pt-slave-delay/auto_restart.t

  • Committer: Daniel Nichter
  • Date: 2012-10-25 21:36:24 UTC
  • Revision ID: daniel@percona.com-20121025213624-95czvkp2nmnish5v
Fix t/pt-slave-delay/auto_restart.t and use direct call, no backticks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
elsif ( !@{$dbh->selectcol_arrayref("SHOW DATABASES LIKE 'sakila'")} ) {
30
30
   plan skip_all => 'sakila db not loaded';
31
31
}
32
 
else {
33
 
   plan tests => 3;
34
 
}
35
32
 
36
33
my $cnf = '/tmp/12346/my.sandbox.cnf';
37
 
my $cmd = "$trunk/bin/pt-slave-delay -F $cnf";
38
34
my $output;
39
35
 
40
36
# #############################################################################
49
45
my $pid = fork();
50
46
if ( $pid ) {
51
47
   # parent
52
 
   $output = `$cmd --interval 1 --run-time 4 2>&1`;
 
48
   $output = output(
 
49
      sub { pt_slave_delay::main('-F', $cnf, qw(--interval 1 --run-time 4)) },
 
50
      stderr => 1,
 
51
   );
53
52
   like(
54
53
      $output,
55
 
      qr/Lost connection.+?Reconnected to slave.+Setting slave to run/ms,
 
54
      qr/Lost connection.+?Setting slave to run/ms,
56
55
      "Reconnect to slave"
57
56
   );
58
57
}
70
69
# Reap the child.
71
70
waitpid ($pid, 0);
72
71
 
 
72
$sb->wait_for_slaves;
 
73
 
73
74
# Do it all over again, but this time KILL instead of restart.
74
75
$pid = fork();
75
76
if ( $pid ) {
76
77
   # parent. Note the --database mysql
77
 
   $output = `$cmd --database mysql --interval 1 --run-time 4 2>&1`;
 
78
   $output = output(
 
79
      sub { pt_slave_delay::main('-F', $cnf, qw(--interval 1 --run-time 4),
 
80
         qw(--database mysql)) },
 
81
      stderr => 1,
 
82
   );
78
83
   like(
79
84
      $output,
80
 
      qr/Lost connection.+?Reconnected to slave.+Setting slave to run/ms,
 
85
      qr/Lost connection.+?Setting slave to run/ms,
81
86
      "Reconnect to slave when KILL'ed"
82
87
   );
83
88
}
106
111
# #############################################################################
107
112
$sb->wipe_clean($master_dbh);
108
113
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
 
114
done_testing;
109
115
exit;