fork
Configure Feed
Select the types of activity you want to include in your feed.
lol
fork
Configure Feed
Select the types of activity you want to include in your feed.
1import ../make-test-python.nix (
2 {
3 pkgs,
4 version ? 4,
5 ...
6 }:
7
8 let
9
10 client =
11 { pkgs, ... }:
12 {
13 virtualisation.fileSystems = {
14 "/data" = {
15 # nfs4 exports the export with fsid=0 as a virtual root directory
16 device = if (version == 4) then "server:/" else "server:/data";
17 fsType = "nfs";
18 options = [ "vers=${toString version}" ];
19 };
20 };
21 networking.firewall.enable = false; # FIXME: only open statd
22 };
23
24 in
25
26 {
27 name = "nfs";
28 meta = with pkgs.lib.maintainers; {
29 maintainers = [ ];
30 };
31
32 nodes = {
33 client1 = client;
34 client2 = client;
35
36 server =
37 { ... }:
38 {
39 services.nfs.server.enable = true;
40 services.nfs.server.exports = ''
41 /data 192.168.1.0/255.255.255.0(rw,no_root_squash,no_subtree_check,fsid=0)
42 '';
43 services.nfs.server.createMountPoints = true;
44 networking.firewall.enable = false; # FIXME: figure out what ports need to be allowed
45 };
46 };
47
48 testScript = ''
49 import time
50
51 server.wait_for_unit("nfs-server")
52 server.succeed("systemctl start network-online.target")
53 server.wait_for_unit("network-online.target")
54
55 start_all()
56
57 client1.wait_for_unit("data.mount")
58 client1.succeed("echo bla > /data/foo")
59 server.succeed("test -e /data/foo")
60
61 client2.wait_for_unit("data.mount")
62 client2.succeed("echo bla > /data/bar")
63 server.succeed("test -e /data/bar")
64
65 with subtest("restarting 'nfs-server' works correctly"):
66 server.succeed("systemctl restart nfs-server")
67 # will take 90 seconds due to the NFS grace period
68 client2.succeed("echo bla >> /data/bar")
69
70 with subtest("can get a lock"):
71 client2.succeed("time flock -n -s /data/lock true")
72
73 with subtest("client 2 fails to acquire lock held by client 1"):
74 client1.succeed("flock -x /data/lock -c 'touch locked; sleep 100000' >&2 &")
75 client1.wait_for_file("locked")
76 client2.fail("flock -n -s /data/lock true")
77
78 with subtest("client 2 obtains lock after resetting client 1"):
79 client2.succeed(
80 "flock -x /data/lock -c 'echo acquired; touch locked; sleep 100000' >&2 &"
81 )
82 client1.crash()
83 client1.start()
84 client2.wait_for_file("locked")
85
86 with subtest("locks survive server reboot"):
87 client1.wait_for_unit("data.mount")
88 server.shutdown()
89 server.start()
90 client1.succeed("touch /data/xyzzy")
91 client1.fail("time flock -n -s /data/lock true")
92
93 with subtest("unmounting during shutdown happens quickly"):
94 t1 = time.monotonic()
95 client1.shutdown()
96 duration = time.monotonic() - t1
97 # FIXME: regressed in kernel 6.1.28, temporarily disabled while investigating
98 # assert duration < 30, f"shutdown took too long ({duration} seconds)"
99 '';
100 }
101)