From 40a27ed8e72e3ac29dd4e703a488ffdc1cd16b1a Mon Sep 17 00:00:00 2001 From: Sizhe Zhao Date: Sat, 7 Jun 2025 21:43:30 +0800 Subject: [PATCH] nixosTests.flannel: handleTest -> runTest --- nixos/tests/all-tests.nix | 2 +- nixos/tests/flannel.nix | 102 +++++++++++++++++--------------------- 2 files changed, 47 insertions(+), 57 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index d204d2155d1c..1aa54c48d472 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -530,7 +530,7 @@ in }; fish = runTest ./fish.nix; firezone = runTest ./firezone/firezone.nix; - flannel = handleTestOn [ "x86_64-linux" ] ./flannel.nix { }; + flannel = runTestOn [ "x86_64-linux" ] ./flannel.nix; flaresolverr = runTest ./flaresolverr.nix; flood = runTest ./flood.nix; floorp = runTest { diff --git a/nixos/tests/flannel.nix b/nixos/tests/flannel.nix index 738558e64afc..9bcd920bdc70 100644 --- a/nixos/tests/flannel.nix +++ b/nixos/tests/flannel.nix @@ -1,66 +1,56 @@ -import ./make-test-python.nix ( - { lib, ... }: - { - name = "flannel"; +{ lib, ... }: +{ + name = "flannel"; - meta = with lib.maintainers; { - maintainers = [ offline ]; - }; + meta.maintainers = with lib.maintainers; [ offline ]; - nodes = - let - flannelConfig = - { pkgs, ... }: - { - services.flannel = { - enable = true; - backend = { - Type = "udp"; - Port = 8285; - }; - network = "10.1.0.0/16"; - iface = "eth1"; - etcd.endpoints = [ "http://etcd:2379" ]; - }; - - networking.firewall.allowedUDPPorts = [ 8285 ]; + nodes = + let + flannelConfig = { + services.flannel = { + enable = true; + backend = { + Type = "udp"; + Port = 8285; }; - in - { - etcd = - { ... }: - { - services = { - etcd = { - enable = true; - listenClientUrls = [ "http://0.0.0.0:2379" ]; # requires ip-address for binding - listenPeerUrls = [ "http://0.0.0.0:2380" ]; # requires ip-address for binding - advertiseClientUrls = [ "http://etcd:2379" ]; - initialAdvertisePeerUrls = [ "http://etcd:2379" ]; - initialCluster = [ "etcd=http://etcd:2379" ]; - }; - }; + network = "10.1.0.0/16"; + iface = "eth1"; + etcd.endpoints = [ "http://etcd:2379" ]; + }; - networking.firewall.allowedTCPPorts = [ 2379 ]; - }; + networking.firewall.allowedUDPPorts = [ 8285 ]; + }; + in + { + etcd = { + services.etcd = { + enable = true; + listenClientUrls = [ "http://0.0.0.0:2379" ]; # requires ip-address for binding + listenPeerUrls = [ "http://0.0.0.0:2380" ]; # requires ip-address for binding + advertiseClientUrls = [ "http://etcd:2379" ]; + initialAdvertisePeerUrls = [ "http://etcd:2379" ]; + initialCluster = [ "etcd=http://etcd:2379" ]; + }; - node1 = flannelConfig; - node2 = flannelConfig; + networking.firewall.allowedTCPPorts = [ 2379 ]; }; - testScript = '' - start_all() + node1 = flannelConfig; + node2 = flannelConfig; + }; - node1.wait_for_unit("flannel.service") - node2.wait_for_unit("flannel.service") + testScript = '' + start_all() - node1.wait_until_succeeds("ip l show dev flannel0") - ip1 = node1.succeed("ip -4 addr show flannel0 | grep -oP '(?<=inet).*(?=/)'") - node2.wait_until_succeeds("ip l show dev flannel0") - ip2 = node2.succeed("ip -4 addr show flannel0 | grep -oP '(?<=inet).*(?=/)'") + node1.wait_for_unit("flannel.service") + node2.wait_for_unit("flannel.service") - node1.wait_until_succeeds(f"ping -c 1 {ip2}") - node2.wait_until_succeeds(f"ping -c 1 {ip1}") - ''; - } -) + node1.wait_until_succeeds("ip l show dev flannel0") + ip1 = node1.succeed("ip -4 addr show flannel0 | grep -oP '(?<=inet).*(?=/)'") + node2.wait_until_succeeds("ip l show dev flannel0") + ip2 = node2.succeed("ip -4 addr show flannel0 | grep -oP '(?<=inet).*(?=/)'") + + node1.wait_until_succeeds(f"ping -c 1 {ip2}") + node2.wait_until_succeeds(f"ping -c 1 {ip1}") + ''; +}