about summary refs log tree commit diff
path: root/nixos/tests
diff options
context:
space:
mode:
authorAaron Andersen <aaron@fosslib.net>2019-04-12 19:06:11 -0400
committerAaron Andersen <aaron@fosslib.net>2019-04-15 21:51:55 -0400
commit5f4df8e50935e219704389d8467f7edd363896d9 (patch)
tree5b9672047ac2032ee3509d7c7caef4d509a3efee /nixos/tests
parent1fc591f9a5bd1b016b5d66dfab29560073955a14 (diff)
downloadnixlib-5f4df8e50935e219704389d8467f7edd363896d9.tar
nixlib-5f4df8e50935e219704389d8467f7edd363896d9.tar.gz
nixlib-5f4df8e50935e219704389d8467f7edd363896d9.tar.bz2
nixlib-5f4df8e50935e219704389d8467f7edd363896d9.tar.lz
nixlib-5f4df8e50935e219704389d8467f7edd363896d9.tar.xz
nixlib-5f4df8e50935e219704389d8467f7edd363896d9.tar.zst
nixlib-5f4df8e50935e219704389d8467f7edd363896d9.zip
automysqlinit: init at 3.0_rc6
Diffstat (limited to 'nixos/tests')
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/automysqlbackup.nix34
2 files changed, 35 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 8b27ff808e6b..950eb01044f1 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -23,6 +23,7 @@ in
 {
   acme = handleTestOn ["x86_64-linux"] ./acme.nix {};
   atd = handleTest ./atd.nix {};
+  automysqlbackup = handleTest ./automysqlbackup.nix {};
   avahi = handleTest ./avahi.nix {};
   bcachefs = handleTestOn ["x86_64-linux"] ./bcachefs.nix {}; # linux-4.18.2018.10.12 is unsupported on aarch64
   beanstalkd = handleTest ./beanstalkd.nix {};
diff --git a/nixos/tests/automysqlbackup.nix b/nixos/tests/automysqlbackup.nix
new file mode 100644
index 000000000000..ada104a34de3
--- /dev/null
+++ b/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");
+    '';
+})