Log packets captured by tcpdump on the nodes in case of test failure
In the tests which are using tcpdump to check if traffic is going through the right node(s) there was only check if something was captured or not. But in case of failure we didn't know what was captured what caused issue. Now this patch adds logging of the packets captured on all of the nodes in case if the assertion in test failed. Hopefully that will help debugging issues like in the related bug. Related-bug: #OSPRH-11312 Change-Id: I1025ae0c9dbb50d187b2827a8a7c4de864e35875
This commit is contained in:
parent
77bddb9256
commit
81d9dc6831
@ -97,6 +97,9 @@ class TcpdumpCapture(fixtures.Fixture):
|
||||
return repr(icmp.nexthopmtu)
|
||||
return None
|
||||
|
||||
def get_captured_records(self):
|
||||
return [str(r) for r in rdpcap(self._open_capture_file())]
|
||||
|
||||
def _open_capture_file(self):
|
||||
if not self.capture_files:
|
||||
raise ValueError('No capture files available')
|
||||
|
@ -1129,6 +1129,17 @@ class TrafficFlowTest(BaseTempestWhiteboxTestCase):
|
||||
if node.get('capture'):
|
||||
node['capture'].stop()
|
||||
|
||||
def _log_captured_packets(self):
|
||||
for node in self.nodes:
|
||||
capture = node.get('capture')
|
||||
if capture is None or capture.is_empty():
|
||||
captured_packets = "No packets captured"
|
||||
else:
|
||||
captured_packets = "\n ".join(
|
||||
capture.get_captured_records())
|
||||
LOG.debug("Node: %s; Packets captured: %s",
|
||||
node["short_name"], captured_packets)
|
||||
|
||||
def check_east_west_icmp_flow(
|
||||
self, dst_ip, expected_routing_nodes, expected_macs, ssh_client):
|
||||
"""Check that traffic routed as expected within a tenant network
|
||||
@ -1172,7 +1183,11 @@ class TrafficFlowTest(BaseTempestWhiteboxTestCase):
|
||||
not node['capture'].is_empty())]
|
||||
LOG.debug('Actual routing nodes: %s',
|
||||
','.join(actual_routing_nodes))
|
||||
self.assertCountEqual(expected_routing_nodes, actual_routing_nodes)
|
||||
try:
|
||||
self.assertCountEqual(expected_routing_nodes, actual_routing_nodes)
|
||||
except AssertionError:
|
||||
self._log_captured_packets()
|
||||
raise
|
||||
|
||||
def check_north_south_icmp_flow(
|
||||
self, dst_ip, expected_routing_nodes, expected_mac, ssh_client,
|
||||
@ -1217,7 +1232,11 @@ class TrafficFlowTest(BaseTempestWhiteboxTestCase):
|
||||
not node['capture'].is_empty())]
|
||||
LOG.debug('Actual routing nodes: %s',
|
||||
','.join(actual_routing_nodes))
|
||||
self.assertCountEqual(expected_routing_nodes, actual_routing_nodes)
|
||||
try:
|
||||
self.assertCountEqual(expected_routing_nodes, actual_routing_nodes)
|
||||
except AssertionError:
|
||||
self._log_captured_packets()
|
||||
raise
|
||||
|
||||
|
||||
class BaseTempestTestCaseOvn(BaseTempestWhiteboxTestCase):
|
||||
|
Loading…
x
Reference in New Issue
Block a user