Skip to content

Commit d82ed5e

Browse files
authored
[202412] Code sync sonic-net/sonic-mgmt:202411 => 202412 (sonic-net#522)
Code sync sonic-net/sonic-mgmt:202411 => 202412 ``` * 3124d52 (HEAD -> code-sync-202412, origin/code-sync-202412) r12f 250710:1626 - Merge remote-tracking branch 'base/202411' into code-sync-202412 |\ | * b1b95dc (base/202411) zitingguo-ms 250513:1848 - Fix PortChannel name matching in verify_attr_change to handle leading spaces (sonic-net#18301) | * 7461bf3 wrideout-arista 250604:1542 - Determine if the eos switch is running in multiagent mode, and stop/start the (sonic-net#18748) | * 4346afd Dashuai Zhang 250411:0103 - update d18u8s4 PT0 ASN to 4 bytes (sonic-net#17888) | * de1b1b4 Ryangwaite 250709:1028 - Skip multi-hop upgrade tests on non-T0 testbeds (sonic-net#19078) (sonic-net#19326) | * 573d42d Cong Hou 250709:0232 - Update the skip for test test_qos_dscp_mapping.py (sonic-net#19381) | * 3eb65b9 Yawen 250708:1743 - Unskip test_qos_sai for dualtor-aa-64-breakout (sonic-net#19363) | * f0c9705 Cong Hou 250707:2351 - xfail generic hash test on dualtor (sonic-net#19383) | * d378110 eyakubch 250707:0546 - Reduce flakiness of test_l2_configure.py. (sonic-net#18831) | * 043dba8 ShiyanWangMS 250703:0935 - Fix the ignore pattern - leapsecond file expired warning (sonic-net#19332) | * 92af38f zitingguo-ms 250703:1958 - Unskip testQosSaiHeadroomPoolWatermark on t0-d18u8s4 (sonic-net#19287) (sonic-net#19342) | * 0b7e4de Chuan Wu 250704:0334 - Add background traffic for test_pfc_pause_extra_lossless test (sonic-net#19218) ```
2 parents a60ad24 + 3124d52 commit d82ed5e

7 files changed

Lines changed: 191 additions & 163 deletions

File tree

ansible/roles/test/files/tools/loganalyzer/loganalyzer_common_ignore.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ r, ".* ERR swss#orchagent:.*doAppSwitchTableTask.*Unsupported Attribute lag_hash
306306
r, ".* ERR syncd\d*#syncd.*SAI_API_BUFFER.*Unsupported buffer pool.*"
307307

308308
# ignore leap second file NTP daemon (ntpd) is using has passed its expiration date
309-
r, ".* ERR ntpd\[\d*\]:.*leapsecond file ('/usr/share/zoneinfo/leap-seconds.list'): expired.*"
309+
r, ".* ERR ntpd\[\d*\]:.*leapsecond file \('/usr/share/zoneinfo/leap-seconds\.list'\): expired.*"
310310

311311
# ignore NTP nss_tacplus error, which will happen when reload config, because NTPD will invoke getpwnap API but nss_tacplus will re-render during reload config
312312
r, ".* ERR ntpd\[\d*\]: nss_tacplus: .*"

tests/common/plugins/conditional_mark/tests_mark_conditions.yaml

Lines changed: 36 additions & 23 deletions
Large diffs are not rendered by default.

tests/conftest.py

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from tests.common.helpers.dut_ports import encode_dut_port_name
4242
from tests.common.helpers.dut_utils import encode_dut_and_container_name
4343
from tests.common.helpers.parallel_utils import InitialCheckState, InitialCheckStatus
44+
from tests.common.helpers.pfcwd_helper import TrafficPorts, select_test_ports, set_pfc_timers
4445
from tests.common.system_utils import docker
4546
from tests.common.testbed import TestbedInfo
4647
from tests.common.utilities import get_inventory_files, wait_until
@@ -2827,3 +2828,112 @@ def start_platform_api_service(duthosts, enum_rand_one_per_hwsku_hostname, local
28272828

28282829
res = localhost.wait_for(host=dut_ip, port=SERVER_PORT, state='started', delay=1, timeout=10)
28292830
assert res['failed'] is False
2831+
2832+
2833+
def update_t1_test_ports(duthost, mg_facts, test_ports, tbinfo):
2834+
"""
2835+
Find out active IP interfaces and use the list to
2836+
remove inactive ports from test_ports
2837+
"""
2838+
ip_ifaces = duthost.get_active_ip_interfaces(tbinfo, asic_index=0)
2839+
port_list = []
2840+
for iface in list(ip_ifaces.keys()):
2841+
if iface.startswith("PortChannel"):
2842+
port_list.extend(
2843+
mg_facts["minigraph_portchannels"][iface]["members"]
2844+
)
2845+
else:
2846+
port_list.append(iface)
2847+
port_list_set = set(port_list)
2848+
for port in list(test_ports.keys()):
2849+
if port not in port_list_set:
2850+
del test_ports[port]
2851+
return test_ports
2852+
2853+
2854+
@pytest.fixture(scope="module")
2855+
def setup_pfc_test(
2856+
duthosts, enum_rand_one_per_hwsku_frontend_hostname, ptfhost, conn_graph_facts, tbinfo, # noqa F811
2857+
):
2858+
"""
2859+
Sets up all the parameters needed for the PFC Watchdog tests
2860+
Args:
2861+
duthost: AnsibleHost instance for DUT
2862+
ptfhost: AnsibleHost instance for PTF
2863+
conn_graph_facts: fixture that contains the parsed topology info
2864+
Yields:
2865+
setup_info: dictionary containing pfc timers, generated test ports and selected test ports
2866+
"""
2867+
SUPPORTED_T1_TOPOS = {"t1-lag", "t1-64-lag", "t1-56-lag", "t1-28-lag", "t1-32-lag"}
2868+
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
2869+
mg_facts = duthost.get_extended_minigraph_facts(tbinfo)
2870+
port_list = list(mg_facts['minigraph_ports'].keys())
2871+
neighbors = conn_graph_facts['device_conn'].get(duthost.hostname, {})
2872+
dut_eth0_ip = duthost.mgmt_ip
2873+
vlan_nw = None
2874+
2875+
if mg_facts['minigraph_vlans']:
2876+
# Filter VLANs with one interface inside only(PortChannel interface in case of t0-56-po2vlan topo)
2877+
unexpected_vlans = []
2878+
for vlan, vlan_data in list(mg_facts['minigraph_vlans'].items()):
2879+
if len(vlan_data['members']) < 2:
2880+
unexpected_vlans.append(vlan)
2881+
2882+
# Update minigraph_vlan_interfaces with only expected VLAN interfaces
2883+
expected_vlan_ifaces = []
2884+
for vlan in unexpected_vlans:
2885+
for mg_vl_iface in mg_facts['minigraph_vlan_interfaces']:
2886+
if vlan != mg_vl_iface['attachto']:
2887+
expected_vlan_ifaces.append(mg_vl_iface)
2888+
if expected_vlan_ifaces:
2889+
mg_facts['minigraph_vlan_interfaces'] = expected_vlan_ifaces
2890+
2891+
# gather all vlan specific info
2892+
vlan_addr = mg_facts['minigraph_vlan_interfaces'][0]['addr']
2893+
vlan_prefix = mg_facts['minigraph_vlan_interfaces'][0]['prefixlen']
2894+
vlan_dev = mg_facts['minigraph_vlan_interfaces'][0]['attachto']
2895+
vlan_ips = duthost.get_ip_in_range(
2896+
num=1, prefix="{}/{}".format(vlan_addr, vlan_prefix),
2897+
exclude_ips=[vlan_addr])['ansible_facts']['generated_ips']
2898+
vlan_nw = vlan_ips[0].split('/')[0]
2899+
2900+
topo = tbinfo["topo"]["name"]
2901+
2902+
# build the port list for the test
2903+
config_facts = duthost.config_facts(host=duthost.hostname, source="running")['ansible_facts']
2904+
tp_handle = TrafficPorts(mg_facts, neighbors, vlan_nw, topo, config_facts)
2905+
test_ports = tp_handle.build_port_list()
2906+
2907+
# In T1 topology update test ports by removing inactive ports
2908+
if topo in SUPPORTED_T1_TOPOS:
2909+
test_ports = update_t1_test_ports(
2910+
duthost, mg_facts, test_ports, tbinfo
2911+
)
2912+
# select a subset of ports from the generated port list
2913+
selected_ports = select_test_ports(test_ports)
2914+
2915+
setup_info = {'test_ports': test_ports,
2916+
'port_list': port_list,
2917+
'selected_test_ports': selected_ports,
2918+
'pfc_timers': set_pfc_timers(),
2919+
'neighbors': neighbors,
2920+
'eth0_ip': dut_eth0_ip
2921+
}
2922+
2923+
if mg_facts['minigraph_vlans']:
2924+
setup_info['vlan'] = {'addr': vlan_addr,
2925+
'prefix': vlan_prefix,
2926+
'dev': vlan_dev
2927+
}
2928+
else:
2929+
setup_info['vlan'] = None
2930+
2931+
# stop pfcwd
2932+
logger.info("--- Stopping Pfcwd ---")
2933+
duthost.command("pfcwd stop")
2934+
2935+
# set poll interval
2936+
duthost.command("pfcwd interval {}".format(setup_info['pfc_timers']['pfc_wd_poll_time']))
2937+
2938+
logger.info("setup_info : {}".format(setup_info))
2939+
yield setup_info

tests/generic_config_updater/test_portchannel_interface.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,12 @@ def verify_attr_change(duthost, po_name, attr, value):
247247
...
248248
"""
249249
if attr == "mtu":
250-
output = duthost.shell("show interfaces status | grep -w '^{}' | awk '{{print $4}}'".format(po_name))
250+
cmd = (
251+
"show interfaces status | "
252+
"grep -w '^[[:space:]]*{}' | "
253+
"awk '{{print $4}}'"
254+
).format(po_name)
255+
output = duthost.shell(cmd)
251256

252257
pytest_assert(output['stdout'] == value, "{} attribute {} failed to change to {}".format(po_name, attr, value))
253258
elif attr == "min_links":

tests/l2/test_l2_configure.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import pytest
77
import tempfile
88

9+
from pytest_ansible.errors import AnsibleConnectionFailure
10+
911
from tests.common import config_reload
1012
from tests.common.platform.processes_utils import wait_critical_processes
1113
from tests.common.helpers.assertions import pytest_assert
@@ -175,7 +177,12 @@ def test_no_hardcoded_tables(duthosts, rand_one_dut_hostname, tbinfo):
175177

176178
# Remove minigraph to avoid config coming from minigraph.
177179
duthost.shell("sudo rm {}".format(MINIGRAPH))
178-
config_reload(duthost)
180+
try:
181+
config_reload(duthost)
182+
except AnsibleConnectionFailure as e:
183+
# In latest SONiC, config reload command will exit after mgmt interface restart
184+
# Then 'duthost' will lost IPV4 connection and throw exception
185+
logger.warning(f'Exception after config reload: {e}')
179186
wait_critical_processes(duthost)
180187
db_version_after = get_db_version(duthost)
181188
logger.info(

tests/pfcwd/conftest.py

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from tests.common.fixtures.ptfhost_utils import pause_garp_service # noqa F401
1111
from tests.common.mellanox_data import is_mellanox_device as isMellanoxDevice
1212
from tests.common.cisco_data import is_cisco_device
13-
from tests.common.helpers.pfcwd_helper import TrafficPorts, set_pfc_timers, select_test_ports
1413
from tests.common.utilities import str2bool
1514

1615
logger = logging.getLogger(__name__)
@@ -80,117 +79,6 @@ def fake_storm(request, duthosts, enum_rand_one_per_hwsku_frontend_hostname):
8079
else request.config.getoption('--fake-storm')
8180

8281

83-
def update_t1_test_ports(duthost, mg_facts, test_ports, tbinfo):
84-
"""
85-
Find out active IP interfaces and use the list to
86-
remove inactive ports from test_ports
87-
"""
88-
ip_ifaces = duthost.get_active_ip_interfaces(tbinfo, asic_index=0)
89-
port_list = []
90-
for iface in list(ip_ifaces.keys()):
91-
if iface.startswith("PortChannel"):
92-
port_list.extend(
93-
mg_facts["minigraph_portchannels"][iface]["members"]
94-
)
95-
else:
96-
port_list.append(iface)
97-
port_list_set = set(port_list)
98-
for port in list(test_ports.keys()):
99-
if port not in port_list_set:
100-
del test_ports[port]
101-
return test_ports
102-
103-
104-
@pytest.fixture(scope="module")
105-
def setup_pfc_test(
106-
duthosts, enum_rand_one_per_hwsku_frontend_hostname, ptfhost, conn_graph_facts, tbinfo, # noqa F811
107-
):
108-
"""
109-
Sets up all the parameters needed for the PFC Watchdog tests
110-
111-
Args:
112-
duthost: AnsibleHost instance for DUT
113-
ptfhost: AnsibleHost instance for PTF
114-
conn_graph_facts: fixture that contains the parsed topology info
115-
116-
Yields:
117-
setup_info: dictionary containing pfc timers, generated test ports and selected test ports
118-
"""
119-
SUPPORTED_T1_TOPOS = {"t1-lag", "t1-64-lag", "t1-56-lag", "t1-28-lag", "t1-32-lag"}
120-
duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]
121-
mg_facts = duthost.get_extended_minigraph_facts(tbinfo)
122-
port_list = list(mg_facts['minigraph_ports'].keys())
123-
neighbors = conn_graph_facts['device_conn'].get(duthost.hostname, {})
124-
dut_eth0_ip = duthost.mgmt_ip
125-
vlan_nw = None
126-
127-
if mg_facts['minigraph_vlans']:
128-
# Filter VLANs with one interface inside only(PortChannel interface in case of t0-56-po2vlan topo)
129-
unexpected_vlans = []
130-
for vlan, vlan_data in list(mg_facts['minigraph_vlans'].items()):
131-
if len(vlan_data['members']) < 2:
132-
unexpected_vlans.append(vlan)
133-
134-
# Update minigraph_vlan_interfaces with only expected VLAN interfaces
135-
expected_vlan_ifaces = []
136-
for vlan in unexpected_vlans:
137-
for mg_vl_iface in mg_facts['minigraph_vlan_interfaces']:
138-
if vlan != mg_vl_iface['attachto']:
139-
expected_vlan_ifaces.append(mg_vl_iface)
140-
if expected_vlan_ifaces:
141-
mg_facts['minigraph_vlan_interfaces'] = expected_vlan_ifaces
142-
143-
# gather all vlan specific info
144-
vlan_addr = mg_facts['minigraph_vlan_interfaces'][0]['addr']
145-
vlan_prefix = mg_facts['minigraph_vlan_interfaces'][0]['prefixlen']
146-
vlan_dev = mg_facts['minigraph_vlan_interfaces'][0]['attachto']
147-
vlan_ips = duthost.get_ip_in_range(
148-
num=1, prefix="{}/{}".format(vlan_addr, vlan_prefix),
149-
exclude_ips=[vlan_addr])['ansible_facts']['generated_ips']
150-
vlan_nw = vlan_ips[0].split('/')[0]
151-
152-
topo = tbinfo["topo"]["name"]
153-
154-
# build the port list for the test
155-
config_facts = duthost.config_facts(host=duthost.hostname, source="running")['ansible_facts']
156-
tp_handle = TrafficPorts(mg_facts, neighbors, vlan_nw, topo, config_facts)
157-
test_ports = tp_handle.build_port_list()
158-
159-
# In T1 topology update test ports by removing inactive ports
160-
if topo in SUPPORTED_T1_TOPOS:
161-
test_ports = update_t1_test_ports(
162-
duthost, mg_facts, test_ports, tbinfo
163-
)
164-
# select a subset of ports from the generated port list
165-
selected_ports = select_test_ports(test_ports)
166-
167-
setup_info = {'test_ports': test_ports,
168-
'port_list': port_list,
169-
'selected_test_ports': selected_ports,
170-
'pfc_timers': set_pfc_timers(),
171-
'neighbors': neighbors,
172-
'eth0_ip': dut_eth0_ip
173-
}
174-
175-
if mg_facts['minigraph_vlans']:
176-
setup_info['vlan'] = {'addr': vlan_addr,
177-
'prefix': vlan_prefix,
178-
'dev': vlan_dev
179-
}
180-
else:
181-
setup_info['vlan'] = None
182-
183-
# stop pfcwd
184-
logger.info("--- Stopping Pfcwd ---")
185-
duthost.command("pfcwd stop")
186-
187-
# set poll interval
188-
duthost.command("pfcwd interval {}".format(setup_info['pfc_timers']['pfc_wd_poll_time']))
189-
190-
logger.info("setup_info : {}".format(setup_info))
191-
yield setup_info
192-
193-
19482
@pytest.fixture(scope="module")
19583
def setup_dut_test_params(
19684
duthosts, enum_rand_one_per_hwsku_frontend_hostname, ptfhost, conn_graph_facts, tbinfo, # noqa F811

0 commit comments

Comments
 (0)