cluster/services/consul: test in simulacrum
This commit is contained in:
parent
f558c9c724
commit
322ce99392
2 changed files with 24 additions and 0 deletions
|
@ -22,6 +22,11 @@ in
|
|||
];
|
||||
ready = ./ready.nix;
|
||||
};
|
||||
simulacrum = {
|
||||
enable = true;
|
||||
deps = [ "wireguard" ];
|
||||
settings = ./test.nix;
|
||||
};
|
||||
};
|
||||
|
||||
dns.records."consul-remote.internal".consulService = "consul-remote";
|
||||
|
|
19
cluster/services/consul/test.nix
Normal file
19
cluster/services/consul/test.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
testScript = ''
|
||||
import json
|
||||
|
||||
start_all()
|
||||
|
||||
with subtest("should form cluster"):
|
||||
for machine in machines:
|
||||
machine.succeed("systemctl start consul-ready.service")
|
||||
for machine in machines:
|
||||
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 machines:
|
||||
assert machine2.name in memberList
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue