diff options
author | xeji <36407913+xeji@users.noreply.github.com> | 2018-05-12 11:37:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-12 11:37:35 +0200 |
commit | a19cc36e1a2f55767a7413effd02598278c6003f (patch) | |
tree | 5f87411661c7f70068aad7725b29e03bdd0513a8 /nixos | |
parent | 14720761763a06e98508f31bcba6626a95fd7518 (diff) | |
download | nixpkgs-a19cc36e1a2f55767a7413effd02598278c6003f.tar nixpkgs-a19cc36e1a2f55767a7413effd02598278c6003f.tar.gz nixpkgs-a19cc36e1a2f55767a7413effd02598278c6003f.tar.bz2 nixpkgs-a19cc36e1a2f55767a7413effd02598278c6003f.tar.lz nixpkgs-a19cc36e1a2f55767a7413effd02598278c6003f.tar.xz nixpkgs-a19cc36e1a2f55767a7413effd02598278c6003f.tar.zst nixpkgs-a19cc36e1a2f55767a7413effd02598278c6003f.zip |
nixos/tests/mysql-backup: fix non-deterministic failure (#40258)
Sometimes failed because of delayed creation of the backup file.
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/tests/mysql-backup.nix | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/nixos/tests/mysql-backup.nix b/nixos/tests/mysql-backup.nix index f5bcc460cba..ff365098883 100644 --- a/nixos/tests/mysql-backup.nix +++ b/nixos/tests/mysql-backup.nix @@ -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 |