mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-26 23:45:44 +00:00
Make pt-table-checksum always create the database/table it needs
This commit is contained in:
@@ -41,9 +41,6 @@ elsif ( !$slave1_dbh ) {
|
||||
elsif ( !@{$master_dbh->selectall_arrayref("show databases like 'sakila'")} ) {
|
||||
plan skip_all => 'sakila database is not loaded';
|
||||
}
|
||||
else {
|
||||
plan tests => 3;
|
||||
}
|
||||
|
||||
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
|
||||
# so we need to specify --lock-wait-timeout=3 else the tool will die.
|
||||
@@ -54,6 +51,49 @@ my $output;
|
||||
my $exit_status;
|
||||
my $sample = "t/pt-table-checksum/samples/";
|
||||
|
||||
# ############################################################################
|
||||
# Should always create schema and tables with IF NOT EXISTS
|
||||
# https://bugs.launchpad.net/percona-toolkit/+bug/950294
|
||||
# ############################################################################
|
||||
|
||||
$sb->wipe_clean($master_dbh);
|
||||
diag(`/tmp/12345/use -u root < $trunk/t/lib/samples/ro-checksum-user.sql 2>/dev/null`);
|
||||
PerconaTest::wait_for_table($slave1_dbh, "mysql.tables_priv", "user='ro_checksum_user'");
|
||||
|
||||
($output, $exit_status) = full_output(
|
||||
sub { pt_table_checksum::main(@args,
|
||||
"$master_dsn,u=ro_checksum_user,p=msandbox",
|
||||
qw(--recursion-method none)
|
||||
) },
|
||||
);
|
||||
|
||||
isnt($exit_status, 0, "");
|
||||
like($output,
|
||||
qr/\Q--replicate database percona does not exist and it cannot be created automatically/,
|
||||
"fails if the percona db doesn't exist and the user can't create it",
|
||||
);
|
||||
|
||||
($output, $exit_status) = full_output(
|
||||
sub { pt_table_checksum::main(@args,
|
||||
"$master_dsn,u=ro_checksum_user,p=msandbox",
|
||||
qw(--recursion-method none --no-create-replicate-table)
|
||||
) },
|
||||
);
|
||||
|
||||
like($output,
|
||||
qr/\Q--replicate database percona does not exist and --no-create-replicate-table was/,
|
||||
"fails if the percona db doesn't exist and --no-create-replicate-table",
|
||||
);
|
||||
|
||||
diag(`/tmp/12345/use -u root -e "drop user 'ro_checksum_user'\@'%'"`);
|
||||
wait_until(
|
||||
sub {
|
||||
my $rows=$slave2_dbh->selectall_arrayref("SELECT user FROM mysql.user");
|
||||
return !grep { ($_->[0] || '') ne 'ro_checksum_user' } @$rows;
|
||||
}
|
||||
);
|
||||
$sb->wipe_clean($master_dbh);
|
||||
|
||||
# ############################################################################
|
||||
# --recursion-method=none to avoid SHOW SLAVE HOSTS
|
||||
# https://bugs.launchpad.net/percona-toolkit/+bug/987694
|
||||
@@ -64,7 +104,7 @@ pt_table_checksum::main(@args,
|
||||
"$master_dsn,u=msandbox,p=msandbox",
|
||||
qw(-t sakila.country --quiet --quiet));
|
||||
|
||||
diag(`/tmp/12345/use -u root < $trunk/t/lib/samples/ro-checksum-user.sql`);
|
||||
diag(`/tmp/12345/use -u root < $trunk/t/lib/samples/ro-checksum-user.sql 2>/dev/null`);
|
||||
PerconaTest::wait_for_table($slave1_dbh, "mysql.tables_priv", "user='ro_checksum_user'");
|
||||
|
||||
$output = output(
|
||||
@@ -90,6 +130,20 @@ like(
|
||||
"Read-only user (bug 987694): checksummed rows"
|
||||
);
|
||||
|
||||
diag(qx{/tmp/12345/use -u root -e 'DROP TABLE `percona`.`checksums`'});
|
||||
|
||||
($output, $exit_status) = full_output(
|
||||
sub { pt_table_checksum::main(@args,
|
||||
"$master_dsn,u=ro_checksum_user,p=msandbox",
|
||||
qw(--recursion-method none --no-create-replicate-table)
|
||||
) },
|
||||
);
|
||||
|
||||
like($output,
|
||||
qr/\Q--replicate table `percona`.`checksums` does not exist and --no/,
|
||||
"fails if the checksums db doesn't exist and --no-create-replicate-table"
|
||||
);
|
||||
|
||||
diag(`/tmp/12345/use -u root -e "drop user 'ro_checksum_user'\@'%'"`);
|
||||
wait_until(
|
||||
sub {
|
||||
@@ -103,4 +157,5 @@ wait_until(
|
||||
# #############################################################################
|
||||
$sb->wipe_clean($master_dbh);
|
||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||
exit;
|
||||
|
||||
done_testing;
|
||||
|
Reference in New Issue
Block a user