1 import ./make-test-python.nix (
5 nodes.host = {config, pkgs, ...}: {
7 # Prerequisites for ZFS and tests.
8 boot.supportedFilesystems = [ "zfs" ];
9 environment.systemPackages = [ pkgs.zrepl ];
10 networking.hostId = "deadbeef";
14 # Enable Prometheus output for status assertions.
15 global.monitoring = [{
19 # Create a periodic snapshot job for an ephemeral zpool.
24 filesystems."test" = true;
44 with subtest("Wait for zrepl and network ready"):
45 host.systemctl("start network-online.target")
46 host.wait_for_unit("network-online.target")
47 host.wait_for_unit("zrepl.service")
49 with subtest("Create test zpool"):
50 # ZFS requires 64MiB minimum pool size.
51 host.succeed("fallocate -l 64MiB /root/zpool.img")
52 host.succeed("zpool create test /root/zpool.img")
54 with subtest("Check for completed zrepl snapshot"):
55 # zrepl periodic snapshot job creates a snapshot with this prefix.
56 host.wait_until_succeeds("zfs list -t snapshot | grep -q zrepl_")
58 with subtest("Verify HTTP monitoring server is configured"):
59 out = host.succeed("curl -f localhost:9811/metrics")
62 "zrepl_start_time" in out
63 ), "zrepl start time metric was not found in Prometheus output"
66 "zrepl_zfs_snapshot_duration_count{filesystem=\"test\"}" in out
67 ), "zrepl snapshot counter for test was not found in Prometheus output"