nixosTests.flannel: handleTest -> runTest

This commit is contained in:
Sizhe Zhao 2025-06-07 21:43:30 +08:00
parent bb76321386
commit 40a27ed8e7
No known key found for this signature in database
GPG Key ID: ED1807251A7DA08F
2 changed files with 47 additions and 57 deletions

View File

@ -530,7 +530,7 @@ in
}; };
fish = runTest ./fish.nix; fish = runTest ./fish.nix;
firezone = runTest ./firezone/firezone.nix; firezone = runTest ./firezone/firezone.nix;
flannel = handleTestOn [ "x86_64-linux" ] ./flannel.nix { }; flannel = runTestOn [ "x86_64-linux" ] ./flannel.nix;
flaresolverr = runTest ./flaresolverr.nix; flaresolverr = runTest ./flaresolverr.nix;
flood = runTest ./flood.nix; flood = runTest ./flood.nix;
floorp = runTest { floorp = runTest {

View File

@ -1,66 +1,56 @@
import ./make-test-python.nix ( { lib, ... }:
{ lib, ... }: {
{ name = "flannel";
name = "flannel";
meta = with lib.maintainers; { meta.maintainers = with lib.maintainers; [ offline ];
maintainers = [ offline ];
};
nodes = nodes =
let let
flannelConfig = flannelConfig = {
{ pkgs, ... }: services.flannel = {
{ enable = true;
services.flannel = { backend = {
enable = true; Type = "udp";
backend = { Port = 8285;
Type = "udp";
Port = 8285;
};
network = "10.1.0.0/16";
iface = "eth1";
etcd.endpoints = [ "http://etcd:2379" ];
};
networking.firewall.allowedUDPPorts = [ 8285 ];
}; };
in network = "10.1.0.0/16";
{ iface = "eth1";
etcd = etcd.endpoints = [ "http://etcd:2379" ];
{ ... }: };
{
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" ];
};
};
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; networking.firewall.allowedTCPPorts = [ 2379 ];
node2 = flannelConfig;
}; };
testScript = '' node1 = flannelConfig;
start_all() node2 = flannelConfig;
};
node1.wait_for_unit("flannel.service") testScript = ''
node2.wait_for_unit("flannel.service") start_all()
node1.wait_until_succeeds("ip l show dev flannel0") node1.wait_for_unit("flannel.service")
ip1 = node1.succeed("ip -4 addr show flannel0 | grep -oP '(?<=inet).*(?=/)'") node2.wait_for_unit("flannel.service")
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}") node1.wait_until_succeeds("ip l show dev flannel0")
node2.wait_until_succeeds(f"ping -c 1 {ip1}") 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}")
'';
}