mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-26 05:58:16 +00:00
PT-2340 - Support MySQL 8.4
- Updated modules and tests for pt-query-digest, pt-show-grants, pt-slave-delay, pt-slave-find, pt-slave-restart, pt-stalk, pt-summary, pt-table-checksum
This commit is contained in:
@@ -12,8 +12,8 @@ use English qw(-no_match_vars);
|
||||
use Test::More;
|
||||
|
||||
# Hostnames make testing less accurate. Tests need to see
|
||||
# that such-and-such happened on specific slave hosts, but
|
||||
# the sandbox servers are all on one host so all slaves have
|
||||
# that such-and-such happened on specific replica hosts, but
|
||||
# the sandbox servers are all on one host so all replicas have
|
||||
# the same hostname.
|
||||
$ENV{PERCONA_TOOLKIT_TEST_USE_DSN_NAMES} = 1;
|
||||
|
||||
@@ -25,24 +25,24 @@ require "$trunk/bin/pt-table-checksum";
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||
my $master_dbh = $sb->get_dbh_for('master');
|
||||
my $slave1_dbh = $sb->get_dbh_for('slave1');
|
||||
my $slave2_dbh = $sb->get_dbh_for('slave2');
|
||||
my $source_dbh = $sb->get_dbh_for('source');
|
||||
my $replica1_dbh = $sb->get_dbh_for('replica1');
|
||||
my $replica2_dbh = $sb->get_dbh_for('replica2');
|
||||
|
||||
if ( !$master_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox master';
|
||||
if ( !$source_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox source';
|
||||
}
|
||||
elsif ( !$slave1_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox slave1';
|
||||
elsif ( !$replica1_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox replica1';
|
||||
}
|
||||
elsif ( !$slave2_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox slave2';
|
||||
elsif ( !$replica2_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox replica2';
|
||||
}
|
||||
|
||||
# The sandbox servers run with lock_wait_timeout=3 and it's not dynamic
|
||||
# so we need to specify --set-vars innodb_lock_wait_timeout=3 else the tool will die.
|
||||
my $master_dsn = 'h=127.1,P=12345,u=msandbox,p=msandbox';
|
||||
my @args = ($master_dsn, qw(--set-vars innodb_lock_wait_timeout=3));
|
||||
my $source_dsn = 'h=127.1,P=12345,u=msandbox,p=msandbox,s=1';
|
||||
my @args = ($source_dsn, qw(--set-vars innodb_lock_wait_timeout=3));
|
||||
my $output;
|
||||
my $exit_status;
|
||||
my $sample = "t/pt-table-checksum/samples/";
|
||||
@@ -52,7 +52,7 @@ my $sample = "t/pt-table-checksum/samples/";
|
||||
# Can't use an undefined value as an ARRAY reference at pt-table-checksum
|
||||
# line 2206
|
||||
# ############################################################################
|
||||
$sb->load_file('master', "$sample/undef-arrayref-bug-995274.sql");
|
||||
$sb->load_file('source', "$sample/undef-arrayref-bug-995274.sql");
|
||||
|
||||
# Must chunk the table so an index is used.
|
||||
$output = output(
|
||||
@@ -79,8 +79,8 @@ cmp_ok(
|
||||
# https://bugs.launchpad.net/percona-toolkit/+bug/987393
|
||||
# Empy tables cause "undefined value as an ARRAY" errors
|
||||
# #############################################################################
|
||||
$master_dbh->do("DROP DATABASE IF EXISTS percona"); # clear old checksums
|
||||
$sb->load_file('master', "$sample/empty-table-bug-987393.sql");
|
||||
$source_dbh->do("DROP DATABASE IF EXISTS percona"); # clear old checksums
|
||||
$sb->load_file('source', "$sample/empty-table-bug-987393.sql");
|
||||
|
||||
$output = output(
|
||||
sub { $exit_status = pt_table_checksum::main(
|
||||
@@ -100,7 +100,7 @@ is(
|
||||
"Bug 987393 (empty table): no errors"
|
||||
);
|
||||
|
||||
my $rows = $master_dbh->selectall_arrayref("SELECT db, tbl, chunk, master_crc, master_cnt FROM percona.checksums ORDER BY db, tbl, chunk");
|
||||
my $rows = $source_dbh->selectall_arrayref("SELECT db, tbl, chunk, ${source_name}_crc, ${source_name}_cnt FROM percona.checksums ORDER BY db, tbl, chunk");
|
||||
is_deeply(
|
||||
$rows,
|
||||
[
|
||||
@@ -116,7 +116,7 @@ is_deeply(
|
||||
# #############################################################################
|
||||
$output = output(
|
||||
sub {
|
||||
print `$trunk/bin/pt-table-checksum $master_dsn -t sakila.country 2>&1`;
|
||||
print `$trunk/bin/pt-table-checksum $source_dsn -t sakila.country 2>&1`;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -136,16 +136,16 @@ is(
|
||||
# https://bugs.launchpad.net/percona-toolkit/+bug/1030031
|
||||
# pt-table-checksum reports wrong number of DIFFS
|
||||
# #############################################################################
|
||||
$sb->load_file('master', "$sample/a-z.sql");
|
||||
$sb->wait_for_slaves();
|
||||
$sb->load_file('source', "$sample/a-z.sql");
|
||||
$sb->wait_for_replicas();
|
||||
|
||||
# Create 2 diffs on slave1 and 1 diff on slave2.
|
||||
$slave1_dbh->do("UPDATE test.t SET c='' WHERE id=5"); # diff on slave1 & 2
|
||||
$slave1_dbh->do("SET SQL_LOG_BIN=0");
|
||||
$slave1_dbh->do("UPDATE test.t SET c='' WHERE id=20"); # diff only on slave1
|
||||
# Create 2 diffs on replica1 and 1 diff on replica2.
|
||||
$replica1_dbh->do("UPDATE test.t SET c='' WHERE id=5"); # diff on replica1 & 2
|
||||
$replica1_dbh->do("SET SQL_LOG_BIN=0");
|
||||
$replica1_dbh->do("UPDATE test.t SET c='' WHERE id=20"); # diff only on replica1
|
||||
|
||||
# Restore sql_log_bin on slave1 in case later tests use it.
|
||||
$slave1_dbh->do("SET SQL_LOG_BIN=1");
|
||||
# Restore sql_log_bin on replica1 in case later tests use it.
|
||||
$replica1_dbh->do("SET SQL_LOG_BIN=1");
|
||||
|
||||
$output = output(
|
||||
sub { pt_table_checksum::main(@args, qw(-t test.t --chunk-size 10)) },
|
||||
@@ -157,10 +157,10 @@ is(
|
||||
"Bug 1030031 (wrong DIFFS): 2 diffs"
|
||||
);
|
||||
|
||||
# Restore slave2, but then give it 1 diff that's not the same chunk#
|
||||
# as slave1, so there's 3 unique chunk that differ.
|
||||
$slave2_dbh->do("UPDATE test.t SET c='e' WHERE id=5");
|
||||
$slave2_dbh->do("UPDATE test.t SET c='' WHERE id=26");
|
||||
# Restore replica2, but then give it 1 diff that's not the same chunk#
|
||||
# as replica1, so there's 3 unique chunk that differ.
|
||||
$replica2_dbh->do("UPDATE test.t SET c='e' WHERE id=5");
|
||||
$replica2_dbh->do("UPDATE test.t SET c='' WHERE id=26");
|
||||
|
||||
$output = output(
|
||||
sub { pt_table_checksum::main(@args, qw(-t test.t --chunk-size 10)) },
|
||||
@@ -210,22 +210,22 @@ like(
|
||||
{
|
||||
$output = output(
|
||||
sub { pt_table_checksum::main(@args,
|
||||
'--skip-check-slave-lag', "h=127.0.0.1,P=".$sb->port_for('slave1'),
|
||||
'--skip-check-replica-lag', "h=127.0.0.1,P=".$sb->port_for('replica1'),
|
||||
),
|
||||
},
|
||||
);
|
||||
|
||||
my $skipping_str = "Skipping.*".$sb->port_for('slave1');
|
||||
my $skipping_str = "Skipping.*".$sb->port_for('replica1');
|
||||
like(
|
||||
$output,
|
||||
qr/$skipping_str/s,
|
||||
"--skip-check-slave-lag",
|
||||
"--skip-check-replica-lag",
|
||||
);
|
||||
|
||||
# Test for skip-check-slave-lag and empty replica port
|
||||
# Test for skip-check-replica-lag and empty replica port
|
||||
$output = output(
|
||||
sub { pt_table_checksum::main(@args,
|
||||
'--skip-check-slave-lag', "h=127.0.0.1",
|
||||
'--skip-check-replica-lag', "h=127.0.0.1",
|
||||
),
|
||||
},
|
||||
stderr => 1
|
||||
@@ -234,7 +234,7 @@ $output = output(
|
||||
unlike(
|
||||
$output,
|
||||
qr/Use of uninitialized value.*/,
|
||||
'No syntax error if port is missed in --skip-check-slave-lag DSN',
|
||||
'No syntax error if port is missed in --skip-check-replica-lag DSN',
|
||||
) or diag($output);
|
||||
}
|
||||
# #############################################################################
|
||||
@@ -272,7 +272,7 @@ unlike(
|
||||
}
|
||||
|
||||
# #############################################################################
|
||||
# pt-table-checksum doesn't warn if binlog_format=row or mixed on slaves
|
||||
# pt-table-checksum doesn't warn if binlog_format=row or mixed on replicas
|
||||
# https://bugs.launchpad.net/percona-toolkit/+bug/938068
|
||||
# #############################################################################
|
||||
|
||||
@@ -281,9 +281,9 @@ SKIP: {
|
||||
unless $sandbox_version ge '5.1';
|
||||
|
||||
local $ENV{BINLOG_FORMAT} = 'ROW';
|
||||
diag(`$trunk/sandbox/start-sandbox slave 12348 12345`);
|
||||
diag(`$trunk/sandbox/start-sandbox replica 12348 12345`);
|
||||
local $ENV{BINLOG_FORMAT} = 'MIXED';
|
||||
diag(`$trunk/sandbox/start-sandbox slave 12349 12348`);
|
||||
diag(`$trunk/sandbox/start-sandbox replica 12349 12348`);
|
||||
|
||||
$output = output( sub { pt_table_checksum::main(@args) }, stderr => 1 );
|
||||
|
||||
@@ -291,13 +291,13 @@ SKIP: {
|
||||
like(
|
||||
$output,
|
||||
$re,
|
||||
"Bug 938068: doesn't warn if binlog_format=row or mixed on slaves"
|
||||
"Bug 938068: doesn't warn if binlog_format=row or mixed on replicas"
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
[ $output =~ /$re/g ],
|
||||
[ 'ROW', 'MIXED' ],
|
||||
"...and warns for both level 1 and level 2 slaves"
|
||||
"...and warns for both level 1 and level 2 replicas"
|
||||
) or diag($output);
|
||||
|
||||
diag(`$trunk/sandbox/stop-sandbox 12349 12348`);
|
||||
@@ -309,7 +309,7 @@ SKIP: {
|
||||
# #############################################################################
|
||||
|
||||
$output = output(sub {
|
||||
pt_table_checksum::main($master_dsn,
|
||||
pt_table_checksum::main($source_dsn,
|
||||
qw(--recursion-method cluster -t mysql.user)
|
||||
)},
|
||||
stderr => 1,
|
||||
@@ -326,11 +326,11 @@ like(
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# pt-table-checksum has errors when slaves have different system_time_zone
|
||||
# pt-table-checksum has errors when replicas have different system_time_zone
|
||||
# https://bugs.launchpad.net/percona-toolkit/+bug/1388870
|
||||
# #############################################################################
|
||||
|
||||
# make slave set diferent system_time_zone by changing env var TZ.
|
||||
# make replica set diferent system_time_zone by changing env var TZ.
|
||||
diag(`/tmp/12346/stop >/dev/null`);
|
||||
diag(`export TZ='HST';/tmp/12346/start >/dev/null`);
|
||||
|
||||
@@ -342,10 +342,10 @@ $output = output(
|
||||
is(
|
||||
PerconaTest::count_checksum_results($output, 'diffs'),
|
||||
0,
|
||||
"Bug 1388870 - No false positive reported when system_tz differ on slave"
|
||||
"Bug 1388870 - No false positive reported when system_tz differ on replica"
|
||||
);
|
||||
|
||||
# restore slave to original system_tz
|
||||
# restore replica to original system_tz
|
||||
diag(`/tmp/12346/stop >/dev/null`);
|
||||
diag(`/tmp/12346/start >/dev/null`);
|
||||
|
||||
@@ -354,6 +354,6 @@ diag(`/tmp/12346/start >/dev/null`);
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
$sb->wipe_clean($master_dbh);
|
||||
$sb->wipe_clean($source_dbh);
|
||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||
done_testing;
|
||||
|
Reference in New Issue
Block a user