Author: eelco Date: 2010-06-09 13:18:49 +0000 (Wed, 09 Jun 2010) New Revision: 22197
You can view the changes in this commit at: https://svn.nixos.org/viewvc/nix?rev=22197&view=rev Modified: nixos/branches/boot-order/tests/nfs.nix Log: * Test whether distributed locking works on NFS. Changes: Modified: nixos/branches/boot-order/tests/nfs.nix =================================================================== --- nixos/branches/boot-order/tests/nfs.nix 2010-06-09 13:18:01 UTC (rev 22196) +++ nixos/branches/boot-order/tests/nfs.nix 2010-06-09 13:18:49 UTC (rev 22197) @@ -1,18 +1,25 @@ { pkgs, ... }: +let + + client = + { config, pkgs, ... }: + { fileSystems = pkgs.lib.mkOverride 50 {} + [ { mountPoint = "/data"; + device = "server:/data"; + fsType = "nfs"; + options = "bootwait"; + } + ]; + }; + +in + { nodes = - { client = - { config, pkgs, ... }: - { fileSystems = pkgs.lib.mkOverride 50 {} - [ { mountPoint = "/data"; - device = "server:/data"; - fsType = "nfs"; - options = "bootwait"; - } - ]; - }; + { client1 = client; + client2 = client; server = { config, pkgs, ... }: @@ -33,14 +40,24 @@ $server->waitForJob("nfs-kernel-mountd"); $server->waitForJob("nfs-kernel-statd"); - $client->waitForJob("nfs-kernel-statd"); + $client1->waitForJob("tty1"); # depends on filesystems + $client1->succeed("echo bla > /data/foo"); + $server->succeed("test -e /data/foo"); - $client->waitForJob("tty1"); # depends on filesystems + $client2->waitForJob("tty1"); # depends on filesystems + $client2->succeed("echo bla > /data/bar"); + $server->succeed("test -e /data/bar"); - $client->succeed("echo bar > /data/foo"); - $server->succeed("test -e /data/foo"); - - $client->shutdown; + # Test whether we can get a lock. !!! This step takes about 90 + # seconds because the NFS server waits that long after booting + # before accepting new locks. + $client2->succeed("time flock -n -s /data/lock true >&2"); + + # Test locking: client 1 acquires an exclusive lock, so client 2 + # should then fail to acquire a shared lock. + $client1->succeed("flock -x /data/lock -c 'touch locked; sleep 100000' &"); + $client1->waitForFile("locked"); + $client2->fail("flock -n -s /data/lock true"); ''; } _______________________________________________ nix-commits mailing list [email protected] http://mail.cs.uu.nl/mailman/listinfo/nix-commits
