Skip to content

Commit b0c1885

Browse files
committed
Update qos dscp mapping case (sonic-net#20429)
1.Optimize the test cases and use one case to do the two dscp mode test 2.Change the teardown step to a fixture to make sure it must be executed 3.Make sure dscp_to_tc_map is AZURE 4.Add warm reboot action to enhance the test coverage 5.Remove skip condition for mellanox 6.Optimize the packet validation flow which dramatically reduce the execution time 7.Optimize the queue counter check flow to reduce the queue counter check execution time 8.Add port and dscp mode as well as route check to enhance the script debuggability 9.Use completeness_level, by default the script would run warm reboot test if completeness_level had been set as basic, it would skip warm reboot test and the function test after warm reboot action
1 parent bfb16f7 commit b0c1885

4 files changed

Lines changed: 346 additions & 157 deletions

File tree

tests/common/plugins/conditional_mark/tests_mark_conditions.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3322,7 +3322,7 @@ qos/test_qos_dscp_mapping.py:
33223322
- "asic_type in ['cisco-8000'] and platform.startswith('x86_64-8122_')"
33233323
- "asic_type in ['vs']"
33243324

3325-
qos/test_qos_dscp_mapping.py::TestQoSSaiDSCPQueueMapping_IPIP_Base::test_dscp_to_queue_mapping_pipe_mode:
3325+
qos/test_qos_dscp_mapping.py::TestQoSSaiDSCPQueueMapping_IPIP_Base::test_dscp_to_queue_mapping[pipe]:
33263326
skip:
33273327
reason: "Pipe decap mode not supported due to either SAI or platform limitation / M* topo does not support qos"
33283328
conditions_logical_operator: or
@@ -3331,7 +3331,7 @@ qos/test_qos_dscp_mapping.py::TestQoSSaiDSCPQueueMapping_IPIP_Base::test_dscp_to
33313331
- https://github.com/sonic-net/sonic-mgmt/issues/12906
33323332
- "topo_type in ['m0', 'mx', 'm1']"
33333333

3334-
qos/test_qos_dscp_mapping.py::TestQoSSaiDSCPQueueMapping_IPIP_Base::test_dscp_to_queue_mapping_uniform_mode:
3334+
qos/test_qos_dscp_mapping.py::TestQoSSaiDSCPQueueMapping_IPIP_Base::test_dscp_to_queue_mapping[uniform]:
33353335
skip:
33363336
reason: "Uniform decap mode is not supported on Mellanox dualtor testbed due to the mode is pipe to support dscp remapping"
33373337
conditions:

tests/common/utilities.py

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,19 @@ def find_egress_queue(all_queue_pkts, exp_queue_pkts, tolerance=0.05):
12161216
return -1
12171217

12181218

1219+
def handle_queue_stats_output(intf_queue_stats):
1220+
queue_stats = []
1221+
for prio in range(8):
1222+
total_pkts_prio_str = intf_queue_stats.get("UC{}".format(prio)) if intf_queue_stats.get("UC{}".format(prio)) \
1223+
is not None else {"totalpacket": "0"}
1224+
total_pkts_str = total_pkts_prio_str.get("totalpacket")
1225+
if total_pkts_str == "N/A" or total_pkts_str is None:
1226+
total_pkts_str = "0"
1227+
queue_stats.append(int(total_pkts_str.replace(',', '')))
1228+
1229+
return queue_stats
1230+
1231+
12191232
def get_egress_queue_pkt_count_all_prio(duthost, port):
12201233
"""
12211234
Get the egress queue count in packets for a given port and all priorities from SONiC CLI.
@@ -1229,17 +1242,27 @@ def get_egress_queue_pkt_count_all_prio(duthost, port):
12291242
raw_out = duthost.shell("queuestat -jp {}".format(port))['stdout']
12301243
raw_json = json.loads(raw_out)
12311244
intf_queue_stats = raw_json.get(port)
1232-
queue_stats = []
12331245

1234-
for prio in range(8):
1235-
total_pkts_prio_str = intf_queue_stats.get("UC{}".format(prio)) if intf_queue_stats.get("UC{}".format(prio)) \
1236-
is not None else {"totalpacket": "0"}
1237-
total_pkts_str = total_pkts_prio_str.get("totalpacket")
1238-
if total_pkts_str == "N/A" or total_pkts_str is None:
1239-
total_pkts_str = "0"
1240-
queue_stats.append(int(total_pkts_str.replace(',', '')))
1246+
return handle_queue_stats_output(intf_queue_stats)
12411247

1242-
return queue_stats
1248+
1249+
def get_egress_queue_pkt_count_all_port_prio(duthost):
1250+
"""
1251+
Get the egress queue count in packets for all ports and all priorities from SONiC CLI.
1252+
This is the equivalent of the "queuestat -j" command.
1253+
Args:
1254+
duthost (Ansible host instance): device under test
1255+
Returns:
1256+
array [int]: total count of packets in the queue for all priorities and ports
1257+
"""
1258+
raw_out = duthost.shell("queuestat -j")['stdout']
1259+
raw_json = json.loads(raw_out)
1260+
all_stats = {}
1261+
for port in raw_json.keys():
1262+
intf_queue_stats = raw_json.get(port)
1263+
all_stats[port] = handle_queue_stats_output(intf_queue_stats)
1264+
1265+
return all_stats
12431266

12441267

12451268
@contextlib.contextmanager

tests/qos/qos_helpers.py

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
import os
77
import json
88
import logging
9+
import requests
910

1011
logger = logging.getLogger(__name__)
1112

12-
1313
PFC_GEN_FILE = 'pfc_gen.py'
1414
PFC_GEN_LOCAL_PATH = '../../ansible/roles/test/files/helpers/pfc_gen.py'
1515
PFC_GEN_REMOTE_PATH = '~/pfc_gen.py'
16+
WITHDRAW = 'withdraw'
17+
ANNOUNCE = 'announce'
1618

1719

1820
def atoi(text):
@@ -316,3 +318,51 @@ def disable_voq_watchdog(duthosts, get_src_dst_asic_and_duts):
316318
yield
317319
# Enable voq watchdog.
318320
modify_voq_watchdog(duthosts, get_src_dst_asic_and_duts, enable=True)
321+
322+
323+
def get_upstream_vm_offset(nbrhosts, tbinfo):
324+
"""
325+
Get ports offset of exabgp port
326+
"""
327+
port_offset_list = []
328+
if 't0' in tbinfo['topo']['type']:
329+
vm_filter = 'T1'
330+
elif 't1' in tbinfo['topo']['type']:
331+
vm_filter = 'T2'
332+
vm_name_list = [vm_name for vm_name in nbrhosts.keys() if vm_name.endswith(vm_filter)]
333+
for vm_name in vm_name_list:
334+
port_offset = tbinfo['topo']['properties']['topology']['VMs'][vm_name]['vm_offset']
335+
port_offset_list.append((port_offset))
336+
return port_offset_list
337+
338+
339+
def get_upstream_exabgp_port(nbrhosts, tbinfo, exabgp_base_port):
340+
"""
341+
Get exabgp port and ptf receive port
342+
"""
343+
port_offset_list = get_upstream_vm_offset(nbrhosts, tbinfo)
344+
return [_ + exabgp_base_port for _ in port_offset_list]
345+
346+
347+
def install_route_from_exabgp(operation, ptfip, route, port):
348+
"""
349+
Install or withdraw ip route by exabgp
350+
"""
351+
route_data = [route]
352+
url = "http://{}:{}".format(ptfip, port)
353+
command = "{} attribute next-hop self nlri {}".format(operation, ' '.join(route_data))
354+
data = {"command": command}
355+
logger.info("url: {}".format(url))
356+
logger.info("command: {}".format(data))
357+
r = requests.post(url, data=data, timeout=90)
358+
assert r.status_code == 200
359+
360+
361+
def announce_route(ptfip, route, port, action=ANNOUNCE):
362+
"""
363+
Announce or withdraw ipv4 or ipv6 route
364+
"""
365+
logger.info("\n========================== announce_route -- {} ==========================".format(action))
366+
logger.info(" action:{}\n ptfip:{}\n route:{}\n port:{}".format(action, ptfip, route, port))
367+
install_route_from_exabgp(action, ptfip, route, port)
368+
logger.info("\n--------------------------------------------------------------------------------")

0 commit comments

Comments
 (0)