1import ../make-test-python.nix (
2 { pkgs, ... }:
3 {
4 name = "stratis";
5
6 meta = with pkgs.lib.maintainers; {
7 maintainers = [ nickcao ];
8 };
9
10 nodes.machine =
11 { pkgs, ... }:
12 {
13 services.stratis.enable = true;
14 virtualisation.emptyDiskImages = [
15 2048
16 1024
17 1024
18 1024
19 ];
20 };
21
22 testScript = ''
23 machine.wait_for_unit("stratisd")
24 # test pool creation
25 machine.succeed("stratis pool create testpool /dev/vdb")
26 machine.succeed("stratis pool add-data testpool /dev/vdc")
27 machine.succeed("stratis pool init-cache testpool /dev/vdd")
28 machine.succeed("stratis pool add-cache testpool /dev/vde")
29 # test filesystem creation and rename
30 machine.succeed("stratis filesystem create testpool testfs0")
31 machine.succeed("stratis filesystem rename testpool testfs0 testfs1")
32 # test snapshot
33 machine.succeed("mkdir -p /mnt/testfs1 /mnt/testfs2")
34 machine.wait_for_file("/dev/stratis/testpool/testfs1")
35 machine.succeed("mount /dev/stratis/testpool/testfs1 /mnt/testfs1")
36 machine.succeed("echo test0 > /mnt/testfs1/test0")
37 machine.succeed("echo test1 > /mnt/testfs1/test1")
38 machine.succeed("stratis filesystem snapshot testpool testfs1 testfs2")
39 machine.succeed("echo test2 > /mnt/testfs1/test1")
40 machine.wait_for_file("/dev/stratis/testpool/testfs2")
41 machine.succeed("mount /dev/stratis/testpool/testfs2 /mnt/testfs2")
42 assert "test0" in machine.succeed("cat /mnt/testfs1/test0")
43 assert "test0" in machine.succeed("cat /mnt/testfs2/test0")
44 assert "test2" in machine.succeed("cat /mnt/testfs1/test1")
45 assert "test1" in machine.succeed("cat /mnt/testfs2/test1")
46 '';
47 }
48)