1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-25 23:20:55 +00:00
nixpkgs/nixos/tests/mysql/mysql-autobackup.nix
talyz 59e0120aa5
treewide: Fix mysql alias deprecation breakage
62733b37b4 broke evaluation in all
places `pkgs.mysql` was used. Fix this by changing all occurrences to
`pkgs.mariadb`.
2021-06-04 21:42:08 +02:00

39 lines
1.2 KiB
Nix

import ./../make-test-python.nix ({ pkgs, lib, ... }:
{
name = "automysqlbackup";
meta.maintainers = [ lib.maintainers.aanderse ];
machine =
{ pkgs, ... }:
{
services.mysql.enable = true;
services.mysql.package = pkgs.mariadb;
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"
)
'';
})