aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2019-01-25 06:37:15 -0800
committerNeale Ranns <nranns@cisco.com>2019-01-31 09:19:52 +0000
commitf6e9b014cbd0ba5a757565a6a0179065d7236463 (patch)
tree6691f8b705461b4e3900ed8eeb1cc587cdfdbe36 /test
parent94519aaed6c1801d1410689c4c6d7823ad7d6357 (diff)
DHCP-test: more robust sleep check
Change-Id: I48c382797239dc305e01cc35124140d6ce16149a Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'test')
-rw-r--r--test/test_dhcp.py21
1 files 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