mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-20 17:49:56 +00:00
Fix more test output broken by percona_test.load_data. Tweak ptc/t/privs.t so it passes on my box. Fix new start/stop scripts: don't check ibdata1 because SKIP_INNODB may be used. Make PerconaTest::output() cleaner.
This commit is contained in:
@@ -8162,7 +8162,7 @@ sub check_repl_table {
|
|||||||
$sql = "CREATE DATABASE IF NOT EXISTS "
|
$sql = "CREATE DATABASE IF NOT EXISTS "
|
||||||
. $q->quote($db)
|
. $q->quote($db)
|
||||||
. " /* pt-table-checksum */";
|
. " /* pt-table-checksum */";
|
||||||
local $@;
|
# local $@;
|
||||||
PTDEBUG && _d($sql);
|
PTDEBUG && _d($sql);
|
||||||
eval {
|
eval {
|
||||||
$dbh->do($sql);
|
$dbh->do($sql);
|
||||||
|
@@ -150,32 +150,36 @@ sub output {
|
|||||||
my ($file, $stderr, $die, $trf) = @args{qw(file stderr die trf)};
|
my ($file, $stderr, $die, $trf) = @args{qw(file stderr die trf)};
|
||||||
|
|
||||||
my $output = '';
|
my $output = '';
|
||||||
if ( $file ) {
|
{
|
||||||
open *output_fh, '>', $file
|
if ( $file ) {
|
||||||
or die "Cannot open file $file: $OS_ERROR";
|
open *output_fh, '>', $file
|
||||||
}
|
or die "Cannot open file $file: $OS_ERROR";
|
||||||
else {
|
}
|
||||||
open *output_fh, '>', \$output
|
else {
|
||||||
or die "Cannot capture output to variable: $OS_ERROR";
|
open *output_fh, '>', \$output
|
||||||
}
|
or die "Cannot capture output to variable: $OS_ERROR";
|
||||||
local *STDOUT = *output_fh;
|
}
|
||||||
|
local *STDOUT = *output_fh;
|
||||||
|
|
||||||
# If capturing STDERR we must dynamically scope (local) STDERR
|
# If capturing STDERR we must dynamically scope (local) STDERR
|
||||||
# in the outer scope of the sub. If we did,
|
# in the outer scope of the sub. If we did,
|
||||||
# if ( $args{stderr} ) { local *STDERR; ... }
|
# if ( $args{stderr} ) { local *STDERR; ... }
|
||||||
# then STDERR would revert to its original value outside the if
|
# then STDERR would revert to its original value outside the if
|
||||||
# block.
|
# block.
|
||||||
local *STDERR if $args{stderr}; # do in outer scope of this sub
|
local *STDERR if $args{stderr}; # do in outer scope of this sub
|
||||||
*STDERR = *STDOUT if $args{stderr};
|
*STDERR = *STDOUT if $args{stderr};
|
||||||
|
|
||||||
eval { $code->() };
|
eval { $code->() };
|
||||||
close *output_fh;
|
if ( $EVAL_ERROR ) {
|
||||||
if ( $EVAL_ERROR ) {
|
die $EVAL_ERROR if $die;
|
||||||
die $EVAL_ERROR if $die;
|
warn $EVAL_ERROR;
|
||||||
warn $EVAL_ERROR unless $args{stderr};
|
}
|
||||||
return $EVAL_ERROR;
|
|
||||||
|
close *output_fh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
select STDOUT;
|
||||||
|
|
||||||
# Possible transform output before returning it. This doesn't work
|
# Possible transform output before returning it. This doesn't work
|
||||||
# if output was captured to a file.
|
# if output was captured to a file.
|
||||||
$output = $trf->($output) if $trf;
|
$output = $trf->($output) if $trf;
|
||||||
|
@@ -8,7 +8,7 @@ BASEDIR="PERCONA_TOOLKIT_SANDBOX"
|
|||||||
|
|
||||||
sandbox_is_alive() {
|
sandbox_is_alive() {
|
||||||
# First, all these files must exist.
|
# First, all these files must exist.
|
||||||
[ -f $PIDFILE -a -S $SOCKETFILE -a -s "/tmp/PORT/data/ibdata1" ] || return 1
|
[ -f $PIDFILE -a -S $SOCKETFILE ] || return 1
|
||||||
|
|
||||||
# And that PID file must have a PID.
|
# And that PID file must have a PID.
|
||||||
local pid=$(cat /tmp/PORT/data/mysql_sandboxPORT.pid 2>/dev/null)
|
local pid=$(cat /tmp/PORT/data/mysql_sandboxPORT.pid 2>/dev/null)
|
||||||
|
@@ -8,7 +8,7 @@ BASEDIR="PERCONA_TOOLKIT_SANDBOX"
|
|||||||
|
|
||||||
sandbox_is_alive() {
|
sandbox_is_alive() {
|
||||||
# First, all these files must exist.
|
# First, all these files must exist.
|
||||||
[ -f $PIDFILE -a -S $SOCKETFILE -a -s "/tmp/PORT/data/ibdata1" ] || return 1
|
[ -f $PIDFILE -a -S $SOCKETFILE ] || return 1
|
||||||
|
|
||||||
# And that PID file must have a PID.
|
# And that PID file must have a PID.
|
||||||
local pid=$(cat /tmp/PORT/data/mysql_sandboxPORT.pid 2>/dev/null)
|
local pid=$(cat /tmp/PORT/data/mysql_sandboxPORT.pid 2>/dev/null)
|
||||||
|
@@ -110,18 +110,18 @@ ok(
|
|||||||
$row = $master_dbh->selectrow_arrayref("select count(*) from percona.checksums");
|
$row = $master_dbh->selectrow_arrayref("select count(*) from percona.checksums");
|
||||||
is(
|
is(
|
||||||
$row->[0],
|
$row->[0],
|
||||||
( $sandbox_version gt "5.1" ? 89
|
( $sandbox_version gt "5.1" ? 90
|
||||||
: $sandbox_version gt "5.0" ? 88
|
: $sandbox_version gt "5.0" ? 89
|
||||||
: 84),
|
: 85),
|
||||||
'Expected checksums on master'
|
'Expected checksums on master'
|
||||||
);
|
);
|
||||||
|
|
||||||
$row = $slave1_dbh->selectrow_arrayref("select count(*) from percona.checksums");
|
$row = $slave1_dbh->selectrow_arrayref("select count(*) from percona.checksums");
|
||||||
is(
|
is(
|
||||||
$row->[0],
|
$row->[0],
|
||||||
( $sandbox_version gt "5.1" ? 89
|
( $sandbox_version gt "5.1" ? 90
|
||||||
: $sandbox_version gt "5.0" ? 88
|
: $sandbox_version gt "5.0" ? 89
|
||||||
: 84),
|
: 85),
|
||||||
'Expected checksums on slave'
|
'Expected checksums on slave'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -56,47 +56,45 @@ my $sample = "t/pt-table-checksum/samples/";
|
|||||||
# https://bugs.launchpad.net/percona-toolkit/+bug/950294
|
# https://bugs.launchpad.net/percona-toolkit/+bug/950294
|
||||||
# ############################################################################
|
# ############################################################################
|
||||||
|
|
||||||
$sb->wipe_clean($master_dbh);
|
$master_dbh->do("DROP DATABASE IF EXISTS percona");
|
||||||
diag(`/tmp/12345/use -u root < $trunk/t/lib/samples/ro-checksum-user.sql 2>/dev/null`);
|
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'");
|
PerconaTest::wait_for_table($slave2_dbh, "mysql.user", "user='ro_checksum_user'");
|
||||||
|
|
||||||
($output, $exit_status) = full_output(
|
$output = output(
|
||||||
sub { pt_table_checksum::main(@args,
|
sub { $exit_status = pt_table_checksum::main(@args,
|
||||||
"$master_dsn,u=ro_checksum_user,p=msandbox",
|
"$master_dsn,u=ro_checksum_user,p=msandbox",
|
||||||
qw(--recursion-method none)
|
qw(--recursion-method none)
|
||||||
) },
|
) },
|
||||||
|
stderr => 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
ok(
|
like(
|
||||||
$exit_status,
|
$output,
|
||||||
"Dies with an error status if it can't create the db/table"
|
qr/\Qdatabase percona does not exist and it cannot be created automatically/,
|
||||||
|
"Error if percona db doesn't exist and user can't create it",
|
||||||
);
|
);
|
||||||
|
|
||||||
like($output,
|
$output = 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,
|
sub { pt_table_checksum::main(@args,
|
||||||
"$master_dsn,u=ro_checksum_user,p=msandbox",
|
"$master_dsn,u=ro_checksum_user,p=msandbox",
|
||||||
qw(--recursion-method none --no-create-replicate-table)
|
qw(--recursion-method none --no-create-replicate-table)
|
||||||
) },
|
) },
|
||||||
|
stderr => 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
like($output,
|
like(
|
||||||
qr/\Q--replicate database percona does not exist and --no-create-replicate-table was/,
|
$output,
|
||||||
"fails if the percona db doesn't exist and --no-create-replicate-table",
|
qr/\Qdatabase percona does not exist and --no-create-replicate-table was/,
|
||||||
|
"Error if percona db doesn't exist and --no-create-replicate-table",
|
||||||
);
|
);
|
||||||
|
|
||||||
diag(`/tmp/12345/use -u root -e "drop user 'ro_checksum_user'\@'%'"`);
|
diag(`/tmp/12345/use -u root -e "drop user 'ro_checksum_user'\@'%'"`);
|
||||||
wait_until(
|
wait_until(
|
||||||
sub {
|
sub {
|
||||||
my $rows=$slave2_dbh->selectall_arrayref("SELECT user FROM mysql.user");
|
my $rows=$slave2_dbh->selectall_arrayref("SELECT user FROM mysql.user");
|
||||||
return !grep { ($_->[0] || '') ne 'ro_checksum_user' } @$rows;
|
return !grep { ($_->[0] || '') eq 'ro_checksum_user' } @$rows;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
$sb->wipe_clean($master_dbh);
|
|
||||||
|
|
||||||
# ############################################################################
|
# ############################################################################
|
||||||
# --recursion-method=none to avoid SHOW SLAVE HOSTS
|
# --recursion-method=none to avoid SHOW SLAVE HOSTS
|
||||||
@@ -143,7 +141,7 @@ like(
|
|||||||
|
|
||||||
like($output,
|
like($output,
|
||||||
qr/\QThe database exists on the master, but replication will break/,
|
qr/\QThe database exists on the master, but replication will break/,
|
||||||
"dies if the db exists on the master but it can't CREATE DATABASE and --no-create-replicate-table was not specified",
|
"Error if db exists on the master, can't CREATE DATABASE, and --no-create-replicate-table was not specified",
|
||||||
);
|
);
|
||||||
|
|
||||||
diag(qx{/tmp/12345/use -u root -e 'DROP TABLE `percona`.`checksums`'});
|
diag(qx{/tmp/12345/use -u root -e 'DROP TABLE `percona`.`checksums`'});
|
||||||
@@ -157,7 +155,7 @@ diag(qx{/tmp/12345/use -u root -e 'DROP TABLE `percona`.`checksums`'});
|
|||||||
|
|
||||||
like($output,
|
like($output,
|
||||||
qr/\Q--replicate table `percona`.`checksums` does not exist and --no/,
|
qr/\Q--replicate table `percona`.`checksums` does not exist and --no/,
|
||||||
"fails if the checksums db doesn't exist and --no-create-replicate-table"
|
"Error if checksums db doesn't exist and --no-create-replicate-table"
|
||||||
);
|
);
|
||||||
|
|
||||||
diag(`/tmp/12345/use -u root -e "drop user 'ro_checksum_user'\@'%'"`);
|
diag(`/tmp/12345/use -u root -e "drop user 'ro_checksum_user'\@'%'"`);
|
||||||
@@ -171,7 +169,7 @@ wait_until(
|
|||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Bug 916168: bug in pt-table-checksum privileges check
|
# Bug 916168: bug in pt-table-checksum privileges check
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
`/tmp/12345/use -u root < $trunk/t/pt-table-checksum/samples/privs-bug-916168.sql`;
|
diag(`/tmp/12345/use -u root < $trunk/t/pt-table-checksum/samples/privs-bug-916168.sql`);
|
||||||
|
|
||||||
$output = output(
|
$output = output(
|
||||||
sub { $exit_status = pt_table_checksum::main(@args,
|
sub { $exit_status = pt_table_checksum::main(@args,
|
||||||
@@ -197,5 +195,5 @@ wait_until(
|
|||||||
# #############################################################################
|
# #############################################################################
|
||||||
$sb->wipe_clean($master_dbh);
|
$sb->wipe_clean($master_dbh);
|
||||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
exit;
|
||||||
|
@@ -17,6 +17,7 @@ ERRORS DIFFS ROWS SKIPPED TABLE
|
|||||||
0 0 0 0 mysql.time_zone_transition_type
|
0 0 0 0 mysql.time_zone_transition_type
|
||||||
0 0 2 0 mysql.user
|
0 0 2 0 mysql.user
|
||||||
0 0 33 0 percona_test.checksums
|
0 0 33 0 percona_test.checksums
|
||||||
|
0 0 1 0 percona_test.load_data
|
||||||
0 0 1 0 percona_test.sentinel
|
0 0 1 0 percona_test.sentinel
|
||||||
0 0 200 0 sakila.actor
|
0 0 200 0 sakila.actor
|
||||||
0 0 603 0 sakila.address
|
0 0 603 0 sakila.address
|
||||||
|
@@ -21,6 +21,7 @@ ERRORS DIFFS ROWS SKIPPED TABLE
|
|||||||
0 0 0 0 mysql.time_zone_transition_type
|
0 0 0 0 mysql.time_zone_transition_type
|
||||||
0 0 2 0 mysql.user
|
0 0 2 0 mysql.user
|
||||||
0 0 39 0 percona_test.checksums
|
0 0 39 0 percona_test.checksums
|
||||||
|
0 0 1 0 percona_test.load_data
|
||||||
0 0 1 0 percona_test.sentinel
|
0 0 1 0 percona_test.sentinel
|
||||||
0 0 200 0 sakila.actor
|
0 0 200 0 sakila.actor
|
||||||
0 0 603 0 sakila.address
|
0 0 603 0 sakila.address
|
||||||
|
@@ -22,6 +22,7 @@ ERRORS DIFFS ROWS SKIPPED TABLE
|
|||||||
0 0 0 0 mysql.time_zone_transition_type
|
0 0 0 0 mysql.time_zone_transition_type
|
||||||
0 0 2 0 mysql.user
|
0 0 2 0 mysql.user
|
||||||
0 0 40 0 percona_test.checksums
|
0 0 40 0 percona_test.checksums
|
||||||
|
0 0 1 0 percona_test.load_data
|
||||||
0 0 1 0 percona_test.sentinel
|
0 0 1 0 percona_test.sentinel
|
||||||
0 0 200 0 sakila.actor
|
0 0 200 0 sakila.actor
|
||||||
0 0 603 0 sakila.address
|
0 0 603 0 sakila.address
|
||||||
|
@@ -17,6 +17,7 @@ ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
|
|||||||
0 0 0 1 0 mysql.time_zone_transition_type
|
0 0 0 1 0 mysql.time_zone_transition_type
|
||||||
0 0 2 1 0 mysql.user
|
0 0 2 1 0 mysql.user
|
||||||
0 0 33 1 0 percona_test.checksums
|
0 0 33 1 0 percona_test.checksums
|
||||||
|
0 0 1 1 0 percona_test.load_data
|
||||||
0 0 1 1 0 percona_test.sentinel
|
0 0 1 1 0 percona_test.sentinel
|
||||||
0 0 200 1 0 sakila.actor
|
0 0 200 1 0 sakila.actor
|
||||||
0 0 603 1 0 sakila.address
|
0 0 603 1 0 sakila.address
|
||||||
|
@@ -21,6 +21,7 @@ ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
|
|||||||
0 0 0 1 0 mysql.time_zone_transition_type
|
0 0 0 1 0 mysql.time_zone_transition_type
|
||||||
0 0 2 1 0 mysql.user
|
0 0 2 1 0 mysql.user
|
||||||
0 0 39 1 0 percona_test.checksums
|
0 0 39 1 0 percona_test.checksums
|
||||||
|
0 0 1 1 0 percona_test.load_data
|
||||||
0 0 1 1 0 percona_test.sentinel
|
0 0 1 1 0 percona_test.sentinel
|
||||||
0 0 200 1 0 sakila.actor
|
0 0 200 1 0 sakila.actor
|
||||||
0 0 603 1 0 sakila.address
|
0 0 603 1 0 sakila.address
|
||||||
|
@@ -22,6 +22,7 @@ ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
|
|||||||
0 0 0 1 0 mysql.time_zone_transition_type
|
0 0 0 1 0 mysql.time_zone_transition_type
|
||||||
0 0 2 1 0 mysql.user
|
0 0 2 1 0 mysql.user
|
||||||
0 0 40 1 0 percona_test.checksums
|
0 0 40 1 0 percona_test.checksums
|
||||||
|
0 0 1 1 0 percona_test.load_data
|
||||||
0 0 1 1 0 percona_test.sentinel
|
0 0 1 1 0 percona_test.sentinel
|
||||||
0 0 200 1 0 sakila.actor
|
0 0 200 1 0 sakila.actor
|
||||||
0 0 603 1 0 sakila.address
|
0 0 603 1 0 sakila.address
|
||||||
|
Reference in New Issue
Block a user