From a7ffe2e032d5c624254d94e8bccb77d9787874dc Mon Sep 17 00:00:00 2001 From: Carlos Salguero Date: Thu, 13 Apr 2017 11:41:08 -0300 Subject: [PATCH] Fixed tests for pt-stalk --- sandbox/start-sandbox | 2 - t/pt-stalk/pt-stalk.t | 95 ++++++++++++++++++++++++++----------------- 2 files changed, 58 insertions(+), 39 deletions(-) diff --git a/sandbox/start-sandbox b/sandbox/start-sandbox index e1018acf..7246df8f 100755 --- a/sandbox/start-sandbox +++ b/sandbox/start-sandbox @@ -246,7 +246,6 @@ else fi APP="${FORK:-"mysql"}" -echo "APP $APP" > /home/karl/k if [ $type = "cluster" -o $APP = "pxc" ]; then # disabled for now because used perl module is not available everywhere and in some distros it returns ipv6 address @@ -256,7 +255,6 @@ if [ $type = "cluster" -o $APP = "pxc" ]; then else version=`$PERCONA_TOOLKIT_SANDBOX/$mysqld -V 2>/dev/null | awk '{print $3}' | cut -d. -f 1,2`; fi -echo "version $version" >> /home/karl/k if [ ! -d "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version" ]; then die "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version does not exist." diff --git a/t/pt-stalk/pt-stalk.t b/t/pt-stalk/pt-stalk.t index 846f5385..08b333e2 100644 --- a/t/pt-stalk/pt-stalk.t +++ b/t/pt-stalk/pt-stalk.t @@ -465,52 +465,73 @@ SKIP: { qr/ STATE: COMMITTED/, "MySQL 5.7 COMMITTED transactions" ); + + cleanup(); } -cleanup(); +SKIP: { -my ($master1_dbh, $master1_dsn) = $sb->start_sandbox( - server => 'chan_master1', - type => 'master', -); -my ($master2_dbh, $master2_dsn) = $sb->start_sandbox( - server => 'chan_master2', - type => 'master', -); -my ($slave1_dbh, $slave1_dsn) = $sb->start_sandbox( - server => 'chan_slave1', - type => 'master', -); -my $slave1_port = $sb->port_for('chan_slave1'); + skip "Only test on mysql 5.7" if ( $sandbox_version lt '5.7' ); -$sb->load_file('chan_master1', "sandbox/gtid_on.sql", undef, no_wait => 1); -$sb->load_file('chan_master2', "sandbox/gtid_on.sql", undef, no_wait => 1); -$sb->load_file('chan_slave1', "sandbox/slave_channels.sql", undef, no_wait => 1); + my ($master1_dbh, $master1_dsn) = $sb->start_sandbox( + server => 'chan_master1', + type => 'master', + ); + my ($master2_dbh, $master2_dsn) = $sb->start_sandbox( + server => 'chan_master2', + type => 'master', + ); + my ($slave1_dbh, $slave1_dsn) = $sb->start_sandbox( + server => 'chan_slave1', + type => 'master', + ); + my $slave1_port = $sb->port_for('chan_slave1'); + + $sb->load_file('chan_master1', "sandbox/gtid_on.sql", undef, no_wait => 1); + $sb->load_file('chan_master2', "sandbox/gtid_on.sql", undef, no_wait => 1); + $sb->load_file('chan_slave1', "sandbox/slave_channels.sql", undef, no_wait => 1); + my $cmd = "$trunk/bin/pt-stalk --no-stalk --iterations=1 --host=127.0.0.1 --port=$slave1_port --user=msandbox " + . "--password=msandbox --sleep 0 --run-time=10 --dest $dest --log $log_file --iterations=1 " + . "--run-time=2 --pid $pid_file --defaults-file=$cnf >$log_file 2>&1"; + system($cmd); + sleep 5; + PerconaTest::kill_program(pid_file => $pid_file); + + $output = `cat $dest/*-slave-status 2>/dev/null`; + + if ( $sandbox_version lt '5.7' ) { + like( + $output, + qr/SHOW SLAVE STATUS/, + "MySQL 5.6 SLAVE STATUS" + ); + } else { + like( + $output, + qr/FROM performance_schema.replication_connection_configuration JOIN performance_schema.replication_applier_configuration USING/, + "MySQL 5.7 SLAVE STATUS" + ); + } + $sb->stop_sandbox(qw(chan_master1 chan_master2 chan_slave1)); +} + +my $slave1_port = $sb->port_for('slave1'); my $cmd = "$trunk/bin/pt-stalk --no-stalk --iterations=1 --host=127.0.0.1 --port=$slave1_port --user=msandbox " . "--password=msandbox --sleep 0 --run-time=10 --dest $dest --log $log_file --iterations=1 " . "--run-time=2 --pid $pid_file --defaults-file=$cnf >$log_file 2>&1"; -system($cmd); -sleep 5; -PerconaTest::kill_program(pid_file => $pid_file); +system($cmd); +sleep 5; +PerconaTest::kill_program(pid_file => $pid_file); + +$output = `cat $dest/*-slave-status 2>/dev/null`; + +like( + $output, + qr/SHOW SLAVE STATUS/, + "MySQL 5.6 SLAVE STATUS" +); -$output = `cat $dest/*-slave-status 2>/dev/null`; - -if ( $sandbox_version lt '5.7' ) { - like( - $output, - qr/SHOW SLAVE STATUS/, - "MySQL 5.6 SLAVE STATUS" - ); -} else { - like( - $output, - qr/FROM performance_schema.replication_connection_configuration JOIN performance_schema.replication_applier_configuration USING/, - "MySQL 5.7 SLAVE STATUS" - ); -} - -$sb->stop_sandbox(qw(chan_master1 chan_master2 chan_slave1)); # ############################################################################# # Done. # #############################################################################