Skip to content

Commit 1eb3bbf

Browse files
vivekverma-aristavidyac86
authored andcommitted
Fix flakiness in pfcwd/test_pfcwd_cli.py (sonic-net#19969)
What is the motivation for this PR? Recent fix: sonic-net#17411 The test was flaky before this fix (and continues to be so). When the test picks up an egress interface which happens to be a member of a LAG consisting of multiple members, only this member is stormed and some of the traffic successfully egresses out of the other LAG members leading to lesser drops than expected when PFCWD is triggered with DROP action. The proposed fix was to shut down all but one LAG members by reducing the number of min_links. But the same config on cEOS was missing therefore LAG doesn't come up after shutting down other LAG members. This is being rectified in this change for cEOS neighbors. How did you do it? The proposed fix is to change the min_link setting for the involved port channel on the cEOS side as well. How did you verify/test it? Stressed this test 10 times on dualtor-120 and t0-116 with Arista 7260CX3 platform.
1 parent cd50602 commit 1eb3bbf

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

tests/pfcwd/test_pfcwd_cli.py

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from tests.common.utilities import wait_until
1717
from tests.common.cisco_data import is_cisco_device
1818
from tests.common import config_reload
19+
from tests.common.devices.eos import EosHost
1920

2021
pytestmark = [
2122
pytest.mark.topology("t0", "t1")
@@ -306,10 +307,10 @@ def send_rx_ingress(self, action, verify):
306307

307308
class TestPfcwdFunc(SetupPfcwdFunc):
308309
""" Test PFC function and supporting methods """
309-
def __shutdown_lag_members(self, duthost, selected_port):
310+
def __shutdown_lag_members(self, duthost, selected_port, tbinfo, nbrhosts):
310311

311312
if self.ports[selected_port]['test_port_type'] != 'portchannel':
312-
return
313+
return None, None, None
313314

314315
config_facts = duthost.config_facts(host=duthost.hostname, source="persistent")['ansible_facts']
315316
portChannels = config_facts['PORTCHANNEL_MEMBER']
@@ -321,6 +322,25 @@ def __shutdown_lag_members(self, duthost, selected_port):
321322
portChannelMembers = portChannels[intf]
322323
break
323324

325+
dst_mgfacts = duthost.get_extended_minigraph_facts(tbinfo)
326+
vm_neighbors = dst_mgfacts['minigraph_neighbors']
327+
peer_device = vm_neighbors[list(portChannelMembers.keys())[0]]['name']
328+
peer_port = vm_neighbors[list(portChannelMembers.keys())[0]]['port']
329+
vm_host = nbrhosts[peer_device]['host']
330+
neigh_port_channel = None
331+
min_links = None
332+
if isinstance(vm_host, EosHost):
333+
neigh_port_channels = vm_host.eos_command(
334+
commands=['show port-channel | json'])['stdout'][0]["portChannels"]
335+
for po_name, po_config in neigh_port_channels.items():
336+
for member in po_config['activePorts']:
337+
if member == peer_port:
338+
neigh_port_channel = po_name
339+
min_links = len(po_config['activePorts'])
340+
break
341+
342+
vm_host.eos_config(lines=['port-channel min-links 1'], parents=[f'int {neigh_port_channel}'])
343+
324344
cmd_data = f'.PORTCHANNEL.{portChannel}.min_links = "1"'
325345

326346
for port in portChannelMembers:
@@ -334,13 +354,17 @@ def __shutdown_lag_members(self, duthost, selected_port):
334354
duthost.command(cmd, _uses_shell=True)
335355
duthost.command("sudo cp /tmp/config_db.json /etc/sonic/config_db.json", _uses_shell=True)
336356
config_reload(duthost, config_source='config_db', safe_reload=True, check_intf_up_ports=True, wait_for_bgp=True)
357+
return vm_host, neigh_port_channel, min_links
337358

338-
def __restore_original_config(self, duthost, selected_port):
359+
def __restore_original_config(self, duthost, selected_port, vm_host, neigh_port_channel, min_links):
339360

340361
if self.ports[selected_port]['test_port_type'] != 'portchannel':
341362
return
342363

343-
duthost.command("sudo mv /tmp/config_db_backup.json /etc/sonic/config.json", _uses_shell=True)
364+
if isinstance(vm_host, EosHost):
365+
vm_host.eos_config(lines=[f'port-channel min-links {min_links}'], parents=[f'int {neigh_port_channel}'])
366+
367+
duthost.command("sudo mv /tmp/config_db_backup.json /etc/sonic/config_db.json", _uses_shell=True)
344368
config_reload(duthost, config_source='config_db', safe_reload=True, check_intf_up_ports=True, wait_for_bgp=True)
345369

346370
def storm_detect_path(self, dut, port, action):
@@ -479,7 +503,7 @@ def set_traffic_action(self, duthost, action):
479503
self.rx_action = action
480504
self.tx_action = action
481505

482-
def test_pfcwd_show_stat(self, request, setup_pfc_test,
506+
def test_pfcwd_show_stat(self, request, setup_pfc_test, tbinfo, nbrhosts,
483507
setup_dut_test_params, enum_fanout_graph_facts, ptfhost, # noqa: F811
484508
duthosts, enum_rand_one_per_hwsku_frontend_hostname, fanouthosts,
485509
setup_standby_ports_on_non_enum_rand_one_per_hwsku_frontend_host_m_unconditionally,
@@ -525,7 +549,7 @@ def test_pfcwd_show_stat(self, request, setup_pfc_test,
525549
# for idx, port in enumerate(self.ports):
526550
port = list(self.ports.keys())[0]
527551

528-
self.__shutdown_lag_members(duthost, port)
552+
vm_host, neigh_port_channel, min_links = self.__shutdown_lag_members(duthost, port, tbinfo, nbrhosts)
529553

530554
logger.info("--- Testing various Pfcwd actions on {} ---".format(port))
531555
self.setup_test_params(port, setup_info['vlan'], init=True, ip_version=ip_version)
@@ -558,4 +582,4 @@ def test_pfcwd_show_stat(self, request, setup_pfc_test,
558582
self.storm_hndle.stop_storm()
559583
logger.info("--- Stop PFC WD ---")
560584
self.dut.command("pfcwd stop")
561-
self.__restore_original_config(duthost, port)
585+
self.__restore_original_config(duthost, port, vm_host, neigh_port_channel, min_links)

0 commit comments

Comments
 (0)