mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-06 07:33:01 +02:00
test/case: update ipv4-autoconf with new test passes
- Add check for specific 169.254/16 adddress (new feature) - Add check for disabling autoconf on interface (regression test #638) Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
=== IPv4 linklocal
|
||||
=== IPv4 link-local
|
||||
|
||||
==== Description
|
||||
Verifies that linklocal (ZeroConf) work as expected
|
||||
|
||||
==== Topology
|
||||
|
||||
ifdef::topdoc[]
|
||||
image::../../test/case/ietf_interfaces/ipv4_autoconf/topology.png[IPv4 linklocal topology]
|
||||
image::../../test/case/ietf_interfaces/ipv4_autoconf/topology.png[IPv4 link-local topology]
|
||||
endif::topdoc[]
|
||||
ifndef::topdoc[]
|
||||
ifdef::testgroup[]
|
||||
@@ -14,11 +16,14 @@ ifndef::testgroup[]
|
||||
image::topology.png[IPv4 linklocal topology]
|
||||
endif::testgroup[]
|
||||
endif::topdoc[]
|
||||
|
||||
==== Test sequence
|
||||
. Initialize
|
||||
. Configure an interface with IPv4 ZeroConf IP
|
||||
. Wait for linklocal address on interface
|
||||
. Verify link local address exist on target:mgmt
|
||||
. Configure target:mgmt with a specific IPv4 ZeroConf IP
|
||||
. Verify target:mgmt has link local address 169.254.42.42
|
||||
. Remove IPv4 link-local addresses from target:mgmt
|
||||
|
||||
|
||||
<<<
|
||||
|
||||
|
||||
@@ -3,24 +3,46 @@
|
||||
# PC ---- e0: 10.0.0.2
|
||||
#
|
||||
"""
|
||||
IPv4 linklocal
|
||||
IPv4 link-local
|
||||
|
||||
Verifies that linklocal (ZeroConf) work as expected
|
||||
Verifies that link-local (IPv4LL/ZeroConf) address assignment work as
|
||||
expected. Checks random address, the request-address setting, and
|
||||
address removal on autoconf disable.
|
||||
"""
|
||||
import ipaddress
|
||||
import infamy
|
||||
import time
|
||||
import infamy.iface
|
||||
|
||||
from infamy.util import until
|
||||
|
||||
def has_linklocal(target, iface):
|
||||
"""Check if interface as a linklocal address"""
|
||||
|
||||
def has_linklocal(target, iface, request=None):
|
||||
"""Check if interface as a link-local address"""
|
||||
addrs = infamy.iface.get_ipv4_address(target, iface)
|
||||
if not addrs:
|
||||
return False
|
||||
for addr in addrs:
|
||||
if addr['origin'] == "random":
|
||||
return True
|
||||
if request is None:
|
||||
print(f"Got IP address {addr['ip']}")
|
||||
return True
|
||||
if addr['ip'] == request:
|
||||
print(f"Got requested IP address {addr['ip']}")
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def no_linklocal(target, iface):
|
||||
"""Check if interface has no link-local address in the 169.254/16 range"""
|
||||
addrs = infamy.iface.get_ipv4_address(target, iface)
|
||||
if not addrs:
|
||||
return True
|
||||
for addr in addrs:
|
||||
ip = ipaddress.IPv4Address(addr['ip'])
|
||||
if ip in ipaddress.IPv4Network('169.254.0.0/16'):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
with infamy.Test() as test:
|
||||
with test.step("Initialize"):
|
||||
@@ -46,7 +68,37 @@ with infamy.Test() as test:
|
||||
}
|
||||
})
|
||||
|
||||
with test.step("Wait for linklocal address on interface"):
|
||||
until(lambda: has_linklocal(target, tport), attempts=30)
|
||||
with test.step("Verify link local address exist on target:mgmt"):
|
||||
until(lambda: has_linklocal(target, tport), attempts=30)
|
||||
|
||||
with test.step("Configure target:mgmt with a specific IPv4 ZeroConf IP"):
|
||||
_, tport = env.ltop.xlate("target", "data")
|
||||
|
||||
target.put_config_dict("ietf-interfaces", {
|
||||
"interfaces": {
|
||||
"interface": [
|
||||
{
|
||||
"name": tport,
|
||||
"enabled": True,
|
||||
"ipv4": {
|
||||
"autoconf": {
|
||||
"enabled": True,
|
||||
"request-address": "169.254.42.42"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
with test.step("Verify target:mgmt has link local address 169.254.42.42"):
|
||||
until(lambda: has_linklocal(target, tport, request="169.254.42.42"),
|
||||
attempts=30)
|
||||
|
||||
with test.step("Remove IPv4 link-local addresses from target:mgmt"):
|
||||
xpath = f"/ietf-interfaces:interfaces/interface[name='{tport}']" \
|
||||
"/ietf-ip:ipv4/infix-ip:autoconf"
|
||||
target.delete_xpath(xpath)
|
||||
until(lambda: no_linklocal(target, tport), attempts=30)
|
||||
|
||||
test.succeed()
|
||||
|
||||
Reference in New Issue
Block a user