diff --git a/cluster/services/consul/default.nix b/cluster/services/consul/default.nix index d7855b6..ee4e374 100644 --- a/cluster/services/consul/default.nix +++ b/cluster/services/consul/default.nix @@ -22,6 +22,11 @@ in ]; ready = ./ready.nix; }; + simulacrum = { + enable = true; + deps = [ "wireguard" ]; + settings = ./test.nix; + }; }; dns.records."consul-remote.internal".consulService = "consul-remote"; diff --git a/cluster/services/consul/test.nix b/cluster/services/consul/test.nix new file mode 100644 index 0000000..3a279bb --- /dev/null +++ b/cluster/services/consul/test.nix @@ -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 + ''; +}