diff options
author | Jörg Thalheim <Mic92@users.noreply.github.com> | 2020-05-07 15:51:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-07 15:51:17 +0100 |
commit | c880c7b5922ccfd97f8254917bd10d7267d4786a (patch) | |
tree | 3c6990c7fe7c5344fb18e9b06b2b2c1ea8982c46 /nixos/tests/mysql/mysql-autobackup.nix | |
parent | be14551a197024e2379330e8b1886358ce4f5414 (diff) | |
parent | 585bbc598c1787090fd8e144339dff77d10d02cf (diff) | |
download | nixlib-c880c7b5922ccfd97f8254917bd10d7267d4786a.tar nixlib-c880c7b5922ccfd97f8254917bd10d7267d4786a.tar.gz nixlib-c880c7b5922ccfd97f8254917bd10d7267d4786a.tar.bz2 nixlib-c880c7b5922ccfd97f8254917bd10d7267d4786a.tar.lz nixlib-c880c7b5922ccfd97f8254917bd10d7267d4786a.tar.xz nixlib-c880c7b5922ccfd97f8254917bd10d7267d4786a.tar.zst nixlib-c880c7b5922ccfd97f8254917bd10d7267d4786a.zip |
Merge pull request #84136 from Izorkin/mariadb-galera-test
nixos/tests: add check mariadb galera cluster
Diffstat (limited to 'nixos/tests/mysql/mysql-autobackup.nix')
-rw-r--r-- | nixos/tests/mysql/mysql-autobackup.nix | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/nixos/tests/mysql/mysql-autobackup.nix b/nixos/tests/mysql/mysql-autobackup.nix new file mode 100644 index 000000000000..65576e52a537 --- /dev/null +++ b/nixos/tests/mysql/mysql-autobackup.nix @@ -0,0 +1,38 @@ +import ./../make-test-python.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 = '' + start_all() + + # Need to have mysql started so that it can be populated with data. + machine.wait_for_unit("mysql.service") + + with subtest("Wait for testdb to be fully populated (5 rows)."): + machine.wait_until_succeeds( + "mysql -u root -D testdb -N -B -e 'select count(id) from tests' | grep -q 5" + ) + + with subtest("Do a backup and wait for it to start"): + machine.start_job("automysqlbackup.service") + machine.wait_for_job("automysqlbackup.service") + + with subtest("wait for backup file and check that data appears in backup"): + machine.wait_for_file("/var/backup/mysql/daily/testdb") + machine.succeed( + "${pkgs.gzip}/bin/zcat /var/backup/mysql/daily/testdb/daily_testdb_*.sql.gz | grep hello" + ) + ''; +}) |