Skip to content

Commit

Permalink
nixos/tests/mysql-backup: fix non-deterministic failure (#40258)
Browse files Browse the repository at this point in the history
Sometimes failed because of delayed creation of the backup file.
  • Loading branch information
xeji committed May 12, 2018
1 parent 1472076 commit a19cc36
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions nixos/tests/mysql-backup.nix
Expand Up @@ -23,17 +23,25 @@ import ./make-test.nix ({ pkgs, ... } : {
testScript =
'' startAll;
# Delete backup file that may be left over from a previous test run.
# This is not needed on Hydra but useful for repeated local test runs.
$master->execute("rm -f /var/backup/mysql/testdb.gz");
# Need to have mysql started so that it can be populated with data.
$master->waitForUnit("mysql.service");
# Wait for testdb to be populated.
$master->sleep(10);
# 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");
# Do a backup and wait for it to finish.
# Do a backup and wait for it to start
$master->startJob("mysql-backup.service");
$master->waitForJob("mysql-backup.service");
# Check that data appears in backup
# wait for backup to fail, because of database 'doesnotexist'
$master->waitUntilFails("systemctl is-active -q mysql-backup.service");
# wait for backup file and check that data appears in backup
$master->waitForFile("/var/backup/mysql/testdb.gz");
$master->succeed("${pkgs.gzip}/bin/zcat /var/backup/mysql/testdb.gz | grep hello");
# Check that a failed backup is logged
Expand Down

0 comments on commit a19cc36

Please sign in to comment.