From f6e9b014cbd0ba5a757565a6a0179065d7236463 Mon Sep 17 00:00:00 2001 From: Neale Ranns Date: Fri, 25 Jan 2019 06:37:15 -0800 Subject: [PATCH] DHCP-test: more robust sleep check Change-Id: I48c382797239dc305e01cc35124140d6ce16149a Signed-off-by: Neale Ranns --- test/test_dhcp.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/test/test_dhcp.py b/test/test_dhcp.py index 833ee00a529..d1af9fd9e7d 100644 --- a/test/test_dhcp.py +++ b/test/test_dhcp.py @@ -360,6 +360,16 @@ class TestDHCP(VppTestCase): # not sure why this is not decoding # adv = pkt[DHCP6_Advertise] + def wait_for_no_route(self, address, length, + n_tries=50, s_time=1): + while (n_tries): + if not find_route(self, address, length): + return True + n_tries = n_tries - 1 + self.sleep(s_time) + + return False + def test_dhcp_proxy(self): """ DHCPv4 Proxy """ @@ -1535,15 +1545,10 @@ class TestDHCP(VppTestCase): is_add=0) # - # Sleep for the lease time - # - self.sleep(lease_time+1) - + # the route should be gone after the lease expires # - # And now the route should be gone - # - self.assertFalse(find_route(self, self.pg3.local_ip4, 32)) - self.assertFalse(find_route(self, self.pg3.local_ip4, 24)) + self.assertTrue(self.wait_for_no_route(self.pg3.local_ip4, 32)) + self.assertTrue(self.wait_for_no_route(self.pg3.local_ip4, 24)) # # remove the DHCP config -- 2.16.6