diff options
author | Klement Sekera <ksekera@cisco.com> | 2017-04-19 07:10:58 +0000 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2017-04-20 13:29:09 +0000 |
commit | 3cfa558a24ca19745b248304bf9dc4c69bda342a (patch) | |
tree | d0b1144848886aaaa61dd5733a8d3a3d4b4d2fd9 | |
parent | 48009e4c5732180ecc951ac6359b9b96d38b8dc2 (diff) |
make test: improve bfd reliability
Change-Id: Iaf446a2d7d8e595c3379fb9ed61a954351c17b90
Signed-off-by: Klement Sekera <ksekera@cisco.com>
-rw-r--r-- | test/framework.py | 12 | ||||
-rw-r--r-- | test/test_bfd.py | 48 |
2 files changed, 41 insertions, 19 deletions
diff --git a/test/framework.py b/test/framework.py index f105950ad5a..91915fca447 100644 --- a/test/framework.py +++ b/test/framework.py @@ -648,8 +648,18 @@ class VppTestCase(unittest.TestCase): @classmethod def sleep(cls, timeout, remark=None): if hasattr(cls, 'logger'): - cls.logger.debug("Sleeping for %ss (%s)" % (timeout, remark)) + cls.logger.debug("Starting sleep for %ss (%s)" % (timeout, remark)) + before = time.time() time.sleep(timeout) + after = time.time() + if after - before > 2 * timeout: + cls.logger.error( + "time.sleep() derp! slept for %ss instead of ~%ss!" % ( + after - before, timeout)) + if hasattr(cls, 'logger'): + cls.logger.debug( + "Finished sleep (%s) - slept %ss (wanted %ss)" % ( + remark, after - before, timeout)) class TestCasePrinter(object): diff --git a/test/test_bfd.py b/test/test_bfd.py index e8f8f33849f..925a0f80baa 100644 --- a/test/test_bfd.py +++ b/test/test_bfd.py @@ -1066,13 +1066,13 @@ class BFD4TestCase(VppTestCase): def test_echo(self): """ echo function """ bfd_session_up(self) - self.test_session.update(required_min_echo_rx=50000) + self.test_session.update(required_min_echo_rx=150000) self.test_session.send_packet() detection_time = self.test_session.detect_mult *\ self.vpp_session.required_min_rx / USEC_IN_SEC # echo shouldn't work without echo source set - for dummy in range(3): - sleep = 0.75 * detection_time + for dummy in range(10): + sleep = self.vpp_session.required_min_rx / USEC_IN_SEC self.sleep(sleep, "delay before sending bfd packet") self.test_session.send_packet() p = wait_for_bfd_packet( @@ -1080,7 +1080,9 @@ class BFD4TestCase(VppTestCase): self.assert_equal(p[BFD].required_min_rx_interval, self.vpp_session.required_min_rx, "BFD required min rx interval") + self.test_session.send_packet() self.vapi.bfd_udp_set_echo_source(self.loopback0.sw_if_index) + echo_seen = False # should be turned on - loopback echo packets for dummy in range(3): loop_until = time.time() + 0.75 * detection_time @@ -1098,9 +1100,12 @@ class BFD4TestCase(VppTestCase): p[Ether].dst = self.pg0.local_mac self.pg0.add_stream(p) self.pg_start() + echo_seen = True elif p.haslayer(BFD): - self.assertGreaterEqual(p[BFD].required_min_rx_interval, - 1000000) + if echo_seen: + self.assertGreaterEqual( + p[BFD].required_min_rx_interval, + 1000000) if "P" in p.sprintf("%BFD.flags%"): final = self.test_session.create_packet() final[BFD].flags = "F" @@ -1111,12 +1116,13 @@ class BFD4TestCase(VppTestCase): self.assert_equal(len(self.vapi.collect_events()), 0, "number of bfd events") self.test_session.send_packet() + self.assertTrue(echo_seen, "No echo packets received") @unittest.skipUnless(running_extended_tests(), "part of extended tests") def test_echo_fail(self): """ session goes down if echo function fails """ bfd_session_up(self) - self.test_session.update(required_min_echo_rx=50000) + self.test_session.update(required_min_echo_rx=150000) self.test_session.send_packet() detection_time = self.test_session.detect_mult *\ self.vpp_session.required_min_rx / USEC_IN_SEC @@ -1156,7 +1162,7 @@ class BFD4TestCase(VppTestCase): def test_echo_stop(self): """ echo function stops if peer sets required min echo rx zero """ bfd_session_up(self) - self.test_session.update(required_min_echo_rx=50000) + self.test_session.update(required_min_echo_rx=150000) self.test_session.send_packet() self.vapi.bfd_udp_set_echo_source(self.loopback0.sw_if_index) # wait for first echo packet @@ -1188,7 +1194,7 @@ class BFD4TestCase(VppTestCase): def test_echo_source_removed(self): """ echo function stops if echo source is removed """ bfd_session_up(self) - self.test_session.update(required_min_echo_rx=50000) + self.test_session.update(required_min_echo_rx=150000) self.test_session.send_packet() self.vapi.bfd_udp_set_echo_source(self.loopback0.sw_if_index) # wait for first echo packet @@ -1220,7 +1226,7 @@ class BFD4TestCase(VppTestCase): def test_stale_echo(self): """ stale echo packets don't keep a session up """ bfd_session_up(self) - self.test_session.update(required_min_echo_rx=50000) + self.test_session.update(required_min_echo_rx=150000) self.vapi.bfd_udp_set_echo_source(self.loopback0.sw_if_index) self.test_session.send_packet() # should be turned on - loopback echo packets @@ -1273,7 +1279,7 @@ class BFD4TestCase(VppTestCase): def test_invalid_echo_checksum(self): """ echo packets with invalid checksum don't keep a session up """ bfd_session_up(self) - self.test_session.update(required_min_echo_rx=50000) + self.test_session.update(required_min_echo_rx=150000) self.vapi.bfd_udp_set_echo_source(self.loopback0.sw_if_index) self.test_session.send_packet() # should be turned on - loopback echo packets @@ -1534,15 +1540,15 @@ class BFD6TestCase(VppTestCase): "ECHO packet identifier for test purposes)") def test_echo(self): - """ echo function used """ + """ echo function """ bfd_session_up(self) - self.test_session.update(required_min_echo_rx=50000) + self.test_session.update(required_min_echo_rx=150000) self.test_session.send_packet() detection_time = self.test_session.detect_mult *\ self.vpp_session.required_min_rx / USEC_IN_SEC # echo shouldn't work without echo source set - for dummy in range(3): - sleep = 0.75 * detection_time + for dummy in range(10): + sleep = self.vpp_session.required_min_rx / USEC_IN_SEC self.sleep(sleep, "delay before sending bfd packet") self.test_session.send_packet() p = wait_for_bfd_packet( @@ -1550,7 +1556,9 @@ class BFD6TestCase(VppTestCase): self.assert_equal(p[BFD].required_min_rx_interval, self.vpp_session.required_min_rx, "BFD required min rx interval") + self.test_session.send_packet() self.vapi.bfd_udp_set_echo_source(self.loopback0.sw_if_index) + echo_seen = False # should be turned on - loopback echo packets for dummy in range(3): loop_until = time.time() + 0.75 * detection_time @@ -1568,9 +1576,12 @@ class BFD6TestCase(VppTestCase): p[Ether].dst = self.pg0.local_mac self.pg0.add_stream(p) self.pg_start() + echo_seen = True elif p.haslayer(BFD): - self.assertGreaterEqual(p[BFD].required_min_rx_interval, - 1000000) + if echo_seen: + self.assertGreaterEqual( + p[BFD].required_min_rx_interval, + 1000000) if "P" in p.sprintf("%BFD.flags%"): final = self.test_session.create_packet() final[BFD].flags = "F" @@ -1581,6 +1592,7 @@ class BFD6TestCase(VppTestCase): self.assert_equal(len(self.vapi.collect_events()), 0, "number of bfd events") self.test_session.send_packet() + self.assertTrue(echo_seen, "No echo packets received") class BFDFIBTestCase(VppTestCase): @@ -1619,8 +1631,8 @@ class BFDFIBTestCase(VppTestCase): # packets to match against both of the routes p = [(Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) / - IPv6(src="3001::1", dst="2001::1") / - UDP(sport=1234, dport=1234) / + IPv6(src="3001::1", dst="2001::1") / + UDP(sport=1234, dport=1234) / Raw('\xa5' * 100)), (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) / IPv6(src="3001::1", dst="2002::1") / |