From c35c3a203bea297a2dd7b49a3c32c2bc24f9cfdf Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 13 Aug 2024 18:51:26 +0200 Subject: [PATCH] cluster/services/wireguard: test in simulacrum --- cluster/services/wireguard/default.nix | 4 ++++ cluster/services/wireguard/test.nix | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 cluster/services/wireguard/test.nix diff --git a/cluster/services/wireguard/default.nix b/cluster/services/wireguard/default.nix index 54b893a..b3ba747 100644 --- a/cluster/services/wireguard/default.nix +++ b/cluster/services/wireguard/default.nix @@ -93,5 +93,9 @@ in nodes = config.services.wireguard.nodes.mesh; shared = false; }; + simulacrum = { + enable = true; + settings = ./test.nix; + }; }; } diff --git a/cluster/services/wireguard/test.nix b/cluster/services/wireguard/test.nix new file mode 100644 index 0000000..dfa7e92 --- /dev/null +++ b/cluster/services/wireguard/test.nix @@ -0,0 +1,26 @@ +{ cluster, lib, ... }: + +{ + testScript = '' + start_all() + ${lib.pipe cluster.config.services.wireguard.nodes.mesh [ + (map (node: /*python*/ '' + ${node}.wait_for_unit("wireguard-wgmesh.target") + '')) + (lib.concatStringsSep "\n") + ]} + + ${lib.pipe cluster.config.services.wireguard.nodes.mesh [ + (map (node: /*python*/ '' + with subtest("${node} can reach all other nodes"): + ${lib.pipe (cluster.config.services.wireguard.otherNodes.mesh node) [ + (map (peer: /*python*/ '' + ${node}.succeed("ping -c3 ${cluster.config.hostLinks.${peer}.mesh.extra.meshIp}") + '')) + (lib.concatStringsSep "\n ") + ]} + '')) + (lib.concatStringsSep "\n") + ]} + ''; +}