nixos/syncoid: test both with and without --no-sync-snap

This commit is contained in:
Ben Wolsieffer 2020-11-22 14:27:55 -05:00 committed by Daniel Fullmer
parent d87903ac6b
commit 0f66d95328

View File

@ -33,13 +33,22 @@ in {
autosnap = true;
};
datasets."pool/test".useTemplate = [ "test" ];
datasets."pool/sanoid".useTemplate = [ "test" ];
extraArgs = [ "--verbose" ];
};
services.syncoid = {
enable = true;
sshKey = "/var/lib/syncoid/id_ecdsa";
commands."pool/test".target = "root@target:pool/test";
commands = {
# Sync snapshot taken by sanoid
"pool/sanoid" = {
target = "root@target:pool/sanoid";
extraArgs = [ "--no-sync-snap" ];
};
# Take snapshot and sync
"pool/syncoid".target = "root@target:pool/syncoid";
};
};
};
target = { ... }: {
@ -53,18 +62,19 @@ in {
testScript = ''
source.succeed(
"mkdir /tmp/mnt",
"mkdir /mnt",
"parted --script /dev/vdb -- mklabel msdos mkpart primary 1024M -1s",
"udevadm settle",
"zpool create pool /dev/vdb1",
"zfs create -o mountpoint=legacy pool/test",
"mount -t zfs pool/test /tmp/mnt",
"zpool create pool -R /mnt /dev/vdb1",
"zfs create pool/sanoid",
"zfs create pool/syncoid",
"udevadm settle",
)
target.succeed(
"mkdir /mnt",
"parted --script /dev/vdb -- mklabel msdos mkpart primary 1024M -1s",
"udevadm settle",
"zpool create pool /dev/vdb1",
"zpool create pool -R /mnt /dev/vdb1",
"udevadm settle",
)
@ -75,16 +85,15 @@ in {
"chown -R syncoid:syncoid /var/lib/syncoid/",
)
source.succeed("touch /tmp/mnt/test.txt")
# Take snapshot with sanoid
source.succeed("touch /mnt/pool/sanoid/test.txt")
source.systemctl("start --wait sanoid.service")
# Sync snapshots
target.wait_for_open_port(22)
source.succeed("touch /mnt/pool/syncoid/test.txt")
source.systemctl("start --wait syncoid.service")
target.succeed(
"mkdir /tmp/mnt",
"zfs set mountpoint=legacy pool/test",
"mount -t zfs pool/test /tmp/mnt",
)
target.succeed("cat /tmp/mnt/test.txt")
target.succeed("cat /mnt/pool/sanoid/test.txt")
target.succeed("cat /mnt/pool/syncoid/test.txt")
'';
})