2019-11-24 01:37:18 +01:00
|
|
|
import ./make-test-python.nix ({pkgs, lib, ...}:
|
2019-08-17 01:28:43 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
client = { pkgs, ... } : {
|
|
|
|
environment.systemPackages = [ pkgs.glusterfs ];
|
|
|
|
fileSystems = pkgs.lib.mkVMOverride
|
2020-02-17 09:57:35 +01:00
|
|
|
{ "/gluster" =
|
|
|
|
{ device = "server1:/gv0";
|
|
|
|
fsType = "glusterfs";
|
|
|
|
};
|
|
|
|
};
|
2019-08-17 01:28:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
server = { pkgs, ... } : {
|
|
|
|
networking.firewall.enable = false;
|
|
|
|
services.glusterfs.enable = true;
|
|
|
|
|
|
|
|
# create a mount point for the volume
|
|
|
|
boot.initrd.postDeviceCommands = ''
|
|
|
|
${pkgs.e2fsprogs}/bin/mkfs.ext4 -L data /dev/vdb
|
|
|
|
'';
|
|
|
|
|
|
|
|
virtualisation.emptyDiskImages = [ 1024 ];
|
|
|
|
|
|
|
|
fileSystems = pkgs.lib.mkVMOverride
|
2020-02-17 09:57:35 +01:00
|
|
|
{ "/data" =
|
|
|
|
{ device = "/dev/disk/by-label/data";
|
|
|
|
fsType = "ext4";
|
|
|
|
};
|
|
|
|
};
|
2019-08-17 01:28:43 +02:00
|
|
|
};
|
|
|
|
in {
|
|
|
|
name = "glusterfs";
|
|
|
|
|
|
|
|
nodes = {
|
|
|
|
server1 = server;
|
|
|
|
server2 = server;
|
|
|
|
client1 = client;
|
|
|
|
client2 = client;
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
2019-11-24 01:37:18 +01:00
|
|
|
server1.wait_for_unit("glusterd.service")
|
|
|
|
server2.wait_for_unit("glusterd.service")
|
|
|
|
|
|
|
|
server1.wait_until_succeeds("gluster peer status")
|
|
|
|
server2.wait_until_succeeds("gluster peer status")
|
2019-08-17 01:28:43 +02:00
|
|
|
|
|
|
|
# establish initial contact
|
2019-11-24 01:37:18 +01:00
|
|
|
server1.succeed("gluster peer probe server2")
|
|
|
|
server1.succeed("gluster peer probe server1")
|
2019-08-17 01:28:43 +02:00
|
|
|
|
2019-11-24 01:37:18 +01:00
|
|
|
server1.succeed("gluster peer status | grep Connected")
|
2019-08-17 01:28:43 +02:00
|
|
|
|
|
|
|
# create volumes
|
2019-11-24 01:37:18 +01:00
|
|
|
server1.succeed("mkdir -p /data/vg0")
|
|
|
|
server2.succeed("mkdir -p /data/vg0")
|
|
|
|
server1.succeed("gluster volume create gv0 server1:/data/vg0 server2:/data/vg0")
|
|
|
|
server1.succeed("gluster volume start gv0")
|
2019-08-17 01:28:43 +02:00
|
|
|
|
|
|
|
# test clients
|
2019-11-24 01:37:18 +01:00
|
|
|
client1.wait_for_unit("gluster.mount")
|
|
|
|
client2.wait_for_unit("gluster.mount")
|
2019-08-17 01:28:43 +02:00
|
|
|
|
2019-11-24 01:37:18 +01:00
|
|
|
client1.succeed("echo test > /gluster/file1")
|
|
|
|
client2.succeed("grep test /gluster/file1")
|
2019-08-17 01:28:43 +02:00
|
|
|
'';
|
|
|
|
})
|