nixos/tests: add moosefs test

This commit is contained in:
Markus Kowalewski 2021-10-06 21:51:07 +02:00
parent b302bda010
commit b74dc1a230
No known key found for this signature in database
GPG key ID: D865C8A91D7025EB
2 changed files with 90 additions and 0 deletions

View file

@ -303,6 +303,7 @@ in
moodle = handleTest ./moodle.nix {};
morty = handleTest ./morty.nix {};
mosquitto = handleTest ./mosquitto.nix {};
moosefs = handleTest ./moosefs.nix {};
mpd = handleTest ./mpd.nix {};
mpv = handleTest ./mpv.nix {};
mumble = handleTest ./mumble.nix {};

89
nixos/tests/moosefs.nix Normal file
View file

@ -0,0 +1,89 @@
import ./make-test-python.nix ({ pkgs, ... } :
let
master = { pkgs, ... } : {
# data base is stored in memory
# server crashes with default memory size
virtualisation.memorySize = 1024;
services.moosefs.master = {
enable = true;
openFirewall = true;
exports = [
"* / rw,alldirs,admin,maproot=0:0"
"* . rw"
];
};
};
chunkserver = { pkgs, ... } : {
virtualisation.emptyDiskImages = [ 4096 ];
boot.initrd.postDeviceCommands = ''
${pkgs.e2fsprogs}/bin/mkfs.ext4 -L data /dev/vdb
'';
fileSystems = pkgs.lib.mkVMOverride {
"/data" = {
device = "/dev/disk/by-label/data";
fsType = "ext4";
};
};
services.moosefs = {
masterHost = "master";
chunkserver = {
openFirewall = true;
enable = true;
hdds = [ "~/data" ];
};
};
};
metalogger = { pkgs, ... } : {
services.moosefs = {
masterHost = "master";
metalogger.enable = true;
};
};
client = { pkgs, ... } : {
services.moosefs.client.enable = true;
};
in {
name = "moosefs";
nodes= {
inherit master;
inherit metalogger;
chunkserver1 = chunkserver;
chunkserver2 = chunkserver;
client1 = client;
client2 = client;
};
testScript = ''
# prepare master server
master.start()
master.wait_for_unit("multi-user.target")
master.succeed("mfsmaster-init")
master.succeed("systemctl restart mfs-master")
master.wait_for_unit("mfs-master.service")
metalogger.wait_for_unit("mfs-metalogger.service")
for chunkserver in [chunkserver1, chunkserver2]:
chunkserver.wait_for_unit("multi-user.target")
chunkserver.succeed("chown moosefs:moosefs /data")
chunkserver.succeed("systemctl restart mfs-chunkserver")
chunkserver.wait_for_unit("mfs-chunkserver.service")
for client in [client1, client2]:
client.wait_for_unit("multi-user.target")
client.succeed("mkdir /moosefs")
client.succeed("mount -t moosefs master:/ /moosefs")
client1.succeed("echo test > /moosefs/file")
client2.succeed("grep test /moosefs/file")
'';
})