Skip to content

Commit

Permalink
Update all port pfcwd storm test to make is more stable
Browse files Browse the repository at this point in the history
1. Optimize background traffic
2. Optimize pfcwd polling interval
3. Fix arp resolve issue
4. Remove ptf leftovers added in pfcwd test

Change-Id: I5e0a5f4157bd0e22f5bc2f28df977bfccb679603
  • Loading branch information
echuawu committed Dec 4, 2024
1 parent 518b26b commit 091eb73
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
9 changes: 4 additions & 5 deletions tests/common/helpers/pfcwd_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,13 @@ def start_background_traffic(


@contextlib.contextmanager
def send_background_traffic(duthost, ptfhost, storm_hndle, selected_test_ports, test_ports_info):
def send_background_traffic(duthost, ptfhost, storm_hndle, selected_test_ports, test_ports_info, pkt_count=100000):
"""Send background traffic, stop the background traffic when the context finish """
if is_mellanox_device(duthost) or is_cisco_device(duthost):
background_traffic_params = _prepare_background_traffic_params(duthost, storm_hndle,
selected_test_ports,
test_ports_info)
test_ports_info,
pkt_count)
background_traffic_log = _send_background_traffic(ptfhost, background_traffic_params)
# Ensure the background traffic is running before moving on
time.sleep(1)
Expand All @@ -503,7 +504,7 @@ def send_background_traffic(duthost, ptfhost, storm_hndle, selected_test_ports,
_stop_background_traffic(ptfhost, background_traffic_log)


def _prepare_background_traffic_params(duthost, queues, selected_test_ports, test_ports_info):
def _prepare_background_traffic_params(duthost, queues, selected_test_ports, test_ports_info, pkt_count):
src_ports = []
dst_ports = []
src_ips = []
Expand All @@ -519,8 +520,6 @@ def _prepare_background_traffic_params(duthost, queues, selected_test_ports, tes
src_ips.append(selected_test_port_info["rx_neighbor_addr"])

router_mac = duthost.get_dut_iface_mac(selected_test_ports[0])
# Send enough packets to make sure the background traffic is running during the test
pkt_count = 100000

ptf_params = {'router_mac': router_mac,
'src_ports': src_ports,
Expand Down
15 changes: 15 additions & 0 deletions tests/pfcwd/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,18 @@ def pfcwd_pause_service(ptfhost):
needs_resume["garp_service"] = False

logger.debug("pause_service needs_resume {}".format(needs_resume))


@pytest.fixture(scope='module', autouse=True)
def clear_ptf_ip_addr(duthosts, ptfhost, enum_rand_one_per_hwsku_frontend_hostname):
"""
Fixture that remove ip address of ethX interface at ptf and clear arp at dut
:param duthosts: dut instance
:param ptfhost: ptf instance
:return: None
"""
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
yield
logger.info("Remove ip address of ethX interface at PTF")
ptfhost.script("./scripts/remove_ip.sh")
duthost.command("sonic-clear arp")
22 changes: 20 additions & 2 deletions tests/pfcwd/test_pfcwd_all_port_storm.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,23 @@ def set_storm_params(duthost, fanout_graph, fanouthosts, peer_params):
return storm_hndle


def resolve_arp(duthost, ptfhost, test_ports_info):
"""
Populate ARP info for the DUT vlan port
Args:
ptfhost: ptf host instance
test_ports_info: test ports information
"""
for port, port_info in test_ports_info.items():
if port_info['test_port_type'] == 'vlan':
neighbor_ip = port_info['test_neighbor_addr']
ptf_port = f"eth{port_info['test_port_id']}"
ptfhost.command(f"ifconfig {ptf_port} {neighbor_ip}")
duthost.command(f"docker exec -i swss arping {neighbor_ip} -c 5")
break


@pytest.mark.usefixtures('degrade_pfcwd_detection', 'stop_pfcwd', 'storm_test_setup_restore', 'start_background_traffic') # noqa E501
class TestPfcwdAllPortStorm(object):
""" PFC storm test class """
Expand Down Expand Up @@ -229,8 +246,9 @@ def test_all_port_storm_restore(self, duthosts, enum_rand_one_per_hwsku_frontend
test_port = device_conn[intf]['peerport']
if test_port in setup_pfc_test['test_ports']:
selected_test_ports.append(test_port)

with send_background_traffic(duthost, ptfhost, queues, selected_test_ports, setup_pfc_test['test_ports']):
resolve_arp(duthost, ptfhost, setup_pfc_test['test_ports'])
with send_background_traffic(duthost, ptfhost, queues, selected_test_ports, setup_pfc_test['test_ports'],
pkt_count=500):
self.run_test(duthost,
storm_hndle,
expect_regex=[EXPECT_PFC_WD_DETECT_RE + fetch_vendor_specific_diagnosis_re(duthost)],
Expand Down

0 comments on commit 091eb73

Please sign in to comment.