Test tests/dhcpv4/kea_only/flexid/test_flex_id.py::test_v4_hooks_flexid_reconfigure
failed for me before this fix at line 102:
if presence:
> assert len(world.srvmsg) != 0, "No response received."
E AssertionError: No response received.
E assert 0 != 0
E + where 0 = len([])
E + where [] = <thread._local object at 0x7fcecc6ef950>.srvmsg
When looking at the logs, I can see only 1 DHCP4_PACKET_RECEIVED
instead of 2 and immediately after DHCP4_DYNAMIC_RECONFIGURATION
and DHCP4_CONFIG_COMPLETE
, the server is shutting down DHCPSRV_CLOSE_DB
, DHCP4_SHUTDOWN
. What I think happens is the second offer is sent while the server is reconfiguring, specifically before it has started listening on the interface again. This makes the package drop because nobody is listening on the interface. So instead of sleeping for a few seconds, this wait_for_message_count_in_log
is used to wait for a certain event after which the server returns to normal service. A single wait for DHCP4_CONFIG_COMPLETE
would have sufficed, but I left the wait for DHCP4_DYNAMIC_RECONFIGURATION
to make sure that it is caused by reconfiguration.
I think a good number of sleeps are hacks that could be replaced by this waiting for events. :)