cluster/services/consul: test in simulacrum
This commit is contained in:
parent
cb92fb49f2
commit
f097de64c7
2 changed files with 25 additions and 0 deletions
|
@ -22,6 +22,11 @@ in
|
||||||
];
|
];
|
||||||
ready = ./ready.nix;
|
ready = ./ready.nix;
|
||||||
};
|
};
|
||||||
|
simulacrum = {
|
||||||
|
enable = true;
|
||||||
|
deps = [ "wireguard" ];
|
||||||
|
settings = ./test.nix;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
dns.records."consul-remote.internal".consulService = "consul-remote";
|
dns.records."consul-remote.internal".consulService = "consul-remote";
|
||||||
|
|
20
cluster/services/consul/test.nix
Normal file
20
cluster/services/consul/test.nix
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
testScript = ''
|
||||||
|
import json
|
||||||
|
|
||||||
|
start_all()
|
||||||
|
|
||||||
|
with subtest("should form cluster"):
|
||||||
|
nodes = [ n for n in machines if n != nowhere ]
|
||||||
|
for machine in nodes:
|
||||||
|
machine.succeed("systemctl start consul-ready.service")
|
||||||
|
for machine in nodes:
|
||||||
|
consulConfig = json.loads(machine.succeed("cat /etc/consul.json"))
|
||||||
|
addr = consulConfig["addresses"]["http"]
|
||||||
|
port = consulConfig["ports"]["http"]
|
||||||
|
setEnv = f"CONSUL_HTTP_ADDR={addr}:{port}"
|
||||||
|
memberList = machine.succeed(f"{setEnv} consul members --status=alive")
|
||||||
|
for machine2 in nodes:
|
||||||
|
assert machine2.name in memberList
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in a new issue