test/case: add LLDP to same test

This unfortunately required some restructuring, and as well as extending
the run time since we have no way of sending Ethernet frames currently
in the test framework (socat would be nice).

 - Put enable/disable of services before tcpdump start, LLDP lingers ...
 - Extend run time: 3 -> 20 sec to catch periodic LLDP messages

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2023-08-30 10:37:43 +02:00
committed by Tobias Waldekranz
parent 943603b636
commit 31abe00514
+34 -17
View File
@@ -3,6 +3,11 @@
# Verify that basic services like SSDP, mDNS and LLDP can be enabled and
# disabled. We verify operation and non-operation by using tcpdump.
#
# XXX: with socat in the Docker container we could speed up the LLDP
# detection considerably by sending a probe:
#
# echo -ne "\x01\x80\xc2\x00\x00\x0e\x01\x80\xc2\x00\x00\x0e\x88\xcc\x02\x07\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" | socat - UDP4-DATAGRAM:255.255.255.255:7010,broadcast
#
import time
import infamy
@@ -13,25 +18,30 @@ def verify(enabled, sec):
_, hport = env.ltop.xlate("host", "data")
with infamy.IsolatedMacVlan(hport) as netns:
snif = infamy.Sniffer(netns, "port 1900 or port 5353")
snif = infamy.Sniffer(netns, "port 1900 or port 5353 or ether proto 0x88cc")
ssdp = SsdpClient(netns, retries=sec)
netns.addip("10.0.0.1")
netns.addroute("0.0.0.0/0", "10.0.0.1")
# Put service enable/disable before starting tcpdump, because
# LLDP lingers and will send a final shutdown message that
# otherwise would get in the capture for disable.
target.put_config_dict("infix-services", {
"ssdp": {
"enabled": enabled
},
"mdns": {
"enabled": enabled
}
})
target.put_config_dict("ieee802-dot1ab-lldp", {
"lldp": {
"enabled": enabled
}
})
with snif:
target.put_config_dict("infix-services", {
"ssdp": {
"enabled": enabled
},
"mdns": {
"enabled": enabled
}
})
#running = target.get_config_dict("/infix-services:mdns")
#assert running["mdns"]["enabled"] == enabled
ssdp.start()
time.sleep(sec)
ssdp.stop()
@@ -73,24 +83,31 @@ with infamy.Test() as test:
"enabled": False
}
})
cfg = target.get_config_dict("/infix-services:ssdp")
assert not cfg["ssdp"]["enabled"]
target.put_config_dict("ieee802-dot1ab-lldp", {
"lldp": {
"enabled": False
}
})
with test.step("Start sniffer and enable services on target ..."):
rc = verify(True, 3)
rc = verify(True, 20)
print(rc.stdout)
# breakpoint()
if "10.0.0.10.1900 > 10.0.0.1" not in rc.stdout:
test.fail()
if "10.0.0.10.5353" not in rc.stdout:
test.fail()
if "LLDP" not in rc.stdout:
test.fail()
with test.step("Disable services on target, verify they're not running anymore ..."):
rc = verify(False, 3)
rc = verify(False, 20)
print(rc.stdout)
if "10.0.0.10.1900 > 10.0.0.1" in rc.stdout:
test.fail()
if "10.0.0.10.5353" in rc.stdout:
test.fail()
if "LLDP" in rc.stdout:
test.fail()
test.succeed()