blob: ef09264a0216718af63da59011dadf53ccde7369 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
import ./make-test-python.nix ({pkgs, lib, ...}:
let
client = { pkgs, ... } : {
environment.systemPackages = [ pkgs.glusterfs ];
virtualisation.fileSystems =
{ "/gluster" =
{ device = "server1:/gv0";
fsType = "glusterfs";
};
};
};
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 ];
virtualisation.fileSystems =
{ "/data" =
{ device = "/dev/disk/by-label/data";
fsType = "ext4";
};
};
};
in {
name = "glusterfs";
nodes = {
server1 = server;
server2 = server;
client1 = client;
client2 = client;
};
testScript = ''
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")
# establish initial contact
server1.succeed("gluster peer probe server2")
server1.succeed("gluster peer probe server1")
server1.succeed("gluster peer status | grep Connected")
# create volumes
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")
# test clients
client1.wait_for_unit("gluster.mount")
client2.wait_for_unit("gluster.mount")
client1.succeed("echo test > /gluster/file1")
client2.succeed("grep test /gluster/file1")
'';
})
|