nixos/tests/mysql-replication: fix test (#40850)

Failed non-deterministically on hydra because replcation
sometimes was not finished yet when checking the results.
This commit is contained in:
xeji 2018-05-22 01:22:12 +02:00 committed by GitHub
parent 050d07d672
commit fe79fc0be4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -57,18 +57,25 @@ in
$master->start; $master->start;
$master->waitForUnit("mysql"); $master->waitForUnit("mysql");
$master->waitForOpenPort(3306); $master->waitForOpenPort(3306);
# Wait for testdb to be fully populated (5 rows).
$master->waitUntilSucceeds("mysql -u root -D testdb -N -B -e 'select count(id) from tests' | grep -q 5");
$slave1->start; $slave1->start;
$slave2->start; $slave2->start;
$slave1->waitForUnit("mysql"); $slave1->waitForUnit("mysql");
$slave1->waitForOpenPort(3306); $slave1->waitForOpenPort(3306);
$slave2->waitForUnit("mysql"); $slave2->waitForUnit("mysql");
$slave2->waitForOpenPort(3306); $slave2->waitForOpenPort(3306);
$slave2->succeed("echo 'use testdb; select * from tests' | mysql -u root -N | grep 4");
# wait for replications to finish
$slave1->waitUntilSucceeds("mysql -u root -D testdb -N -B -e 'select count(id) from tests' | grep -q 5");
$slave2->waitUntilSucceeds("mysql -u root -D testdb -N -B -e 'select count(id) from tests' | grep -q 5");
$slave2->succeed("systemctl stop mysql"); $slave2->succeed("systemctl stop mysql");
$master->succeed("echo 'insert into testdb.tests values (123, 456);' | mysql -u root -N"); $master->succeed("echo 'insert into testdb.tests values (123, 456);' | mysql -u root -N");
$slave2->succeed("systemctl start mysql"); $slave2->succeed("systemctl start mysql");
$slave2->waitForUnit("mysql"); $slave2->waitForUnit("mysql");
$slave2->waitForOpenPort(3306); $slave2->waitForOpenPort(3306);
$slave2->succeed("echo 'select * from testdb.tests where Id = 123;' | mysql -u root -N | grep 456"); $slave2->waitUntilSucceeds("echo 'select * from testdb.tests where Id = 123;' | mysql -u root -N | grep 456");
''; '';
}) })