From 0f0aaa517ce760d65c69f7e3efdc69461d252669 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 18 Mar 2024 17:40:30 +0100 Subject: [PATCH] nixos/tests/mycelium: init --- nixos/tests/all-tests.nix | 1 + nixos/tests/mycelium/default.nix | 57 ++++++++++++++++++++++++++++++++ nixos/tests/mycelium/peer1.key | 1 + nixos/tests/mycelium/peer2.key | 1 + 4 files changed, 60 insertions(+) create mode 100644 nixos/tests/mycelium/default.nix create mode 100644 nixos/tests/mycelium/peer1.key create mode 100644 nixos/tests/mycelium/peer2.key diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index dd6c744a79ce..faff759f76c0 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -561,6 +561,7 @@ in { munin = handleTest ./munin.nix {}; mutableUsers = handleTest ./mutable-users.nix {}; mxisd = handleTest ./mxisd.nix {}; + mycelium = handleTest ./mycelium {}; mympd = handleTest ./mympd.nix {}; mysql = handleTest ./mysql/mysql.nix {}; mysql-autobackup = handleTest ./mysql/mysql-autobackup.nix {}; diff --git a/nixos/tests/mycelium/default.nix b/nixos/tests/mycelium/default.nix new file mode 100644 index 000000000000..f0d72436843c --- /dev/null +++ b/nixos/tests/mycelium/default.nix @@ -0,0 +1,57 @@ +import ../make-test-python.nix ({ lib, ... }: let + peer1-ip = "531:c350:28c1:dfde:ea6d:77d1:a60b:7209"; + peer2-ip = "49f:3942:3a55:d100:4c78:c558:c4f:695b"; +in + { + name = "mycelium"; + meta.maintainers = with lib.maintainers; [ lassulus ]; + + nodes = { + + peer1 = { config, pkgs, ... }: { + virtualisation.vlans = [ 1 ]; + networking.interfaces.eth1.ipv4.addresses = [{ + address = "192.168.1.11"; + prefixLength = 24; + }]; + + services.mycelium = { + enable = true; + addHostedPublicNodes = false; + openFirewall = true; + keyFile = ./peer1.key; + peers = [ + "quic://192.168.1.12:9651" + "tcp://192.168.1.12:9651" + ]; + }; + }; + + peer2 = { config, pkgs, ... }: { + virtualisation.vlans = [ 1 ]; + networking.interfaces.eth1.ipv4.addresses = [{ + address = "192.168.1.12"; + prefixLength = 24; + }]; + + services.mycelium = { + enable = true; + addHostedPublicNodes = false; + openFirewall = true; + keyFile = ./peer2.key; + }; + }; + }; + + testScript = '' + start_all() + + peer1.wait_for_unit("network-online.target") + peer2.wait_for_unit("network-online.target") + peer1.wait_for_unit("mycelium.service") + peer2.wait_for_unit("mycelium.service") + + peer1.succeed("ping -c5 ${peer2-ip}") + peer2.succeed("ping -c5 ${peer1-ip}") + ''; + }) diff --git a/nixos/tests/mycelium/peer1.key b/nixos/tests/mycelium/peer1.key new file mode 100644 index 000000000000..db1cf9e72fe4 --- /dev/null +++ b/nixos/tests/mycelium/peer1.key @@ -0,0 +1 @@ +s B0dRH5u?^ \ No newline at end of file diff --git a/nixos/tests/mycelium/peer2.key b/nixos/tests/mycelium/peer2.key new file mode 100644 index 000000000000..7e757de48efb --- /dev/null +++ b/nixos/tests/mycelium/peer2.key @@ -0,0 +1 @@ +X1yGՅSAMe 7] \ No newline at end of file