diff options
Diffstat (limited to 'nixpkgs/nixos/tests/automysqlbackup.nix')
-rw-r--r-- | nixpkgs/nixos/tests/automysqlbackup.nix | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/nixpkgs/nixos/tests/automysqlbackup.nix b/nixpkgs/nixos/tests/automysqlbackup.nix new file mode 100644 index 000000000000..ada104a34de3 --- /dev/null +++ b/nixpkgs/nixos/tests/automysqlbackup.nix @@ -0,0 +1,34 @@ +import ./make-test.nix ({ pkgs, lib, ... }: + +{ + name = "automysqlbackup"; + meta.maintainers = [ lib.maintainers.aanderse ]; + + machine = + { pkgs, ... }: + { + services.mysql.enable = true; + services.mysql.package = pkgs.mysql; + services.mysql.initialDatabases = [ { name = "testdb"; schema = ./testdb.sql; } ]; + + services.automysqlbackup.enable = true; + }; + + testScript = '' + startAll; + + # Need to have mysql started so that it can be populated with data. + $machine->waitForUnit("mysql.service"); + + # Wait for testdb to be fully populated (5 rows). + $machine->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 start + $machine->startJob("automysqlbackup.service"); + $machine->waitForJob("automysqlbackup.service"); + + # wait for backup file and check that data appears in backup + $machine->waitForFile("/var/backup/mysql/daily/testdb"); + $machine->succeed("${pkgs.gzip}/bin/zcat /var/backup/mysql/daily/testdb/daily_testdb_*.sql.gz | grep hello"); + ''; +}) |