2 system ? builtins.currentSystem,
4 pkgs ? import ../../.. { inherit system config; },
9 inherit (import ./common.nix { inherit pkgs lib; }) mkTestName mariadbPackages;
11 makeTest = import ./../make-test-python.nix;
15 name ? mkTestName package
17 name = "${name}-backup";
20 master = { pkgs, ... }: {
24 initialDatabases = [ { name = "testdb"; schema = ./testdb.sql; } ];
27 services.mysqlBackup = {
29 databases = [ "doesnotexist" "testdb" ];
37 # Delete backup file that may be left over from a previous test run.
38 # This is not needed on Hydra but useful for repeated local test runs.
39 master.execute("rm -f /var/backup/mysql/testdb.gz")
41 # Need to have mysql started so that it can be populated with data.
42 master.wait_for_unit("mysql.service")
44 # Wait for testdb to be fully populated (5 rows).
45 master.wait_until_succeeds(
46 "mysql -u root -D testdb -N -B -e 'select count(id) from tests' | grep -q 5"
49 # Do a backup and wait for it to start
50 master.start_job("mysql-backup.service")
52 # wait for backup to fail, because of database 'doesnotexist'
53 master.wait_until_fails("systemctl is-active -q mysql-backup.service")
55 # wait for backup file and check that data appears in backup
56 master.wait_for_file("/var/backup/mysql/testdb.gz")
58 "${pkgs.gzip}/bin/zcat /var/backup/mysql/testdb.gz | grep hello"
61 # Check that a failed backup is logged
63 "journalctl -u mysql-backup.service | grep 'fail.*doesnotexist' > /dev/null"
68 lib.mapAttrs (_: package: makeBackupTest { inherit package; }) mariadbPackages