Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 67 additions & 5 deletions tests/common/helpers/ptf_tests_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,47 @@


@pytest.fixture(scope="module")
def downstream_links(rand_selected_dut, tbinfo):
def downstream_links(rand_selected_dut, tbinfo, nbrhosts):
"""
Returns a dictionary of all the links that are downstream from the DUT.

Args:
rand_selected_dut: DUT fixture
tbinfo: testbed information fixture
nbrhosts: neighbor host fixture
Returns:
links: Dictionary of links downstream from the DUT
"""
links = dict()
duthost = rand_selected_dut

def filter(interface, neighbor, mg_facts, tbinfo):
if ((tbinfo["topo"]["type"] == "t0" and "Server" in neighbor["name"])
or (tbinfo["topo"]["type"] == "t1" and "T0" in neighbor["name"])):
port = mg_facts["minigraph_neighbors"][interface]["port"]
port = mg_facts["minigraph_neighbors"][interface]["port"]
ptf_port_id = mg_facts["minigraph_ptf_indices"][interface]
if tbinfo["topo"]["type"] == "t1" and "T0" in neighbor["name"]:
# Search for BGP neighbor information
local_ipv4_addr = None
peer_ipv4_addr = None
for item in mg_facts["minigraph_bgp"]:
if item["name"] == neighbor["name"]:
if isinstance(ip_address(item["addr"]), IPv4Address):
# The address of neighbor device
local_ipv4_addr = item["addr"]
# The address of DUT
peer_ipv4_addr = item["peer_addr"]
break
links[interface] = {
"name": neighbor["name"],
"ptf_port_id": mg_facts["minigraph_ptf_indices"][interface],
"ptf_port_id": ptf_port_id,
"local_ipv4_addr": local_ipv4_addr,
"peer_ipv4_addr": peer_ipv4_addr,
"downstream_port": port,
"host": nbrhosts[neighbor["name"]]["host"]
}
elif tbinfo["topo"]["type"] == "t0" and "Server" in neighbor["name"]:
links[interface] = {
"name": neighbor["name"],
"ptf_port_id": ptf_port_id,
"downstream_port": port
}

Expand Down Expand Up @@ -83,6 +104,47 @@ def filter(interface, neighbor, mg_facts, tbinfo):
return links


@pytest.fixture(scope="module")
def peer_links(rand_selected_dut, tbinfo, nbrhosts):
"""
Returns a dictionary of all the links that are service ports from the DUT.

Args:
rand_selected_dut: DUT fixture
tbinfo: testbed information fixture
nbrhosts: neighbor host fixture
Returns:
links: Dictionary of service links from the DUT
"""
links = dict()
duthost = rand_selected_dut

def filter(interface, neighbor, mg_facts, tbinfo):
if "PT0" in neighbor["name"]:
local_ipv4_addr = None
peer_ipv4_addr = None
for item in mg_facts["minigraph_bgp"]:
if item["name"] == neighbor["name"]:
if isinstance(ip_address(item["addr"]), IPv4Address):
# The address of neighbor device
local_ipv4_addr = item["addr"]
# The address of DUT
peer_ipv4_addr = item["peer_addr"]
break
port = mg_facts["minigraph_neighbors"][interface]["port"]
links[interface] = {
"name": neighbor["name"],
"ptf_port_id": mg_facts["minigraph_ptf_indices"][interface],
"local_ipv4_addr": local_ipv4_addr,
"peer_ipv4_addr": peer_ipv4_addr,
"service_port": port,
"host": nbrhosts[neighbor["name"]]["host"]
}

find_links(duthost, tbinfo, filter)
return links


def apply_dscp_cfg_setup(duthost, dscp_mode):
"""
Applies the DSCP decap configuration to the DUT.
Expand Down
15 changes: 15 additions & 0 deletions tests/common/plugins/conditional_mark/tests_mark_conditions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,12 @@ generic_config_updater/test_multiasic_linkcrc.py:
conditions:
- "(is_multi_asic is False)"

generic_config_updater/test_packet_trimming_config.py:
skip:
reason: "KVM do not support the feature"
conditions:
- "asic_type in ['vs']"

generic_config_updater/test_pfcwd_interval.py:
skip:
reason: "This test can only support mellanox platforms"
Expand Down Expand Up @@ -1613,6 +1619,15 @@ override_config_table/test_override_config_table.py:
conditions:
- "is_multi_asic==True"

#######################################
###### packet_trimming #####
########################################
packet_trimming/test_packet_trimming.py:
skip:
reason: "KVM do not support the feature"
conditions:
- "asic_type in ['vs']"

#######################################
##### pc #####
#######################################
Expand Down
20 changes: 20 additions & 0 deletions tests/common/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -1455,3 +1455,23 @@ def get_vlan_from_port(duthost, member_port):
if vlan_name is not None:
break
return vlan_name


def configure_packet_aging(duthost, disabled=True):
"""
For Nvidia(Mellanox) platforms, packets in buffer will be aged after a timeout.
This function can enable or disable packet aging feature.

Args:
duthost: DUT host object
disabled: True to disable packet aging, False to enable packet aging
"""
logger.info("Starting configure packet aging")
asic = duthost.get_asic_name()
if 'spc' in asic:
action = "disable" if disabled else "enable"
logger.info(f"{action.capitalize()} Mellanox packet aging")
duthost.copy(src="qos/files/mellanox/packets_aging.py", dest="/tmp")
duthost.command("docker cp /tmp/packets_aging.py syncd:/")
duthost.command(f"docker exec syncd python /packets_aging.py {action}")
duthost.command("docker exec syncd rm -rf /packets_aging.py")
Loading