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);
16
require "$trunk/bin/pt-online-schema-change";
17
require VersionParser;
19
use Time::HiRes qw(sleep);
21
$Data::Dumper::Indent = 1;
22
$Data::Dumper::Sortkeys = 1;
23
$Data::Dumper::Quotekeys = 0;
25
my $dp = new DSNParser(opts=>$dsn_opts);
26
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
27
my $dbh1 = $sb->get_dbh_for('master');
28
my $dbh2 = $sb->get_dbh_for('master');
30
if ( !$dbh1 || !$dbh2 ) {
31
plan skip_all => 'Cannot connect to sandbox master';
33
elsif ( $sandbox_version lt '5.5' ) {
34
plan skip_all => "Metadata locks require MySQL 5.5 and newer";
38
my $master_dsn = $sb->dsn_for('master');
39
my $sample = "t/pt-online-schema-change/samples";
40
my $plugin = "$trunk/$sample/plugins";
44
# Loads pt_osc.t with cols id (pk), c (unique index),, d.
45
$sb->load_file('master', "$sample/basic_no_fks_innodb.sql");
47
# #############################################################################
48
# Meta-block on create_triggers.
49
# #############################################################################
51
($output) = full_output(
52
sub { pt_online_schema_change::main(
53
"$master_dsn,D=pt_osc,t=t",
54
qw(--statistics --execute --tries drop_triggers:1:0.01),
55
qw(--set-vars lock_wait_timeout=1 --print --no-swap-tables),
56
'--plugin', "$plugin/make_drop_trigger_fail.pm",
61
my $triggers = $dbh1->selectall_arrayref("SHOW TRIGGERS FROM pt_osc");
65
"Bug 1188002: triggers not dropped"
66
) or diag(Dumper($triggers));
68
my $tables = $dbh1->selectall_arrayref("SHOW TABLES FROM pt_osc");
71
[ ['_t_new'], ['t'] ],
72
"Bug 1188002: new table not dropped"
73
) or diag(Dumper($tables));
75
# #############################################################################
77
# #############################################################################
78
$sb->wipe_clean($dbh1);
79
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");