4
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
5
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
6
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
10
use warnings FATAL => 'all';
11
use English qw(-no_match_vars);
13
use Time::HiRes qw(time);
14
use File::Temp qw(tempdir);
16
$ENV{PERCONA_TOOLKIT_TEST_USE_DSN_NAMES} = 1;
20
require "$trunk/bin/pt-upgrade";
22
# This runs immediately if the server is already running, else it starts it.
23
diag(`$trunk/sandbox/start-sandbox master 12348 >/dev/null`);
25
my $dp = new DSNParser(opts=>$dsn_opts);
26
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
27
my $dbh1 = $sb->get_dbh_for('host1');
28
my $dbh2 = $sb->get_dbh_for('host2');
31
plan skip_all => 'Cannot connect to sandbox host1';
34
plan skip_all => 'Cannot connect to sandbox host2';
37
my $host1_dsn = $sb->dsn_for('host1');
38
my $host2_dsn = $sb->dsn_for('host2');
39
my $tmpdir = tempdir("/tmp/pt-upgrade.$PID.XXXXXX", CLEANUP => 1);
40
my $samples = "$trunk/t/pt-upgrade/samples";
44
# #############################################################################
46
# #############################################################################
52
$exit_status = pt_upgrade::main($host1_dsn, $host2_dsn,
53
"$samples/slow_slow.log", qw(--run-time 3),
54
'--progress', 'time,1',
63
"Exec queries: ran for roughly --run-time seconds"
64
) or diag($output, 'Actual run time:', $t);
66
# Exit status 8 = --run-time expired (an no other errors/problems)
70
"Exec queries: exit status 8"
75
qr/slow_slow.log.+?remain/,
76
"Exec queries: --progress"
79
# #############################################################################
81
# #############################################################################
87
$exit_status = pt_upgrade::main($host1_dsn,
88
'--save-results', $tmpdir,
89
"$samples/slow_slow.log", qw(--run-time 3),
90
'--progress', 'time,1',
99
"Save results: ran for roughly --run-time seconds"
100
) or diag($output, 'Actual run time:', $t);
102
# Exit status 8 = --run-time expired (an no other errors/problems)
106
"Save results: exit status 8"
111
qr/slow_slow.log.+?remain/,
112
"Save results: --progress"
115
# #############################################################################
117
# #############################################################################
118
#$sb->wipe_clean($dbh2);
119
$sb->wipe_clean($dbh1);
120
diag(`$trunk/sandbox/stop-sandbox 12348 >/dev/null`);
121
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");