mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-05 23:23:02 +02:00
To reduce the duplication of effort between 9pm and the Infamy framework this change consolidates the move from local 'infamy: title:' extension to 9pm 'name:'. For the parameterized tunnel tests we leverage the 9pm dynamic test-spec variable, which looks for a correspodning <case>.adoc instead of static Readme.adoc, when generating the test report. Each test documentation should cover all aspects of the test, much like the usage text of a UNIX program. To this end, the tunnel test docs are now more spelled out, including all invariants. Some refactoring of these tests were also necessary, e.g., replacing any reserved Python keywords like 'type', and other PEP-8 fixes. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
85 lines
2.4 KiB
Python
Executable File
85 lines
2.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""LLDP enable/disable
|
|
|
|
Verify that LLDP can be enabled and disabled.
|
|
Operation and non-operation are confirmed using tcpdump.
|
|
|
|
"""
|
|
import time
|
|
import infamy
|
|
|
|
with infamy.Test() as test:
|
|
with test.step("Set up topology and attach to target DUT"):
|
|
env = infamy.Env()
|
|
target = env.attach("target", "mgmt")
|
|
_, hdata = env.ltop.xlate("host", "data")
|
|
|
|
with test.step("Enable target interface and disable LLDP"):
|
|
target.put_config_dicts({
|
|
"ietf-interfaces": {
|
|
"interfaces": {
|
|
"interface": [
|
|
{
|
|
"name": target["data"],
|
|
"enabled": True
|
|
}
|
|
]
|
|
}
|
|
}
|
|
})
|
|
|
|
target.put_config_dicts({
|
|
"ieee802-dot1ab-lldp": {
|
|
"lldp": {
|
|
"enabled": False
|
|
}
|
|
}
|
|
})
|
|
|
|
sniffing_period = 10
|
|
|
|
def verify(enabled, sec):
|
|
"""Verify lldp traffic, or no traffic if lldp is disabled."""
|
|
|
|
with infamy.IsolatedMacVlan(hdata) as netns:
|
|
snif = infamy.Sniffer(netns, "ether proto 0x88cc")
|
|
act = "enabling" if enabled else "disabling"
|
|
|
|
target.put_config_dicts({
|
|
"ieee802-dot1ab-lldp": {
|
|
"lldp": {
|
|
"enabled": enabled
|
|
}
|
|
}
|
|
})
|
|
|
|
if enabled:
|
|
target.put_config_dicts({
|
|
"ieee802-dot1ab-lldp": {
|
|
"lldp": {
|
|
"message-tx-interval": 1
|
|
}
|
|
}
|
|
})
|
|
|
|
with snif:
|
|
print("host: collecting network traffic ...")
|
|
print(f"target: {act} LLDP service ...")
|
|
time.sleep(sec)
|
|
|
|
return snif.output()
|
|
|
|
with test.step("Enable LLDP"):
|
|
rc = verify(True, sniffing_period)
|
|
with test.step("Verify LLDP packets arrival on host:data"):
|
|
if "LLDP" not in rc.stdout:
|
|
test.fail()
|
|
|
|
with test.step("Disable LLDP"):
|
|
rc = verify(False, sniffing_period)
|
|
with test.step("Verify no LLDP packets on host:data"):
|
|
if "LLDP" in rc.stdout:
|
|
test.fail()
|
|
|
|
test.succeed()
|