diff --git a/ansible/roles/test/files/ptftests/py3/dhcp_relay_stress_test.py b/ansible/roles/test/files/ptftests/py3/dhcp_relay_stress_test.py index ad1bc934169..2ce23ef893d 100644 --- a/ansible/roles/test/files/ptftests/py3/dhcp_relay_stress_test.py +++ b/ansible/roles/test/files/ptftests/py3/dhcp_relay_stress_test.py @@ -51,15 +51,18 @@ def setUp(self): DHCPTest.setUp(self) self.packets_send_duration = self.test_params["packets_send_duration"] self.client_packets_per_sec = self.test_params["client_packets_per_sec"] + self.count_file = self.test_params.get("count_file") def client_send_packet_stress(self): + if not self.count_file: + self.count_file = "/tmp/dhcp_stress_test_{}".format(self.packet_type) # Start tcpdump on each receive-port interface individually to avoid # issues with '-i any' cooked capture (SLL/SLLv2), deep BPF offsets # (udp[249:2]), and grep-based interface filtering. log_files = [] tcpdump_procs = [] for idx in self.receive_port_indices: - log_file = "/tmp/dhcp_stress_{}_{}.log".format(self.packet_type, idx) + log_file = "{}_eth{}.log".format(self.count_file, idx) log_files.append(log_file) # Match only the DHCP message-type under test so background/other-type # DHCP traffic cannot inflate the relayed-packet count. message-type @@ -119,7 +122,7 @@ def client_send_packet_stress(self): # File already removed or never created; nothing to clean up pass - with open("/tmp/dhcp_stress_test_{}".format(self.packet_type), "w") as count_fh: + with open(self.count_file, "w") as count_fh: count_fh.write("{}\n".format(total_count)) def runTest(self): diff --git a/tests/dhcp_relay/test_dhcp_relay_stress.py b/tests/dhcp_relay/test_dhcp_relay_stress.py index 8b8a951089a..53e96a66a64 100644 --- a/tests/dhcp_relay/test_dhcp_relay_stress.py +++ b/tests/dhcp_relay/test_dhcp_relay_stress.py @@ -1,6 +1,7 @@ import pytest import time import logging +import uuid import ptf.packet as scapy from tests.common.fixtures.ptfhost_utils import copy_ptftests_directory # noqa F401 @@ -180,7 +181,8 @@ def test_dhcp_relay_stress(ptfhost, ptfadapter, dut_dhcp_relay_data, validate_du "relay_agent": relay_agent, "kvm_support": True } - count_file = '/tmp/dhcp_stress_test_{}'.format(dhcp_type) + count_file = '/tmp/dhcp_stress_test_{}_{}'.format(dhcp_type, uuid.uuid4().hex) + params["count_file"] = count_file def _check_count_file_exists(): command = 'ls {} > /dev/null 2>&1 && echo exists || echo missing'.format(count_file)