Skip to content

Commit d11f5e3

Browse files
weiguo-nvidiagshemesh2
authored andcommitted
Add packet trimming test cases (sonic-net#18051)
Change-Id: I61b4eba4defc9ba804f4d7c8814fad79daf265c4 Signed-off-by: Guy Shemesh <[email protected]>
1 parent d2295eb commit d11f5e3

9 files changed

Lines changed: 3347 additions & 5 deletions

File tree

tests/common/helpers/ptf_tests_helper.py

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,47 @@
1414

1515

1616
@pytest.fixture(scope="module")
17-
def downstream_links(rand_selected_dut, tbinfo):
17+
def downstream_links(rand_selected_dut, tbinfo, nbrhosts):
1818
"""
1919
Returns a dictionary of all the links that are downstream from the DUT.
2020
2121
Args:
2222
rand_selected_dut: DUT fixture
2323
tbinfo: testbed information fixture
24+
nbrhosts: neighbor host fixture
2425
Returns:
2526
links: Dictionary of links downstream from the DUT
2627
"""
2728
links = dict()
2829
duthost = rand_selected_dut
2930

3031
def filter(interface, neighbor, mg_facts, tbinfo):
31-
if ((tbinfo["topo"]["type"] == "t0" and "Server" in neighbor["name"])
32-
or (tbinfo["topo"]["type"] == "t1" and "T0" in neighbor["name"])):
33-
port = mg_facts["minigraph_neighbors"][interface]["port"]
32+
port = mg_facts["minigraph_neighbors"][interface]["port"]
33+
ptf_port_id = mg_facts["minigraph_ptf_indices"][interface]
34+
if tbinfo["topo"]["type"] == "t1" and "T0" in neighbor["name"]:
35+
# Search for BGP neighbor information
36+
local_ipv4_addr = None
37+
peer_ipv4_addr = None
38+
for item in mg_facts["minigraph_bgp"]:
39+
if item["name"] == neighbor["name"]:
40+
if isinstance(ip_address(item["addr"]), IPv4Address):
41+
# The address of neighbor device
42+
local_ipv4_addr = item["addr"]
43+
# The address of DUT
44+
peer_ipv4_addr = item["peer_addr"]
45+
break
3446
links[interface] = {
3547
"name": neighbor["name"],
36-
"ptf_port_id": mg_facts["minigraph_ptf_indices"][interface],
48+
"ptf_port_id": ptf_port_id,
49+
"local_ipv4_addr": local_ipv4_addr,
50+
"peer_ipv4_addr": peer_ipv4_addr,
51+
"downstream_port": port,
52+
"host": nbrhosts[neighbor["name"]]["host"]
53+
}
54+
elif tbinfo["topo"]["type"] == "t0" and "Server" in neighbor["name"]:
55+
links[interface] = {
56+
"name": neighbor["name"],
57+
"ptf_port_id": ptf_port_id,
3758
"downstream_port": port
3859
}
3960

@@ -83,6 +104,47 @@ def filter(interface, neighbor, mg_facts, tbinfo):
83104
return links
84105

85106

107+
@pytest.fixture(scope="module")
108+
def peer_links(rand_selected_dut, tbinfo, nbrhosts):
109+
"""
110+
Returns a dictionary of all the links that are service ports from the DUT.
111+
112+
Args:
113+
rand_selected_dut: DUT fixture
114+
tbinfo: testbed information fixture
115+
nbrhosts: neighbor host fixture
116+
Returns:
117+
links: Dictionary of service links from the DUT
118+
"""
119+
links = dict()
120+
duthost = rand_selected_dut
121+
122+
def filter(interface, neighbor, mg_facts, tbinfo):
123+
if "PT0" in neighbor["name"]:
124+
local_ipv4_addr = None
125+
peer_ipv4_addr = None
126+
for item in mg_facts["minigraph_bgp"]:
127+
if item["name"] == neighbor["name"]:
128+
if isinstance(ip_address(item["addr"]), IPv4Address):
129+
# The address of neighbor device
130+
local_ipv4_addr = item["addr"]
131+
# The address of DUT
132+
peer_ipv4_addr = item["peer_addr"]
133+
break
134+
port = mg_facts["minigraph_neighbors"][interface]["port"]
135+
links[interface] = {
136+
"name": neighbor["name"],
137+
"ptf_port_id": mg_facts["minigraph_ptf_indices"][interface],
138+
"local_ipv4_addr": local_ipv4_addr,
139+
"peer_ipv4_addr": peer_ipv4_addr,
140+
"service_port": port,
141+
"host": nbrhosts[neighbor["name"]]["host"]
142+
}
143+
144+
find_links(duthost, tbinfo, filter)
145+
return links
146+
147+
86148
def apply_dscp_cfg_setup(duthost, dscp_mode):
87149
"""
88150
Applies the DSCP decap configuration to the DUT.

tests/common/plugins/conditional_mark/tests_mark_conditions.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,12 @@ generic_config_updater/test_multiasic_linkcrc.py:
14771477
conditions:
14781478
- "(is_multi_asic is False)"
14791479

1480+
generic_config_updater/test_packet_trimming_config.py:
1481+
skip:
1482+
reason: "KVM do not support the feature"
1483+
conditions:
1484+
- "asic_type in ['vs']"
1485+
14801486
generic_config_updater/test_pfcwd_interval.py:
14811487
skip:
14821488
reason: "This test can only support mellanox platforms"
@@ -2046,6 +2052,15 @@ override_config_table/test_override_config_table.py:
20462052
conditions:
20472053
- "is_multi_asic==True"
20482054

2055+
#######################################
2056+
###### packet_trimming #####
2057+
########################################
2058+
packet_trimming/test_packet_trimming.py:
2059+
skip:
2060+
reason: "KVM do not support the feature"
2061+
conditions:
2062+
- "asic_type in ['vs']"
2063+
20492064
#######################################
20502065
##### pc #####
20512066
#######################################

tests/common/utilities.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,26 @@ def get_vlan_from_port(duthost, member_port):
15141514
return vlan_name
15151515

15161516

1517+
def configure_packet_aging(duthost, disabled=True):
1518+
"""
1519+
For Nvidia(Mellanox) platforms, packets in buffer will be aged after a timeout.
1520+
This function can enable or disable packet aging feature.
1521+
1522+
Args:
1523+
duthost: DUT host object
1524+
disabled: True to disable packet aging, False to enable packet aging
1525+
"""
1526+
logger.info("Starting configure packet aging")
1527+
asic = duthost.get_asic_name()
1528+
if 'spc' in asic:
1529+
action = "disable" if disabled else "enable"
1530+
logger.info(f"{action.capitalize()} Mellanox packet aging")
1531+
duthost.copy(src="qos/files/mellanox/packets_aging.py", dest="/tmp")
1532+
duthost.command("docker cp /tmp/packets_aging.py syncd:/")
1533+
duthost.command(f"docker exec syncd python /packets_aging.py {action}")
1534+
duthost.command("docker exec syncd rm -rf /packets_aging.py")
1535+
1536+
15171537
def cleanup_prev_images(duthost):
15181538
logger.info("Cleaning up previously installed images on DUT")
15191539
current_os_version = duthost.shell('sonic_installer list | grep Current | cut -f2 -d " "')['stdout']

0 commit comments

Comments
 (0)