diff options
author | Andrew Yourtchenko <ayourtch@gmail.com> | 2019-10-13 18:56:03 +0000 |
---|---|---|
committer | Andrew Yourtchenko <ayourtch@gmail.com> | 2019-11-05 10:31:18 +0000 |
commit | 92a5fdd6849a2788ae42d7d09a6f2838413a9dfb (patch) | |
tree | 136bcad59d66314c44f5ea1e3b8bf07a08d4d05c | |
parent | 5cd73e6d927d45d6129b04ad07b8e6623da83e47 (diff) |
tests: make RA tests run on VPP time
the IPv6 RA tests take timing into the account,
but the time inside VPP may go slightly differently compared
to the time inside the driving python thread,
if the machine running the tests is heavily loaded.
Make a sleep function which sleeps "on VPP time" and use it.
Change-Id: I3b34b0164f6e0ec7a619b92ee308089a4a8935e3
Type: test
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
(cherry picked from commit 63cb8827e586f02f53512d23a8e7596fe9c19aa8)
-rw-r--r-- | test/framework.py | 14 | ||||
-rw-r--r-- | test/test_ip6.py | 14 |
2 files changed, 21 insertions, 7 deletions
diff --git a/test/framework.py b/test/framework.py index bfd848c145c..a1e5e16eb3a 100644 --- a/test/framework.py +++ b/test/framework.py @@ -742,6 +742,20 @@ class VppTestCase(unittest.TestCase): cls._captures.append((time.time(), cap_name)) @classmethod + def get_vpp_time(cls): + return float(cls.vapi.cli('show clock').replace("Time now ", "")) + + @classmethod + def sleep_on_vpp_time(cls, sec): + """ Sleep according to time in VPP world """ + # On a busy system with many processes + # we might end up with VPP time being slower than real world + # So take that into account when waiting for VPP to do something + start_time = cls.get_vpp_time() + while cls.get_vpp_time() - start_time < sec: + cls.sleep(0.1) + + @classmethod def pg_start(cls): """ Enable the PG, wait till it is done, then clean up """ cls.vapi.cli("trace add pg-input 1000") diff --git a/test/test_ip6.py b/test/test_ip6.py index f2c4c00424e..b1a3d050c10 100644 --- a/test/test_ip6.py +++ b/test/test_ip6.py @@ -1299,7 +1299,7 @@ class TestIPv6RDControlPlane(TestIPv6ND): self.pg0.add_stream([packet]) self.pg_start() - self.sleep(0.1) + self.sleep_on_vpp_time(0.1) fib = self.vapi.ip_route_dump(0, True) @@ -1323,21 +1323,21 @@ class TestIPv6RDControlPlane(TestIPv6ND): self.pg0.add_stream([packet]) self.pg_start() - self.sleep(0.1) + self.sleep_on_vpp_time(0.1) # check that default route is deleted fib = self.vapi.ip_route_dump(0, True) default_routes = self.get_default_routes(fib) self.assertEqual(len(default_routes), 0) - self.sleep(0.1) + self.sleep_on_vpp_time(0.1) # send RA packet = self.create_ra_packet(self.pg0) self.pg0.add_stream([packet]) self.pg_start() - self.sleep(0.1) + self.sleep_on_vpp_time(0.1) # check FIB for new default route fib = self.vapi.ip_route_dump(0, True) @@ -1352,7 +1352,7 @@ class TestIPv6RDControlPlane(TestIPv6ND): self.pg0.add_stream([packet]) self.pg_start() - self.sleep(0.1) + self.sleep_on_vpp_time(0.1) # check that default route still exists fib = self.vapi.ip_route_dump(0, True) @@ -1362,7 +1362,7 @@ class TestIPv6RDControlPlane(TestIPv6ND): self.assertEqual(dr['sw_if_index'], self.pg0.sw_if_index) self.assertEqual(dr['next_hop'], router_address) - self.sleep(1) + self.sleep_on_vpp_time(1) # check that default route is deleted fib = self.vapi.ip_route_dump(0, True) @@ -1378,7 +1378,7 @@ class TestIPv6RDControlPlane(TestIPv6ND): strict=False) self.assertEqual(prefix, IPv6Network(text_type('1::/20'))) - self.sleep(1) + self.sleep_on_vpp_time(1) # check that SLAAC address is deleted fib = self.vapi.ip_route_dump(0, True) |