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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
import ./make-test-python.nix (
{ pkgs, lib, ... }:
let
drbdPort = 7789;
drbdConfig =
{ nodes, ... }:
{
virtualisation.emptyDiskImages = [ 1 ];
networking.firewall.allowedTCPPorts = [ drbdPort ];
services.drbd = {
enable = true;
config = ''
global {
usage-count yes;
}
common {
net {
protocol C;
ping-int 1;
}
}
resource r0 {
volume 0 {
device /dev/drbd0;
disk /dev/vdb;
meta-disk internal;
}
on drbd1 {
address ${nodes.drbd1.config.networking.primaryIPAddress}:${toString drbdPort};
}
on drbd2 {
address ${nodes.drbd2.config.networking.primaryIPAddress}:${toString drbdPort};
}
}
'';
};
};
in
{
name = "drbd";
meta = with pkgs.lib.maintainers; {
maintainers = [ ryantm astro ];
};
nodes.drbd1 = drbdConfig;
nodes.drbd2 = drbdConfig;
testScript = { nodes }: ''
drbd1.start()
drbd2.start()
drbd1.wait_for_unit("network.target")
drbd2.wait_for_unit("network.target")
drbd1.succeed(
"drbdadm create-md r0",
"drbdadm up r0",
"drbdadm primary r0 --force",
)
drbd2.succeed("drbdadm create-md r0", "drbdadm up r0")
drbd1.succeed(
"mkfs.ext4 /dev/drbd0",
"mkdir -p /mnt/drbd",
"mount /dev/drbd0 /mnt/drbd",
"touch /mnt/drbd/hello",
"umount /mnt/drbd",
"drbdadm secondary r0",
)
drbd1.sleep(1)
drbd2.succeed(
"drbdadm primary r0",
"mkdir -p /mnt/drbd",
"mount /dev/drbd0 /mnt/drbd",
"ls /mnt/drbd/hello",
)
'';
}
)
|