Skip to content

Commit

Permalink
test_gh668: fix failure on LXD VMs (#801)
Browse files Browse the repository at this point in the history
In LXD containers, the default interface is named eth0.  In VMs, it
isn't; it's renamed by systemd (likely to enp5s0, but we can't rely on
that).  This means that, on VMs, the network configuration we specify
for "eth0" doesn't match an interface in the system and so is not
applied.

This modifies the test to set a MAC address in a match clause in the
network configuration and on the eth0 interface (which is the LXD name
in both containers and VMs pre-rename): this ensures that the specified
configuration applies in both cases.
  • Loading branch information
OddBloke committed Feb 5, 2021
1 parent 3cebe0d commit 3a0a589
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/integration_tests/bugs/test_gh668.py
Expand Up @@ -12,6 +12,7 @@

DESTINATION_IP = "172.16.0.10"
GATEWAY_IP = "10.0.0.100"
MAC_ADDRESS = "de:ad:be:ef:12:34"

NETWORK_CONFIG = """\
version: 2
Expand All @@ -22,7 +23,9 @@
routes:
- to: {}/32
via: {}
""".format(DESTINATION_IP, GATEWAY_IP)
match:
macaddress: {}
""".format(DESTINATION_IP, GATEWAY_IP, MAC_ADDRESS)

EXPECTED_ROUTE = "{} via {}".format(DESTINATION_IP, GATEWAY_IP)

Expand All @@ -31,6 +34,7 @@
@pytest.mark.lxd_vm
@pytest.mark.lxd_config_dict({
"user.network-config": NETWORK_CONFIG,
"volatile.eth0.hwaddr": MAC_ADDRESS,
})
def test_static_route_to_host(client: IntegrationInstance):
route = client.execute("ip route | grep {}".format(DESTINATION_IP))
Expand Down

0 comments on commit 3a0a589

Please sign in to comment.