Merge "Log packets captured by tcpdump on the nodes in case of test failure"
This commit is contained in:
commit
3429e220a5
@ -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