diff --git a/sandbox/test-env b/sandbox/test-env index 3643a848..b602f606 100755 --- a/sandbox/test-env +++ b/sandbox/test-env @@ -369,24 +369,6 @@ case $opt in exit_status=1 fi ;; - reset) - # Several tests reset the bin logs so that queries from prior tests - # don't replicate to new sandbox servers. This makes creating new - # sandbox servers a lot faster. There's no check if this works or - # not, so... yeah. - echo "RESETTING SLAVE. This is DANGEROUS and DOESN'T WORK. FIXME." >&2 - /tmp/12347/use -e "STOP SLAVE; FLUSH SLAVE;" - /tmp/12346/use -e "STOP SLAVE; FLUSH SLAVE; FLUSH MASTER;" - /tmp/12345/use -e "FLUSH MASTER" - - /tmp/12346/use -e "CHANGE MASTER TO master_host='127.0.0.1', master_user='msandbox', master_password='msandbox', master_port=12345, master_log_file='mysql-bin.000001', master_log_pos=0" - /tmp/12346/use -e "START SLAVE" - - /tmp/12347/use -e "CHANGE MASTER TO master_host='127.0.0.1', master_user='msandbox', master_password='msandbox', master_port=12346, master_log_file='mysql-bin.000001', master_log_pos=0" - /tmp/12347/use -e "START SLAVE" - - exit_status=0 - ;; version) set_mysql_version echo $MYSQL_VERSION diff --git a/t/lib/MasterSlave.t b/t/lib/MasterSlave.t index b022a274..ad14fa6a 100644 --- a/t/lib/MasterSlave.t +++ b/t/lib/MasterSlave.t @@ -738,8 +738,6 @@ $sb->wipe_clean($master_dbh); diag(`$trunk/sandbox/stop-sandbox 2903 2902 2901 2900`); diag(`/tmp/12346/use -e "set global read_only=1"`); diag(`/tmp/12347/use -e "set global read_only=1"`); -$sb->wait_for_slaves(); -diag(`$trunk/sandbox/test-env reset`); ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); done_testing; exit; diff --git a/t/lib/RowDiff.t b/t/lib/RowDiff.t index 83ffd5af..c6da9012 100644 --- a/t/lib/RowDiff.t +++ b/t/lib/RowDiff.t @@ -444,7 +444,6 @@ SKIP: { $d = new RowDiff(dbh => $master_dbh); - diag(`$trunk/sandbox/mk-test-env reset >/dev/null 2>&1`); $sb->create_dbs($master_dbh, [qw(test)]); $sb->load_file('master', 't/lib/samples/issue_11.sql'); PerconaTest::wait_until( diff --git a/t/lib/TableSyncer.t b/t/lib/TableSyncer.t index 37ad18b8..23d664e9 100644 --- a/t/lib/TableSyncer.t +++ b/t/lib/TableSyncer.t @@ -576,7 +576,6 @@ $dst->{dbh} = $dst_dbh; # ########################################################################### make_plugins(); $sb->load_file('master', 't/lib/samples/before-TableSyncGroupBy.sql'); -sleep 1; sync_table( src => "test.test1", @@ -606,7 +605,6 @@ is_deeply( # ############################################################################# make_plugins(); $sb->load_file('master', 't/lib/samples/issue_96.sql'); -sleep 1; # Make paranoid-sure that the tables differ. my $r1 = $src_dbh->selectall_arrayref('SELECT from_city FROM issue_96.t WHERE package_id=4'); @@ -1051,7 +1049,9 @@ my $output = ''; "Retries wait" ); } -diag(`$trunk/sandbox/test-env reset`); +diag(`/tmp/12347/use -e "stop slave"`); +diag(`/tmp/12346/use -e "start slave"`); +diag(`/tmp/12347/use -e "start slave"`); # ############################################################################# # Done. diff --git a/t/pt-fifo-split/pt-fifo-split.t b/t/pt-fifo-split/pt-fifo-split.t index 0bcbd76d..d0b4d55b 100644 --- a/t/pt-fifo-split/pt-fifo-split.t +++ b/t/pt-fifo-split/pt-fifo-split.t @@ -9,7 +9,7 @@ BEGIN { use strict; use warnings FATAL => 'all'; use English qw(-no_match_vars); -use Test::More tests => 4; +use Test::More; if ( !$ENV{SLOW_TESTS} ) { plan skip_all => "pt-fifo-split/pt-fifo-split. is a top 5 slowest file; set SLOW_TESTS=1 to enable it."; @@ -63,4 +63,5 @@ unlink '/tmp/pt-script.pid'; # ############################################################################# # Done. # ############################################################################# +done_testing; exit; diff --git a/t/pt-heartbeat/multi_update_mode.t b/t/pt-heartbeat/multi_update_mode.t index b9a0502e..fdcdfe06 100644 --- a/t/pt-heartbeat/multi_update_mode.t +++ b/t/pt-heartbeat/multi_update_mode.t @@ -9,15 +9,12 @@ BEGIN { use strict; use warnings FATAL => 'all'; use English qw(-no_match_vars); -use Time::HiRes qw(sleep); use Test::More; use PerconaTest; use Sandbox; require "$trunk/bin/pt-heartbeat"; -diag(`$trunk/sandbox/test-env reset`); - my $dp = new DSNParser(opts=>$dsn_opts); my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp); my $master_dbh = $sb->get_dbh_for('master'); @@ -37,10 +34,12 @@ 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(); my $output; -my $pid_file = "/tmp/__mk-heartbeat-test.pid"; +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. @@ -54,8 +53,7 @@ my @ports = qw(12345 12346 12347); foreach my $port (@ports) { system("$trunk/bin/pt-heartbeat -h 127.1 -u msandbox -p msandbox -P $port --database test --table heartbeat --create-table --update --interval 0.5 --daemonize --pid $pid_file.$port >/dev/null"); - sleep 0.2; - + PerconaTest::wait_for_files("$pid_file.$port"); ok( -f "$pid_file.$port", "--update on $port started" @@ -154,7 +152,7 @@ ok( # ############################################################################ # $rows already has slave2 heartbeat info. -sleep 1.0; +sleep 1; my $rows2 = $slave2_dbh->selectall_hashref("select * from test.heartbeat", 'server_id'); diff --git a/t/pt-slave-find/pt-slave-find.t b/t/pt-slave-find/pt-slave-find.t index 8488dfed..c2abfe09 100644 --- a/t/pt-slave-find/pt-slave-find.t +++ b/t/pt-slave-find/pt-slave-find.t @@ -13,23 +13,33 @@ use Test::More; use PerconaTest; use Sandbox; + require "$trunk/bin/pt-slave-find"; my $dp = new DSNParser(opts=>$dsn_opts); my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp); -my $master_dbh = $sb->get_dbh_for('master'); -my $slave_dbh = $sb->get_dbh_for('slave1'); -my $slave_2_dbh = $sb->get_dbh_for('slave2'); +my $slave1_dbh = $sb->get_dbh_for('slave1'); +my $slave2_dbh = $sb->get_dbh_for('slave2'); -diag(`$trunk/sandbox/test-env reset`); +# This test is sensitive to ghost/old slaves created/destroyed by other +# tests. So we stop the slaves, restart the master, and start everything +# again. Hopefully this will return the env to its original state. +$slave2_dbh->do("STOP SLAVE"); +$slave1_dbh->do("STOP SLAVE"); +diag(`/tmp/12345/stop >/dev/null`); +diag(`/tmp/12345/start >/dev/null`); +$slave1_dbh->do("START SLAVE"); +$slave2_dbh->do("START SLAVE"); + +my $master_dbh = $sb->get_dbh_for('master'); if ( !$master_dbh ) { plan skip_all => 'Cannot connect to sandbox master'; } -elsif ( !$slave_dbh ) { +elsif ( !$slave1_dbh ) { plan skip_all => 'Cannot connect to sandbox slave'; } -elsif ( !$slave_2_dbh ) { +elsif ( !$slave2_dbh ) { plan skip_all => 'Cannot connect to second sandbox slave'; } else { @@ -42,7 +52,7 @@ my $output = `$trunk/bin/pt-slave-find --help`; like($output, qr/Prompt for a password/, 'It compiles'); # Double check that we're setup correctly. -my $row = $slave_2_dbh->selectall_arrayref('SHOW SLAVE STATUS', {Slice => {}}); +my $row = $slave2_dbh->selectall_arrayref('SHOW SLAVE STATUS', {Slice => {}}); is( $row->[0]->{master_port}, '12346', @@ -108,8 +118,8 @@ my (@innodb_versions) = $result =~ /$innodb_re/g; $result =~ s/$innodb_re/InnoDB version BUILTIN/g; my $master_version = VersionParser->new($master_dbh); -my $slave_version = VersionParser->new($slave_dbh); -my $slave2_version = VersionParser->new($slave_2_dbh); +my $slave_version = VersionParser->new($slave1_dbh); +my $slave2_version = VersionParser->new($slave2_dbh); is( $innodb_versions[0],