2009-10-27 19:19:48 +00:00
|
|
|
{ nixos ? ./..
|
|
|
|
, nixpkgs ? /etc/nixos/nixpkgs
|
|
|
|
, system ? builtins.currentSystem
|
|
|
|
}:
|
|
|
|
|
2011-04-27 14:03:06 +00:00
|
|
|
with import ../lib/build-vms.nix { inherit nixos nixpkgs system; };
|
2009-10-27 19:19:48 +00:00
|
|
|
|
|
|
|
rec {
|
2014-06-28 14:04:49 +00:00
|
|
|
name = "check-filesystems";
|
|
|
|
|
2009-10-27 19:19:48 +00:00
|
|
|
nodes = {
|
|
|
|
share = {pkgs, config, ...}: {
|
2012-03-16 20:41:49 +00:00
|
|
|
services.nfs.server.enable = true;
|
|
|
|
services.nfs.server.exports = ''
|
2009-10-27 19:19:48 +00: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 20:41:49 +00:00
|
|
|
services.nfs.server.createMountPoints = true;
|
2009-10-27 19:19:48 +00: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 20:41:49 +00:00
|
|
|
fsType = "nfs";
|
2009-10-27 19:19:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
repos2 = {
|
|
|
|
mountPoint = "/repos2";
|
|
|
|
autocreate = true;
|
|
|
|
device = "share:/repos2";
|
2012-03-16 20:41:49 +00:00
|
|
|
fsType = "nfs";
|
2009-10-27 19:19:48 +00:00
|
|
|
};
|
2013-10-29 12:04:52 +00:00
|
|
|
in pkgs.lib.mkVMOverride [
|
2009-10-27 19:19:48 +00:00
|
|
|
repos1
|
2011-09-14 18:20:50 +00:00
|
|
|
repos1 # check remount
|
2009-10-27 19:19:48 +00:00
|
|
|
repos2 # check after remount
|
|
|
|
];
|
|
|
|
|
|
|
|
jobs.checkable = {
|
|
|
|
startOn = "stopped ${config.jobs.filesystems.name}";
|
|
|
|
respawn = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-10-27 19:19:48 +00:00
|
|
|
vms = buildVirtualNetwork { inherit nodes; };
|
|
|
|
|
|
|
|
test = runTests vms
|
|
|
|
''
|
|
|
|
startAll;
|
|
|
|
|
2012-10-24 16:22:53 +00:00
|
|
|
$share->waitForUnit("checkable");
|
|
|
|
$fsCheck->waitForUnit("checkable");
|
2009-10-27 19:19:48 +00:00
|
|
|
|
|
|
|
# check repos1
|
2012-10-24 16:22:53 +00:00
|
|
|
$fsCheck->succeed("test -d /repos1");
|
|
|
|
$share->succeed("touch /repos1/test1");
|
|
|
|
$fsCheck->succeed("test -e /repos1/test1");
|
2009-10-27 19:19:48 +00:00
|
|
|
|
|
|
|
# check repos2 (check after remount)
|
2012-10-24 16:22:53 +00:00
|
|
|
$fsCheck->succeed("test -d /repos2");
|
|
|
|
$share->succeed("touch /repos2/test2");
|
|
|
|
$fsCheck->succeed("test -e /repos2/test2");
|
2009-10-27 19:19:48 +00:00
|
|
|
|
|
|
|
# check without network
|
|
|
|
$share->block();
|
2012-10-24 16:22:53 +00:00
|
|
|
$fsCheck->fail("test -e /repos1/test1");
|
|
|
|
$fsCheck->fail("test -e /repos2/test2");
|
2009-10-27 19:19:48 +00:00
|
|
|
'';
|
|
|
|
}
|