[tests] fix the unstable Cert_5_3_03 (#2317)

This commit is contained in:
rongli
2017-11-06 08:58:49 -08:00
committed by Jonathan Hui
parent 4b02d8e2ee
commit 27a30c7209
@@ -108,9 +108,12 @@ class Cert_5_3_3_AddressQuery(unittest.TestCase):
self.assertEqual(self.nodes[DUT_ROUTER2].get_state(), 'router')
self.assertEqual(self.nodes[ROUTER3].get_state(), 'router')
self.assertEqual(self.nodes[MED1].get_state(), 'child')
dut_messages = self.sniffer.get_messages_sent_by(DUT_ROUTER2)
# 2
# Flush the message queue to avoid possible impact on follow-up verification.
dut_messages = self.sniffer.get_messages_sent_by(DUT_ROUTER2)
router3_mleid = self.nodes[ROUTER3].get_ip6_address(config.ADDRESS_TYPE.ML_EID)
self.assertTrue(self.nodes[MED1].ping(router3_mleid))
@@ -120,6 +123,12 @@ class Cert_5_3_3_AddressQuery(unittest.TestCase):
command.check_address_query(msg, self.nodes[DUT_ROUTER2], config.REALM_LOCAL_ALL_ROUTERS_ADDRESS)
# 3
# Wait the finish of address resolution traffic triggerred by previous ping.
time.sleep(5)
# Flush the message queue to avoid possible impact on follow-up verification.
dut_messages = self.sniffer.get_messages_sent_by(DUT_ROUTER2)
med1_mleid = self.nodes[MED1].get_ip6_address(config.ADDRESS_TYPE.ML_EID)
self.assertTrue(self.nodes[ROUTER1].ping(med1_mleid))
@@ -129,7 +138,12 @@ class Cert_5_3_3_AddressQuery(unittest.TestCase):
command.check_address_notification(msg, self.nodes[DUT_ROUTER2], self.nodes[ROUTER1])
# 4
# Wait the finish of address resolution traffic triggerred by previous ping.
time.sleep(5)
# Flush the message queue to avoid possible impact on follow-up verification.
dut_messages = self.sniffer.get_messages_sent_by(DUT_ROUTER2)
self.assertTrue(self.nodes[MED1].ping(router3_mleid))
# Verify DUT_ROUTER2 didn't send an Address Query Request.
@@ -138,12 +152,15 @@ class Cert_5_3_3_AddressQuery(unittest.TestCase):
assert msg is None, "The Address Query Request is not expected."
# 5
dut_messages = self.sniffer.get_messages_sent_by(DUT_ROUTER2)
self.nodes[ROUTER3].stop()
# Wait for the Leader to expire its Router ID.
# MAX_NEIGHBOR_AGE + INFINITE_COST_TIMEOUT + ID_REUSE_DELAY + propagation time + transmission time ~ 580s.
time.sleep(580)
# Flush the message queue to avoid possible impact on follow-up verification.
dut_messages = self.sniffer.get_messages_sent_by(DUT_ROUTER2)
self.assertFalse(self.nodes[MED1].ping(router3_mleid))
# Verify DUT_ROUTER2 sent an Address Query Request to the Realm local address.
@@ -154,6 +171,10 @@ class Cert_5_3_3_AddressQuery(unittest.TestCase):
# 6
self.nodes[MED1].stop()
time.sleep(MED1_TIMEOUT)
# Flush the message queue to avoid possible impact on follow-up verification.
dut_messages = self.sniffer.get_messages_sent_by(DUT_ROUTER2)
self.assertFalse(self.nodes[ROUTER1].ping(med1_mleid))
self.assertFalse(self.nodes[ROUTER1].ping(med1_mleid))