2009-10-27 20:19:48 +01:00
|
|
|
{ nixos ? ./..
|
|
|
|
, nixpkgs ? /etc/nixos/nixpkgs
|
|
|
|
, system ? builtins.currentSystem
|
|
|
|
}:
|
|
|
|
|
2011-04-27 16:03:06 +02:00
|
|
|
with import ../lib/build-vms.nix { inherit nixos nixpkgs system; };
|
2009-10-27 20:19:48 +01:00
|
|
|
|
|
|
|
rec {
|
|
|
|
nodes = {
|
|
|
|
share = {pkgs, config, ...}: {
|
2012-03-16 21:41:49 +01:00
|
|
|
services.nfs.server.enable = true;
|
|
|
|
services.nfs.server.exports = ''
|
2009-10-27 20:19:48 +01:00
|
|
|
/repos1 192.168.1.0/255.255.255.0(rw,no_root_squash)
|
|
|
|
/repos2 192.168.1.0/255.255.255.0(rw,no_root_squash)
|
|
|
|
'';
|
2012-03-16 21:41:49 +01:00
|
|
|
services.nfs.server.createMountPoints = true;
|
2009-10-27 20:19:48 +01:00
|
|
|
|
|
|
|
jobs.checkable = {
|
|
|
|
startOn = [
|
|
|
|
config.jobs.nfs_kernel_exports.name
|
|
|
|
config.jobs.nfs_kernel_nfsd.name
|
|
|
|
];
|
|
|
|
respawn = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
fsCheck = {pkgs, config, ...}: {
|
|
|
|
fileSystems =
|
|
|
|
let
|
|
|
|
repos1 = {
|
|
|
|
mountPoint = "/repos1";
|
|
|
|
autocreate = true;
|
|
|
|
device = "share:/repos1";
|
2012-03-16 21:41:49 +01:00
|
|
|
fsType = "nfs";
|
2009-10-27 20:19:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
repos2 = {
|
|
|
|
mountPoint = "/repos2";
|
|
|
|
autocreate = true;
|
|
|
|
device = "share:/repos2";
|
2012-03-16 21:41:49 +01:00
|
|
|
fsType = "nfs";
|
2009-10-27 20:19:48 +01:00
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
in pkgs.lib.mkOverrideTemplate 50 {} [
|
2009-10-27 20:19:48 +01:00
|
|
|
repos1
|
2011-09-14 20:20:50 +02:00
|
|
|
repos1 # check remount
|
2009-10-27 20:19:48 +01:00
|
|
|
repos2 # check after remount
|
|
|
|
];
|
|
|
|
|
|
|
|
jobs.checkable = {
|
|
|
|
startOn = "stopped ${config.jobs.filesystems.name}";
|
|
|
|
respawn = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-10-27 20:19:48 +01:00
|
|
|
vms = buildVirtualNetwork { inherit nodes; };
|
|
|
|
|
|
|
|
test = runTests vms
|
|
|
|
''
|
|
|
|
startAll;
|
|
|
|
|
|
|
|
$share->waitForJob("checkable");
|
|
|
|
$fsCheck->waitForJob("checkable");
|
|
|
|
|
|
|
|
# check repos1
|
|
|
|
$fsCheck->mustSucceed("test -d /repos1");
|
|
|
|
$share->mustSucceed("touch /repos1/test1");
|
|
|
|
$fsCheck->mustSucceed("test -e /repos1/test1");
|
|
|
|
|
|
|
|
# check repos2 (check after remount)
|
|
|
|
$fsCheck->mustSucceed("test -d /repos2");
|
|
|
|
$share->mustSucceed("touch /repos2/test2");
|
|
|
|
$fsCheck->mustSucceed("test -e /repos2/test2");
|
|
|
|
|
|
|
|
# check without network
|
|
|
|
$share->block();
|
|
|
|
$fsCheck->mustFail("test -e /repos1/test1");
|
|
|
|
$fsCheck->mustFail("test -e /repos2/test2");
|
|
|
|
'';
|
|
|
|
}
|