mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-09 18:30:16 +00:00
PT-2340 - Support MySQL 8.4
- Removed runtime.txt after discussion with Anastasia Alexandrova - Added "use VersionParser" into tests in t/lib when needed - Removed word master from tests for pt-archiver, pt-config-diff, pt-deadlock-logger, pt-duplicate-key-checker, pt-find, pt-fk-error-logger, pt-heartbeat, pt-index-usage, pt-ioprofile, pt-kill, pt-mysql-summary - Removed word slave from tests for pt-archiver, pt-config-diff, pt-deadlock-logger, pt-duplicate-key-checker, pt-find, pt-fk-error-logger, pt-heartbeat, pt-index-usage, pt-ioprofile, pt-kill, pt-mysql-summary - Updated modules for pt-archiver, pt-config-diff, pt-deadlock-logger, pt-duplicate-key-checker, pt-find, pt-fk-error-logger, pt-heartbeat, pt-index-usage, pt-ioprofile, pt-kill, pt-mysql-summary - Changed mysql_ssl patch, so it is now short option s - Added a check for existing zombies in t/pt-kill/execute_command.t - Added bin/pt-galera-log-explainer to .gitignore
This commit is contained in:
@@ -10,6 +10,7 @@ use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More;
|
||||
use Data::Dumper;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
@@ -17,36 +18,36 @@ require "$trunk/bin/pt-heartbeat";
|
||||
|
||||
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';
|
||||
}
|
||||
else {
|
||||
plan tests => 29;
|
||||
}
|
||||
|
||||
diag(`rm -rf /tmp/pt-heartbeat-sentinel >/dev/null 2>&1`);
|
||||
$sb->create_dbs($master_dbh, ['test']);
|
||||
$sb->wait_for_slaves();
|
||||
$sb->create_dbs($source_dbh, ['test']);
|
||||
$sb->wait_for_replicas();
|
||||
|
||||
my $output;
|
||||
my $pid_file = "/tmp/pt-heartbeat-test.$PID.pid";
|
||||
|
||||
# Multi-update mode is the new, hi-res mode that allows a single table to
|
||||
# be updated by multiple servers: a slave's master, its master's master, etc.
|
||||
# be updated by multiple servers: a replica's source, its source's source, etc.
|
||||
#
|
||||
# We have master -> slave1 -> slave2 where master has server_id=12345,
|
||||
# slave1 server_id=12346, and slave2 server_id=12347. The heartbeat table
|
||||
# on slave2 can have 3 heartbeat rows: one from the master, one from slave1
|
||||
# We have source -> replica1 -> replica2 where source has server_id=12345,
|
||||
# replica1 server_id=12346, and replica2 server_id=12347. The heartbeat table
|
||||
# on replica2 can have 3 heartbeat rows: one from the source, one from replica1
|
||||
# and one for itself.
|
||||
my @ports = qw(12345 12346 12347);
|
||||
|
||||
@@ -60,167 +61,167 @@ foreach my $port (@ports) {
|
||||
);
|
||||
}
|
||||
sleep 5;
|
||||
# Check heartbeat on master.
|
||||
my $rows = $master_dbh->selectall_hashref("select * from test.heartbeat", 'server_id');
|
||||
# Check heartbeat on source.
|
||||
my $rows = $source_dbh->selectall_hashref("select * from test.heartbeat", 'server_id');
|
||||
|
||||
is(
|
||||
scalar keys %$rows,
|
||||
1,
|
||||
"One heartbeat row on master"
|
||||
"One heartbeat row on source"
|
||||
);
|
||||
|
||||
ok(
|
||||
exists $rows->{12345},
|
||||
"Master heartbeat"
|
||||
"Source heartbeat"
|
||||
);
|
||||
|
||||
ok(
|
||||
defined $rows->{12345}->{file} && defined $rows->{12345}->{position},
|
||||
"Master file and position"
|
||||
"Source file and position"
|
||||
);
|
||||
|
||||
ok(
|
||||
!$rows->{12345}->{relay_master_log_file} && !$rows->{12345}->{exec_master_log_pos},
|
||||
"No relay_master_log_file or exec_master_log_pos for master"
|
||||
!$rows->{12345}->{"relay_${source_name}_log_file"} && !$rows->{12345}->{"exec_${source_name}_log_pos"},
|
||||
"No relay_source_log_file or exec_source_log_pos for source"
|
||||
);
|
||||
|
||||
# Check heartbeat on slave1.
|
||||
$rows = $slave1_dbh->selectall_hashref("select * from test.heartbeat", 'server_id');
|
||||
# Check heartbeat on replica1.
|
||||
$rows = $replica1_dbh->selectall_hashref("select * from test.heartbeat", 'server_id');
|
||||
|
||||
is(
|
||||
scalar keys %$rows,
|
||||
2,
|
||||
"Two heartbeat rows on slave1"
|
||||
"Two heartbeat rows on replica1"
|
||||
);
|
||||
|
||||
ok(
|
||||
exists $rows->{12345},
|
||||
"Slave1 has master heartbeat",
|
||||
"Replica1 has source heartbeat",
|
||||
);
|
||||
|
||||
ok(
|
||||
exists $rows->{12346},
|
||||
"Slave1 heartbeat"
|
||||
"Replica1 heartbeat"
|
||||
);
|
||||
|
||||
ok(
|
||||
defined $rows->{12346}->{file} && defined $rows->{12346}->{position},
|
||||
"Slave1 master file and position"
|
||||
"Replica1 source file and position"
|
||||
);
|
||||
|
||||
ok(
|
||||
$rows->{12346}->{relay_master_log_file} && $rows->{12346}->{exec_master_log_pos},
|
||||
"Slave1 relay_master_log_file and exec_master_log_pos for master"
|
||||
);
|
||||
$rows->{12346}->{"relay_${source_name}_log_file"} && $rows->{12346}->{"exec_${source_name}_log_pos"},
|
||||
"Replica1 relay_source_log_file and exec_source_log_pos for source"
|
||||
) or diag(Dumper($rows));
|
||||
|
||||
# Check heartbeat on slave2.
|
||||
$rows = $slave2_dbh->selectall_hashref("select * from test.heartbeat", 'server_id');
|
||||
# Check heartbeat on replica2.
|
||||
$rows = $replica2_dbh->selectall_hashref("select * from test.heartbeat", 'server_id');
|
||||
|
||||
is(
|
||||
scalar keys %$rows,
|
||||
3,
|
||||
"Three heartbeat rows on slave2"
|
||||
"Three heartbeat rows on replica2"
|
||||
);
|
||||
|
||||
ok(
|
||||
exists $rows->{12345},
|
||||
"Slave2 has master heartbeat",
|
||||
"Replica2 has source heartbeat",
|
||||
);
|
||||
|
||||
ok(
|
||||
exists $rows->{12346},
|
||||
"Slave2 has slave1 heartbeat",
|
||||
"Replica2 has replica1 heartbeat",
|
||||
);
|
||||
|
||||
ok(
|
||||
exists $rows->{12347},
|
||||
"Slave1 heartbeat"
|
||||
"Replica1 heartbeat"
|
||||
);
|
||||
|
||||
ok(
|
||||
defined $rows->{12347}->{file} && defined $rows->{12347}->{position},
|
||||
"Slave2 master file and position"
|
||||
"Replica2 source file and position"
|
||||
);
|
||||
|
||||
ok(
|
||||
$rows->{12347}->{relay_master_log_file} && $rows->{12347}->{exec_master_log_pos},
|
||||
"Slave2 relay_master_log_file and exec_master_log_pos for master"
|
||||
$rows->{12347}->{"relay_${source_name}_log_file"} && $rows->{12347}->{"exec_${source_name}_log_pos"},
|
||||
"Replica2 relay_source_log_file and exec_source_log_pos for source"
|
||||
);
|
||||
|
||||
# ############################################################################
|
||||
# Verify that the master heartbeat is changing and replicating.
|
||||
# Verify that the source heartbeat is changing and replicating.
|
||||
# ############################################################################
|
||||
|
||||
# $rows already has slave2 heartbeat info.
|
||||
# $rows already has replica2 heartbeat info.
|
||||
sleep 4;
|
||||
|
||||
my $rows2 = $slave2_dbh->selectall_hashref("select * from test.heartbeat", 'server_id');
|
||||
my $rows2 = $replica2_dbh->selectall_hashref("select * from test.heartbeat", 'server_id');
|
||||
|
||||
cmp_ok(
|
||||
$rows2->{12345}->{ts},
|
||||
'gt',
|
||||
$rows->{12345}->{ts},
|
||||
"Master heartbeat ts is changing and replicating"
|
||||
"Source heartbeat ts is changing and replicating"
|
||||
);
|
||||
|
||||
cmp_ok(
|
||||
$rows2->{12345}->{position},
|
||||
'>',
|
||||
$rows->{12345}->{position},
|
||||
"Master binlog position is changing and replicating"
|
||||
"Source binlog position is changing and replicating"
|
||||
);
|
||||
|
||||
# But the master binlog file shouldn't change.
|
||||
# But the source binlog file shouldn't change.
|
||||
is(
|
||||
$rows->{12345}->{file},
|
||||
$rows2->{12345}->{file},
|
||||
"Master binlog file is not changing"
|
||||
"Source binlog file is not changing"
|
||||
);
|
||||
|
||||
|
||||
# ############################################################################
|
||||
# Test --master-server-id.
|
||||
# Test --source-server-id.
|
||||
# ############################################################################
|
||||
|
||||
# First, the option should be optional. If not given, the server's
|
||||
# immediate master should be used.
|
||||
# immediate source should be used.
|
||||
$output = output(
|
||||
sub { pt_heartbeat::main(qw(-h 127.1 -P 12347 -u msandbox -p msandbox),
|
||||
qw(-D test --check --print-master-server-id)) },
|
||||
qw(-D test --check --print-source-server-id)) },
|
||||
);
|
||||
|
||||
like(
|
||||
$output,
|
||||
qr/0\.\d\d\s+12346\n/,
|
||||
"--check 12347, automatic master server_id"
|
||||
);
|
||||
"--check 12347, automatic source server_id"
|
||||
) or diag($output);
|
||||
|
||||
$output = output(
|
||||
sub { pt_heartbeat::main(qw(-h 127.1 -P 12347 -u msandbox -p msandbox),
|
||||
qw(-D test --check --print-master-server-id --master-server-id 12346)) },
|
||||
qw(-D test --check --print-source-server-id --source-server-id 12346)) },
|
||||
);
|
||||
|
||||
like(
|
||||
$output,
|
||||
qr/0\.\d\d\s+12346\n/,
|
||||
"--check 12347 from --master-server-id 12346"
|
||||
"--check 12347 from --source-server-id 12346"
|
||||
);
|
||||
|
||||
$output = output(
|
||||
sub { pt_heartbeat::main(qw(-h 127.1 -P 12347 -u msandbox -p msandbox),
|
||||
qw(-D test --check --print-master-server-id --master-server-id 12345)) },
|
||||
qw(-D test --check --print-source-server-id --source-server-id 12345)) },
|
||||
);
|
||||
|
||||
sleep 3;
|
||||
like(
|
||||
$output,
|
||||
qr/0\.\d\d\s+12345\n/,
|
||||
"--check 12347 from --master-server-id 12345"
|
||||
"--check 12347 from --source-server-id 12345"
|
||||
);
|
||||
|
||||
$output = output(
|
||||
sub { pt_heartbeat::main(qw(-h 127.1 -P 12347 -u msandbox -p msandbox),
|
||||
qw(-D test --check --print-master-server-id --master-server-id 42),
|
||||
qw(-D test --check --print-source-server-id --source-server-id 42),
|
||||
qw(--no-insert-heartbeat-row)) },
|
||||
stderr => 1,
|
||||
);
|
||||
@@ -228,7 +229,7 @@ $output = output(
|
||||
like(
|
||||
$output,
|
||||
qr/No row found in heartbeat table for server_id 42/,
|
||||
"Error if --master-server-id row doesn't exist"
|
||||
"Error if --source-server-id row doesn't exist"
|
||||
);
|
||||
|
||||
# ############################################################################
|
||||
@@ -248,6 +249,6 @@ foreach my $port (@ports) {
|
||||
# Done.
|
||||
# #############################################################################
|
||||
diag(`rm -rf /tmp/pt-heartbeat-sentinel >/dev/null`);
|
||||
$sb->wipe_clean($master_dbh);
|
||||
$sb->wipe_clean($source_dbh);
|
||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||
exit;
|
||||
|
Reference in New Issue
Block a user