nixosTests.networking: Port tests to python
This commit is contained in:
parent
5425557214
commit
98d562f0b3
1 changed files with 225 additions and 204 deletions
|
@ -4,7 +4,7 @@
|
|||
# bool: whether to use networkd in the tests
|
||||
, networkd }:
|
||||
|
||||
with import ../lib/testing.nix { inherit system pkgs; };
|
||||
with import ../lib/testing-python.nix { inherit system pkgs; };
|
||||
with pkgs.lib;
|
||||
|
||||
let
|
||||
|
@ -75,10 +75,11 @@ let
|
|||
machine.networking.useDHCP = false;
|
||||
machine.networking.useNetworkd = networkd;
|
||||
testScript = ''
|
||||
startAll;
|
||||
$machine->waitForUnit("network.target");
|
||||
$machine->succeed("ip addr show lo | grep -q 'inet 127.0.0.1/8 '");
|
||||
$machine->succeed("ip addr show lo | grep -q 'inet6 ::1/128 '");
|
||||
start_all()
|
||||
machine.wait_for_unit("network.target")
|
||||
loopback_addresses = machine.succeed("ip addr show lo")
|
||||
assert "inet 127.0.0.1/8" in loopback_addresses
|
||||
assert "inet6 ::1/128" in loopback_addresses
|
||||
'';
|
||||
};
|
||||
static = {
|
||||
|
@ -102,35 +103,35 @@ let
|
|||
};
|
||||
testScript = { ... }:
|
||||
''
|
||||
startAll;
|
||||
start_all()
|
||||
|
||||
$client->waitForUnit("network.target");
|
||||
$router->waitForUnit("network-online.target");
|
||||
client.wait_for_unit("network.target")
|
||||
router.wait_for_unit("network-online.target")
|
||||
|
||||
# Make sure dhcpcd is not started
|
||||
$client->fail("systemctl status dhcpcd.service");
|
||||
with subtest("Make sure dhcpcd is not started"):
|
||||
client.fail("systemctl status dhcpcd.service")
|
||||
|
||||
# Test vlan 1
|
||||
$client->waitUntilSucceeds("ping -c 1 192.168.1.1");
|
||||
$client->waitUntilSucceeds("ping -c 1 192.168.1.2");
|
||||
$client->waitUntilSucceeds("ping -c 1 192.168.1.3");
|
||||
$client->waitUntilSucceeds("ping -c 1 192.168.1.10");
|
||||
with subtest("Test vlan 1"):
|
||||
client.wait_until_succeeds("ping -c 1 192.168.1.1")
|
||||
client.wait_until_succeeds("ping -c 1 192.168.1.2")
|
||||
client.wait_until_succeeds("ping -c 1 192.168.1.3")
|
||||
client.wait_until_succeeds("ping -c 1 192.168.1.10")
|
||||
|
||||
$router->waitUntilSucceeds("ping -c 1 192.168.1.1");
|
||||
$router->waitUntilSucceeds("ping -c 1 192.168.1.2");
|
||||
$router->waitUntilSucceeds("ping -c 1 192.168.1.3");
|
||||
$router->waitUntilSucceeds("ping -c 1 192.168.1.10");
|
||||
router.wait_until_succeeds("ping -c 1 192.168.1.1")
|
||||
router.wait_until_succeeds("ping -c 1 192.168.1.2")
|
||||
router.wait_until_succeeds("ping -c 1 192.168.1.3")
|
||||
router.wait_until_succeeds("ping -c 1 192.168.1.10")
|
||||
|
||||
# Test vlan 2
|
||||
$client->waitUntilSucceeds("ping -c 1 192.168.2.1");
|
||||
$client->waitUntilSucceeds("ping -c 1 192.168.2.2");
|
||||
with subtest("Test vlan 2"):
|
||||
client.wait_until_succeeds("ping -c 1 192.168.2.1")
|
||||
client.wait_until_succeeds("ping -c 1 192.168.2.2")
|
||||
|
||||
$router->waitUntilSucceeds("ping -c 1 192.168.2.1");
|
||||
$router->waitUntilSucceeds("ping -c 1 192.168.2.2");
|
||||
router.wait_until_succeeds("ping -c 1 192.168.2.1")
|
||||
router.wait_until_succeeds("ping -c 1 192.168.2.2")
|
||||
|
||||
# Test default gateway
|
||||
$router->waitUntilSucceeds("ping -c 1 192.168.3.1");
|
||||
$client->waitUntilSucceeds("ping -c 1 192.168.3.1");
|
||||
with subtest("Test default gateway"):
|
||||
router.wait_until_succeeds("ping -c 1 192.168.3.1")
|
||||
client.wait_until_succeeds("ping -c 1 192.168.3.1")
|
||||
'';
|
||||
};
|
||||
dhcpSimple = {
|
||||
|
@ -155,38 +156,38 @@ let
|
|||
};
|
||||
testScript = { ... }:
|
||||
''
|
||||
startAll;
|
||||
start_all()
|
||||
|
||||
$client->waitForUnit("network.target");
|
||||
$router->waitForUnit("network-online.target");
|
||||
client.wait_for_unit("network.target")
|
||||
router.wait_for_unit("network-online.target")
|
||||
|
||||
# Wait until we have an ip address on each interface
|
||||
$client->waitUntilSucceeds("ip addr show dev eth1 | grep -q '192.168.1'");
|
||||
$client->waitUntilSucceeds("ip addr show dev eth1 | grep -q 'fd00:1234:5678:1:'");
|
||||
$client->waitUntilSucceeds("ip addr show dev eth2 | grep -q '192.168.2'");
|
||||
$client->waitUntilSucceeds("ip addr show dev eth2 | grep -q 'fd00:1234:5678:2:'");
|
||||
with subtest("Wait until we have an ip address on each interface"):
|
||||
client.wait_until_succeeds("ip addr show dev eth1 | grep -q '192.168.1'")
|
||||
client.wait_until_succeeds("ip addr show dev eth1 | grep -q 'fd00:1234:5678:1:'")
|
||||
client.wait_until_succeeds("ip addr show dev eth2 | grep -q '192.168.2'")
|
||||
client.wait_until_succeeds("ip addr show dev eth2 | grep -q 'fd00:1234:5678:2:'")
|
||||
|
||||
# Test vlan 1
|
||||
$client->waitUntilSucceeds("ping -c 1 192.168.1.1");
|
||||
$client->waitUntilSucceeds("ping -c 1 192.168.1.2");
|
||||
$client->waitUntilSucceeds("ping -c 1 fd00:1234:5678:1::1");
|
||||
$client->waitUntilSucceeds("ping -c 1 fd00:1234:5678:1::2");
|
||||
with subtest("Test vlan 1"):
|
||||
client.wait_until_succeeds("ping -c 1 192.168.1.1")
|
||||
client.wait_until_succeeds("ping -c 1 192.168.1.2")
|
||||
client.wait_until_succeeds("ping -c 1 fd00:1234:5678:1::1")
|
||||
client.wait_until_succeeds("ping -c 1 fd00:1234:5678:1::2")
|
||||
|
||||
$router->waitUntilSucceeds("ping -c 1 192.168.1.1");
|
||||
$router->waitUntilSucceeds("ping -c 1 192.168.1.2");
|
||||
$router->waitUntilSucceeds("ping -c 1 fd00:1234:5678:1::1");
|
||||
$router->waitUntilSucceeds("ping -c 1 fd00:1234:5678:1::2");
|
||||
router.wait_until_succeeds("ping -c 1 192.168.1.1")
|
||||
router.wait_until_succeeds("ping -c 1 192.168.1.2")
|
||||
router.wait_until_succeeds("ping -c 1 fd00:1234:5678:1::1")
|
||||
router.wait_until_succeeds("ping -c 1 fd00:1234:5678:1::2")
|
||||
|
||||
# Test vlan 2
|
||||
$client->waitUntilSucceeds("ping -c 1 192.168.2.1");
|
||||
$client->waitUntilSucceeds("ping -c 1 192.168.2.2");
|
||||
$client->waitUntilSucceeds("ping -c 1 fd00:1234:5678:2::1");
|
||||
$client->waitUntilSucceeds("ping -c 1 fd00:1234:5678:2::2");
|
||||
with subtest("Test vlan 2"):
|
||||
client.wait_until_succeeds("ping -c 1 192.168.2.1")
|
||||
client.wait_until_succeeds("ping -c 1 192.168.2.2")
|
||||
client.wait_until_succeeds("ping -c 1 fd00:1234:5678:2::1")
|
||||
client.wait_until_succeeds("ping -c 1 fd00:1234:5678:2::2")
|
||||
|
||||
$router->waitUntilSucceeds("ping -c 1 192.168.2.1");
|
||||
$router->waitUntilSucceeds("ping -c 1 192.168.2.2");
|
||||
$router->waitUntilSucceeds("ping -c 1 fd00:1234:5678:2::1");
|
||||
$router->waitUntilSucceeds("ping -c 1 fd00:1234:5678:2::2");
|
||||
router.wait_until_succeeds("ping -c 1 192.168.2.1")
|
||||
router.wait_until_succeeds("ping -c 1 192.168.2.2")
|
||||
router.wait_until_succeeds("ping -c 1 fd00:1234:5678:2::1")
|
||||
router.wait_until_succeeds("ping -c 1 fd00:1234:5678:2::2")
|
||||
'';
|
||||
};
|
||||
dhcpOneIf = {
|
||||
|
@ -206,28 +207,28 @@ let
|
|||
};
|
||||
testScript = { ... }:
|
||||
''
|
||||
startAll;
|
||||
start_all()
|
||||
|
||||
# Wait for networking to come up
|
||||
$client->waitForUnit("network.target");
|
||||
$router->waitForUnit("network.target");
|
||||
with subtest("Wait for networking to come up"):
|
||||
client.wait_for_unit("network.target")
|
||||
router.wait_for_unit("network.target")
|
||||
|
||||
# Wait until we have an ip address on each interface
|
||||
$client->waitUntilSucceeds("ip addr show dev eth1 | grep -q '192.168.1'");
|
||||
with subtest("Wait until we have an ip address on each interface"):
|
||||
client.wait_until_succeeds("ip addr show dev eth1 | grep -q '192.168.1'")
|
||||
|
||||
# Test vlan 1
|
||||
$client->waitUntilSucceeds("ping -c 1 192.168.1.1");
|
||||
$client->waitUntilSucceeds("ping -c 1 192.168.1.2");
|
||||
with subtest("Test vlan 1"):
|
||||
client.wait_until_succeeds("ping -c 1 192.168.1.1")
|
||||
client.wait_until_succeeds("ping -c 1 192.168.1.2")
|
||||
|
||||
$router->waitUntilSucceeds("ping -c 1 192.168.1.1");
|
||||
$router->waitUntilSucceeds("ping -c 1 192.168.1.2");
|
||||
router.wait_until_succeeds("ping -c 1 192.168.1.1")
|
||||
router.wait_until_succeeds("ping -c 1 192.168.1.2")
|
||||
|
||||
# Test vlan 2
|
||||
$client->waitUntilSucceeds("ping -c 1 192.168.2.1");
|
||||
$client->fail("ping -c 1 192.168.2.2");
|
||||
with subtest("Test vlan 2"):
|
||||
client.wait_until_succeeds("ping -c 1 192.168.2.1")
|
||||
client.fail("ping -c 1 192.168.2.2")
|
||||
|
||||
$router->waitUntilSucceeds("ping -c 1 192.168.2.1");
|
||||
$router->fail("ping -c 1 192.168.2.2");
|
||||
router.wait_until_succeeds("ping -c 1 192.168.2.1")
|
||||
router.fail("ping -c 1 192.168.2.2")
|
||||
'';
|
||||
};
|
||||
bond = let
|
||||
|
@ -252,18 +253,18 @@ let
|
|||
nodes.client2 = node "192.168.1.2";
|
||||
testScript = { ... }:
|
||||
''
|
||||
startAll;
|
||||
start_all()
|
||||
|
||||
# Wait for networking to come up
|
||||
$client1->waitForUnit("network.target");
|
||||
$client2->waitForUnit("network.target");
|
||||
with subtest("Wait for networking to come up"):
|
||||
client1.wait_for_unit("network.target")
|
||||
client2.wait_for_unit("network.target")
|
||||
|
||||
# Test bonding
|
||||
$client1->waitUntilSucceeds("ping -c 2 192.168.1.1");
|
||||
$client1->waitUntilSucceeds("ping -c 2 192.168.1.2");
|
||||
with subtest("Test bonding"):
|
||||
client1.wait_until_succeeds("ping -c 2 192.168.1.1")
|
||||
client1.wait_until_succeeds("ping -c 2 192.168.1.2")
|
||||
|
||||
$client2->waitUntilSucceeds("ping -c 2 192.168.1.1");
|
||||
$client2->waitUntilSucceeds("ping -c 2 192.168.1.2");
|
||||
client2.wait_until_succeeds("ping -c 2 192.168.1.1")
|
||||
client2.wait_until_succeeds("ping -c 2 192.168.1.2")
|
||||
'';
|
||||
};
|
||||
bridge = let
|
||||
|
@ -294,25 +295,24 @@ let
|
|||
};
|
||||
testScript = { ... }:
|
||||
''
|
||||
startAll;
|
||||
start_all()
|
||||
|
||||
# Wait for networking to come up
|
||||
$client1->waitForUnit("network.target");
|
||||
$client2->waitForUnit("network.target");
|
||||
$router->waitForUnit("network.target");
|
||||
with subtest("Wait for networking to come up"):
|
||||
for machine in client1, client2, router:
|
||||
machine.wait_for_unit("network.target")
|
||||
|
||||
# Test bridging
|
||||
$client1->waitUntilSucceeds("ping -c 1 192.168.1.1");
|
||||
$client1->waitUntilSucceeds("ping -c 1 192.168.1.2");
|
||||
$client1->waitUntilSucceeds("ping -c 1 192.168.1.3");
|
||||
with subtest("Test bridging"):
|
||||
client1.wait_until_succeeds("ping -c 1 192.168.1.1")
|
||||
client1.wait_until_succeeds("ping -c 1 192.168.1.2")
|
||||
client1.wait_until_succeeds("ping -c 1 192.168.1.3")
|
||||
|
||||
$client2->waitUntilSucceeds("ping -c 1 192.168.1.1");
|
||||
$client2->waitUntilSucceeds("ping -c 1 192.168.1.2");
|
||||
$client2->waitUntilSucceeds("ping -c 1 192.168.1.3");
|
||||
client2.wait_until_succeeds("ping -c 1 192.168.1.1")
|
||||
client2.wait_until_succeeds("ping -c 1 192.168.1.2")
|
||||
client2.wait_until_succeeds("ping -c 1 192.168.1.3")
|
||||
|
||||
$router->waitUntilSucceeds("ping -c 1 192.168.1.1");
|
||||
$router->waitUntilSucceeds("ping -c 1 192.168.1.2");
|
||||
$router->waitUntilSucceeds("ping -c 1 192.168.1.3");
|
||||
router.wait_until_succeeds("ping -c 1 192.168.1.1")
|
||||
router.wait_until_succeeds("ping -c 1 192.168.1.2")
|
||||
router.wait_until_succeeds("ping -c 1 192.168.1.3")
|
||||
'';
|
||||
};
|
||||
macvlan = {
|
||||
|
@ -340,35 +340,35 @@ let
|
|||
};
|
||||
testScript = { ... }:
|
||||
''
|
||||
startAll;
|
||||
start_all()
|
||||
|
||||
# Wait for networking to come up
|
||||
$client->waitForUnit("network.target");
|
||||
$router->waitForUnit("network.target");
|
||||
with subtest("Wait for networking to come up"):
|
||||
client.wait_for_unit("network.target")
|
||||
router.wait_for_unit("network.target")
|
||||
|
||||
# Wait until we have an ip address on each interface
|
||||
$client->waitUntilSucceeds("ip addr show dev eth1 | grep -q '192.168.1'");
|
||||
$client->waitUntilSucceeds("ip addr show dev macvlan | grep -q '192.168.1'");
|
||||
with subtest("Wait until we have an ip address on each interface"):
|
||||
client.wait_until_succeeds("ip addr show dev eth1 | grep -q '192.168.1'")
|
||||
client.wait_until_succeeds("ip addr show dev macvlan | grep -q '192.168.1'")
|
||||
|
||||
# Print lots of diagnostic information
|
||||
$router->log('**********************************************');
|
||||
$router->succeed("ip addr >&2");
|
||||
$router->succeed("ip route >&2");
|
||||
$router->execute("iptables-save >&2");
|
||||
$client->log('==============================================');
|
||||
$client->succeed("ip addr >&2");
|
||||
$client->succeed("ip route >&2");
|
||||
$client->execute("iptables-save >&2");
|
||||
$client->log('##############################################');
|
||||
with subtest("Print lots of diagnostic information"):
|
||||
router.log("**********************************************")
|
||||
router.succeed("ip addr >&2")
|
||||
router.succeed("ip route >&2")
|
||||
router.execute("iptables-save >&2")
|
||||
client.log("==============================================")
|
||||
client.succeed("ip addr >&2")
|
||||
client.succeed("ip route >&2")
|
||||
client.execute("iptables-save >&2")
|
||||
client.log("##############################################")
|
||||
|
||||
# Test macvlan creates routable ips
|
||||
$client->waitUntilSucceeds("ping -c 1 192.168.1.1");
|
||||
$client->waitUntilSucceeds("ping -c 1 192.168.1.2");
|
||||
$client->waitUntilSucceeds("ping -c 1 192.168.1.3");
|
||||
with subtest("Test macvlan creates routable ips"):
|
||||
client.wait_until_succeeds("ping -c 1 192.168.1.1")
|
||||
client.wait_until_succeeds("ping -c 1 192.168.1.2")
|
||||
client.wait_until_succeeds("ping -c 1 192.168.1.3")
|
||||
|
||||
$router->waitUntilSucceeds("ping -c 1 192.168.1.1");
|
||||
$router->waitUntilSucceeds("ping -c 1 192.168.1.2");
|
||||
$router->waitUntilSucceeds("ping -c 1 192.168.1.3");
|
||||
router.wait_until_succeeds("ping -c 1 192.168.1.1")
|
||||
router.wait_until_succeeds("ping -c 1 192.168.1.2")
|
||||
router.wait_until_succeeds("ping -c 1 192.168.1.3")
|
||||
'';
|
||||
};
|
||||
sit = let
|
||||
|
@ -395,22 +395,22 @@ let
|
|||
nodes.client2 = node { address4 = "192.168.1.2"; remote = "192.168.1.1"; address6 = "fc00::2"; };
|
||||
testScript = { ... }:
|
||||
''
|
||||
startAll;
|
||||
start_all()
|
||||
|
||||
# Wait for networking to be configured
|
||||
$client1->waitForUnit("network.target");
|
||||
$client2->waitForUnit("network.target");
|
||||
with subtest("Wait for networking to be configured"):
|
||||
client1.wait_for_unit("network.target")
|
||||
client2.wait_for_unit("network.target")
|
||||
|
||||
# Print diagnostic information
|
||||
$client1->succeed("ip addr >&2");
|
||||
$client2->succeed("ip addr >&2");
|
||||
# Print diagnostic information
|
||||
client1.succeed("ip addr >&2")
|
||||
client2.succeed("ip addr >&2")
|
||||
|
||||
# Test ipv6
|
||||
$client1->waitUntilSucceeds("ping -c 1 fc00::1");
|
||||
$client1->waitUntilSucceeds("ping -c 1 fc00::2");
|
||||
with subtest("Test ipv6"):
|
||||
client1.wait_until_succeeds("ping -c 1 fc00::1")
|
||||
client1.wait_until_succeeds("ping -c 1 fc00::2")
|
||||
|
||||
$client2->waitUntilSucceeds("ping -c 1 fc00::1");
|
||||
$client2->waitUntilSucceeds("ping -c 1 fc00::2");
|
||||
client2.wait_until_succeeds("ping -c 1 fc00::1")
|
||||
client2.wait_until_succeeds("ping -c 1 fc00::2")
|
||||
'';
|
||||
};
|
||||
vlan = let
|
||||
|
@ -435,15 +435,15 @@ let
|
|||
nodes.client2 = node "192.168.1.2";
|
||||
testScript = { ... }:
|
||||
''
|
||||
startAll;
|
||||
start_all()
|
||||
|
||||
# Wait for networking to be configured
|
||||
$client1->waitForUnit("network.target");
|
||||
$client2->waitForUnit("network.target");
|
||||
with subtest("Wait for networking to be configured"):
|
||||
client1.wait_for_unit("network.target")
|
||||
client2.wait_for_unit("network.target")
|
||||
|
||||
# Test vlan is setup
|
||||
$client1->succeed("ip addr show dev vlan >&2");
|
||||
$client2->succeed("ip addr show dev vlan >&2");
|
||||
with subtest("Test vlan is setup"):
|
||||
client1.succeed("ip addr show dev vlan >&2")
|
||||
client2.succeed("ip addr show dev vlan >&2")
|
||||
'';
|
||||
};
|
||||
virtual = {
|
||||
|
@ -464,33 +464,38 @@ let
|
|||
};
|
||||
|
||||
testScript = ''
|
||||
my $targetList = <<'END';
|
||||
targetList = """
|
||||
tap0: tap persist user 0
|
||||
tun0: tun persist user 0
|
||||
END
|
||||
""".strip()
|
||||
|
||||
# Wait for networking to come up
|
||||
$machine->start;
|
||||
$machine->waitForUnit("network-online.target");
|
||||
with subtest("Wait for networking to come up"):
|
||||
machine.start()
|
||||
machine.wait_for_unit("network-online.target")
|
||||
|
||||
# Test interfaces set up
|
||||
my $list = $machine->succeed("ip tuntap list | sort");
|
||||
"$list" eq "$targetList" or die(
|
||||
"The list of virtual interfaces does not match the expected one:\n",
|
||||
"Result:\n", "$list\n",
|
||||
"Expected:\n", "$targetList\n"
|
||||
);
|
||||
with subtest("Test interfaces set up"):
|
||||
list = machine.succeed("ip tuntap list | sort").strip()
|
||||
assert (
|
||||
list == targetList
|
||||
), """
|
||||
The list of virtual interfaces does not match the expected one:
|
||||
Result:
|
||||
{}
|
||||
Expected:
|
||||
{}
|
||||
""".format(
|
||||
list, targetList
|
||||
)
|
||||
|
||||
# Test interfaces clean up
|
||||
$machine->succeed("systemctl stop network-addresses-tap0");
|
||||
$machine->sleep(10);
|
||||
$machine->succeed("systemctl stop network-addresses-tun0");
|
||||
$machine->sleep(10);
|
||||
my $residue = $machine->succeed("ip tuntap list");
|
||||
$residue eq "" or die(
|
||||
"Some virtual interface has not been properly cleaned:\n",
|
||||
"$residue\n"
|
||||
);
|
||||
with subtest("Test interfaces clean up"):
|
||||
machine.succeed("systemctl stop network-addresses-tap0")
|
||||
machine.sleep(10)
|
||||
machine.succeed("systemctl stop network-addresses-tun0")
|
||||
machine.sleep(10)
|
||||
residue = machine.succeed("ip tuntap list")
|
||||
assert (
|
||||
residue is ""
|
||||
), "Some virtual interface has not been properly cleaned:\n{}".format(residue)
|
||||
'';
|
||||
};
|
||||
privacy = {
|
||||
|
@ -522,7 +527,7 @@ let
|
|||
'';
|
||||
};
|
||||
};
|
||||
nodes.clientWithPrivacy = { pkgs, ... }: with pkgs.lib; {
|
||||
nodes.client_with_privacy = { pkgs, ... }: with pkgs.lib; {
|
||||
virtualisation.vlans = [ 1 ];
|
||||
networking = {
|
||||
useNetworkd = networkd;
|
||||
|
@ -550,25 +555,31 @@ let
|
|||
};
|
||||
testScript = { ... }:
|
||||
''
|
||||
startAll;
|
||||
start_all()
|
||||
|
||||
$client->waitForUnit("network.target");
|
||||
$clientWithPrivacy->waitForUnit("network.target");
|
||||
$router->waitForUnit("network-online.target");
|
||||
client.wait_for_unit("network.target")
|
||||
client_with_privacy.wait_for_unit("network.target")
|
||||
router.wait_for_unit("network-online.target")
|
||||
|
||||
# Wait until we have an ip address
|
||||
$clientWithPrivacy->waitUntilSucceeds("ip addr show dev eth1 | grep -q 'fd00:1234:5678:1:'");
|
||||
$client->waitUntilSucceeds("ip addr show dev eth1 | grep -q 'fd00:1234:5678:1:'");
|
||||
with subtest("Wait until we have an ip address"):
|
||||
client_with_privacy.wait_until_succeeds(
|
||||
"ip addr show dev eth1 | grep -q 'fd00:1234:5678:1:'"
|
||||
)
|
||||
client.wait_until_succeeds("ip addr show dev eth1 | grep -q 'fd00:1234:5678:1:'")
|
||||
|
||||
# Test vlan 1
|
||||
$clientWithPrivacy->waitUntilSucceeds("ping -c 1 fd00:1234:5678:1::1");
|
||||
$client->waitUntilSucceeds("ping -c 1 fd00:1234:5678:1::1");
|
||||
with subtest("Test vlan 1"):
|
||||
client_with_privacy.wait_until_succeeds("ping -c 1 fd00:1234:5678:1::1")
|
||||
client.wait_until_succeeds("ping -c 1 fd00:1234:5678:1::1")
|
||||
|
||||
# Test address used is temporary
|
||||
$clientWithPrivacy->waitUntilSucceeds("! ip route get fd00:1234:5678:1::1 | grep -q ':[a-f0-9]*ff:fe[a-f0-9]*:'");
|
||||
with subtest("Test address used is temporary"):
|
||||
client_with_privacy.wait_until_succeeds(
|
||||
"! ip route get fd00:1234:5678:1::1 | grep -q ':[a-f0-9]*ff:fe[a-f0-9]*:'"
|
||||
)
|
||||
|
||||
# Test address used is EUI-64
|
||||
$client->waitUntilSucceeds("ip route get fd00:1234:5678:1::1 | grep -q ':[a-f0-9]*ff:fe[a-f0-9]*:'");
|
||||
with subtest("Test address used is EUI-64"):
|
||||
client.wait_until_succeeds(
|
||||
"ip route get fd00:1234:5678:1::1 | grep -q ':[a-f0-9]*ff:fe[a-f0-9]*:'"
|
||||
)
|
||||
'';
|
||||
};
|
||||
routes = {
|
||||
|
@ -591,47 +602,57 @@ let
|
|||
};
|
||||
|
||||
testScript = ''
|
||||
my $targetIPv4Table = <<'END';
|
||||
targetIPv4Table = """
|
||||
10.0.0.0/16 proto static scope link mtu 1500
|
||||
192.168.1.0/24 proto kernel scope link src 192.168.1.2
|
||||
192.168.2.0/24 via 192.168.1.1 proto static
|
||||
END
|
||||
""".strip()
|
||||
|
||||
my $targetIPv6Table = <<'END';
|
||||
targetIPv6Table = """
|
||||
2001:1470:fffd:2097::/64 proto kernel metric 256 pref medium
|
||||
2001:1470:fffd:2098::/64 via fdfd:b3f0::1 proto static metric 1024 pref medium
|
||||
fdfd:b3f0::/48 proto static metric 1024 pref medium
|
||||
END
|
||||
""".strip()
|
||||
|
||||
$machine->start;
|
||||
$machine->waitForUnit("network.target");
|
||||
machine.start()
|
||||
machine.wait_for_unit("network.target")
|
||||
|
||||
# test routing tables
|
||||
my $ipv4Table = $machine->succeed("ip -4 route list dev eth0 | head -n3");
|
||||
my $ipv6Table = $machine->succeed("ip -6 route list dev eth0 | head -n3");
|
||||
"$ipv4Table" eq "$targetIPv4Table" or die(
|
||||
"The IPv4 routing table does not match the expected one:\n",
|
||||
"Result:\n", "$ipv4Table\n",
|
||||
"Expected:\n", "$targetIPv4Table\n"
|
||||
);
|
||||
"$ipv6Table" eq "$targetIPv6Table" or die(
|
||||
"The IPv6 routing table does not match the expected one:\n",
|
||||
"Result:\n", "$ipv6Table\n",
|
||||
"Expected:\n", "$targetIPv6Table\n"
|
||||
);
|
||||
with subtest("test routing tables"):
|
||||
ipv4Table = machine.succeed("ip -4 route list dev eth0 | head -n3").strip()
|
||||
ipv6Table = machine.succeed("ip -6 route list dev eth0 | head -n3").strip()
|
||||
assert (
|
||||
ipv4Table == targetIPv4Table
|
||||
), """
|
||||
The IPv4 routing table does not match the expected one:
|
||||
Result:
|
||||
{}
|
||||
Expected:
|
||||
{}
|
||||
""".format(
|
||||
ipv4Table, targetIPv4Table
|
||||
)
|
||||
assert (
|
||||
ipv6Table == targetIPv6Table
|
||||
), """
|
||||
The IPv6 routing table does not match the expected one:
|
||||
Result:
|
||||
{}
|
||||
Expected:
|
||||
{}
|
||||
""".format(
|
||||
ipv6Table, targetIPv6Table
|
||||
)
|
||||
|
||||
# test clean-up of the tables
|
||||
$machine->succeed("systemctl stop network-addresses-eth0");
|
||||
my $ipv4Residue = $machine->succeed("ip -4 route list dev eth0 | head -n-3");
|
||||
my $ipv6Residue = $machine->succeed("ip -6 route list dev eth0 | head -n-3");
|
||||
$ipv4Residue eq "" or die(
|
||||
"The IPv4 routing table has not been properly cleaned:\n",
|
||||
"$ipv4Residue\n"
|
||||
);
|
||||
$ipv6Residue eq "" or die(
|
||||
"The IPv6 routing table has not been properly cleaned:\n",
|
||||
"$ipv6Residue\n"
|
||||
);
|
||||
with subtest("test clean-up of the tables"):
|
||||
machine.succeed("systemctl stop network-addresses-eth0")
|
||||
ipv4Residue = machine.succeed("ip -4 route list dev eth0 | head -n-3").strip()
|
||||
ipv6Residue = machine.succeed("ip -6 route list dev eth0 | head -n-3").strip()
|
||||
assert (
|
||||
ipv4Residue is ""
|
||||
), "The IPv4 routing table has not been properly cleaned:\n{}".format(ipv4Residue)
|
||||
assert (
|
||||
ipv6Residue is ""
|
||||
), "The IPv6 routing table has not been properly cleaned:\n{}".format(ipv6Residue)
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue