From bdb9e201c3695e18743efc5f4276004ab2b4b8ee Mon Sep 17 00:00:00 2001 From: Yaqiang Zhu Date: Wed, 7 Aug 2024 16:46:28 +0800 Subject: [PATCH] [snmp] Add wait pc up in test_snmp_fdb (#13982) What is the motivation for this PR? In some scenario that this case would fail because dummy MAC count miss portchannel data. Hence add time wait How did you do it? Add time wait for portchannel up How did you verify/test it? Run test on t0 and m0. passed --- tests/snmp/test_snmp_fdb.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/snmp/test_snmp_fdb.py b/tests/snmp/test_snmp_fdb.py index 7e325f4599c..22a09087d50 100644 --- a/tests/snmp/test_snmp_fdb.py +++ b/tests/snmp/test_snmp_fdb.py @@ -71,6 +71,26 @@ def build_icmp_packet(vlan_id, src_mac="00:22:00:00:00:02", dst_mac="ff:ff:ff:ff return pkt +def is_port_channel_up(duthost, config_portchannels): + portchannel_status = duthost.show_and_parse("show int po") + portchannel_status_obj = {} + for item in portchannel_status: + all_members_up = True + for port in item["ports"].split(" "): + all_members_up = all_members_up and port.endswith("(S)") + portchannel_status_obj[item["team dev"]] = { + "pc_up": True if item["protocol"].endswith("(Up)") else False, + "all_members_up": all_members_up + } + for portchannel in config_portchannels.keys(): + if portchannel not in portchannel_status_obj: + return False + if not (portchannel_status_obj[portchannel]["pc_up"] and + portchannel_status_obj[portchannel]["all_members_up"]): + return False + return True + + @pytest.mark.bsl @pytest.mark.po2vlan def test_snmp_fdb_send_tagged(ptfadapter, duthosts, rand_one_dut_hostname, # noqa F811 @@ -85,6 +105,7 @@ def test_snmp_fdb_send_tagged(ptfadapter, duthosts, rand_one_dut_hostname, cfg_facts = duthost.config_facts(host=duthost.hostname, source="running")[ 'ansible_facts'] config_portchannels = cfg_facts.get('PORTCHANNEL', {}) + assert wait_until(60, 2, 0, is_port_channel_up, duthost, config_portchannels), "Portchannel is not up" send_cnt = 0 send_portchannels_cnt = 0 vlan_ports_list = running_vlan_ports_list(duthosts, rand_one_dut_hostname, rand_selected_dut, tbinfo, ports_list)