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
57 changes: 57 additions & 0 deletions tests/common/ixia/common_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import ipaddr
from netaddr import IPNetwork
from tests.common.mellanox_data import is_mellanox_device as isMellanoxDevice

def increment_ip_address (ip, incr=1) :
"""
Expand Down Expand Up @@ -466,3 +467,59 @@ def get_pfcwd_restore_time(host_ans, intf):
return int(val)

return None

def start_pfcwd(duthost):
"""
Start PFC watchdog with default setting

Args:
duthost (AnsibleHost): Device Under Test (DUT)

Returns:
N/A
"""
duthost.shell('sudo pfcwd start_default')

def stop_pfcwd(duthost):
"""
Stop PFC watchdog

Args:
duthost (AnsibleHost): Device Under Test (DUT)

Returns:
N/A
"""
duthost.shell('sudo pfcwd stop')

def disable_packet_aging(duthost):
"""
Disable packet aging feature (only on MLNX switches)

Args:
duthost (AnsibleHost): Device Under Test (DUT)

Returns:
N/A
"""
if isMellanoxDevice(duthost):
duthost.copy(src="qos/files/mellanox/packets_aging.py", dest="/tmp")
duthost.command("docker cp /tmp/packets_aging.py syncd:/")
duthost.command("docker exec syncd python /packets_aging.py disable")
duthost.command("docker exec syncd rm -rf /packets_aging.py")

def enable_packet_aging(duthost):
"""
Enable packet aging feature (only on MLNX switches)

Args:
duthost (AnsibleHost): Device Under Test (DUT)

Returns:
N/A
"""
if isMellanoxDevice(duthost):
duthost.copy(src="qos/files/mellanox/packets_aging.py", dest="/tmp")
duthost.command("docker cp /tmp/packets_aging.py syncd:/")
duthost.command("docker exec syncd python /packets_aging.py enable")
duthost.command("docker exec syncd rm -rf /packets_aging.py")
18 changes: 1 addition & 17 deletions tests/common/ixia/qos_fixtures.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import pytest

"""
RDMA test cases may require variety of fixtures. This
file currently holds the following fixture(s):
1. prio_dscp_map
2. all_prio_list
3. lossless_prio_list
4. lossy_prio_list
5. start_pfcwd_default
"""

@pytest.fixture(scope="module")
Expand Down Expand Up @@ -102,19 +102,3 @@ def lossy_prio_list(all_prio_list, lossless_prio_list):
"""
result = [x for x in all_prio_list if x not in lossless_prio_list]
return result

@pytest.fixture(scope="function")
def start_pfcwd_default(duthosts, rand_one_dut_hostname):
"""
Start PFC watchdog with default setting

Args:
duthosts (pytest fixture) : list of DUTs
rand_one_dut_hostname (pytest fixture): DUT hostname
"""
duthost = duthosts[rand_one_dut_hostname]
duthost.shell('sudo pfcwd start_default')
yield

""" teardown code """
duthost.shell('sudo pfcwd stop')
57 changes: 37 additions & 20 deletions tests/pfc/conftest.py → tests/ixia/conftest.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
import pytest

from tests.conftest import generate_port_lists, generate_priority_lists

@pytest.fixture(autouse=True, scope="module")
def rand_one_oper_up_intf(request):
"""
Fixture that randomly selects one oper up interface

Args:
request (object): pytest request object

Yields:
interface (str): string containing 'hostname|selected intf'

"""
oper_up_intfs = generate_port_lists(request, "oper_up_ports")
if oper_up_intfs:
yield random.sample(oper_up_intfs, 1)[0]
else:
yield 'unknown|unknown'
import random
from tests.common.ixia.common_helpers import enable_packet_aging, start_pfcwd
from tests.conftest import generate_priority_lists

@pytest.fixture(autouse=True, scope="module")
def rand_lossless_prio(request):
Expand Down Expand Up @@ -55,3 +38,37 @@ def rand_lossy_prio(request):
yield random.sample(lossy_prios, 1)[0]
else:
yield 'unknown|unknown'

@pytest.fixture(autouse=True, scope="module")
def start_pfcwd_after_test(duthosts, rand_one_dut_hostname):
"""
Ensure that PFC watchdog is enabled with default setting after tests

Args:
duthosts (pytest fixture) : list of DUTs
rand_one_dut_hostname (pytest fixture): DUT hostname

Yields:
N/A
"""
yield

duthost = duthosts[rand_one_dut_hostname]
start_pfcwd(duthost)

@pytest.fixture(autouse=True, scope="module")
def enable_packet_aging_after_test(duthosts, rand_one_dut_hostname):
"""
Ensure that packet aging is enabled after tests

Args:
duthosts (pytest fixture) : list of DUTs
rand_one_dut_hostname (pytest fixture): DUT hostname

Yields:
N/A
"""
yield

duthost = duthosts[rand_one_dut_hostname]
enable_packet_aging(duthost)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions tests/ecn/files/helper.py → tests/ixia/ecn/files/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
ixia_api_serv_user, ixia_api_serv_passwd, ixia_api
from tests.common.ixia.ixia_helpers import get_dut_port_id
from tests.common.ixia.common_helpers import pfc_class_enable_vector, config_wred,\
enable_ecn, config_ingress_lossless_buffer_alpha
enable_ecn, config_ingress_lossless_buffer_alpha, stop_pfcwd, disable_packet_aging

from abstract_open_traffic_generator.capture import CustomFilter, Capture,\
BasicFilter
Expand Down Expand Up @@ -67,8 +67,8 @@ def run_ecn_test(api,

pytest_assert(testbed_config is not None, 'Failed to get L2/3 testbed config')

""" Disable PFC watchdog """
duthost.shell('sudo pfcwd stop')
stop_pfcwd(duthost)
disable_packet_aging(duthost)

""" Configure WRED/ECN thresholds """
config_result = config_wred(host_ans=duthost,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def test_dequeue_ecn(request,
fanout_graph_facts,
duthosts,
rand_one_dut_hostname,
enum_dut_portname_oper_up,
enum_dut_lossless_prio,
rand_one_dut_portname_oper_up,
rand_one_dut_lossless_prio,
prio_dscp_map):
"""
Test if the device under test (DUT) performs ECN marking at the egress
Expand All @@ -32,8 +32,8 @@ def test_dequeue_ecn(request,
fanout_graph_facts (pytest fixture): fanout graph
duthosts (pytest fixture): list of DUTs
rand_one_dut_hostname (str): hostname of DUT
enum_dut_portname_oper_up (str): name of port to test, e.g., 's6100-1|Ethernet0'
enum_dut_lossless_prio (str): name of lossless priority to test, e.g., 's6100-1|3'
rand_one_dut_portname_oper_up (str): name of port to test, e.g., 's6100-1|Ethernet0'
rand_one_dut_lossless_prio (str): name of lossless priority to test, e.g., 's6100-1|3'
prio_dscp_map (pytest fixture): priority vs. DSCP map (key = priority).

Returns:
Expand All @@ -43,8 +43,8 @@ def test_dequeue_ecn(request,
if disable_test:
pytest.skip("test_dequeue_ecn is disabled")

dut_hostname, dut_port = enum_dut_portname_oper_up.split('|')
dut_hostname2, lossless_prio = enum_dut_lossless_prio.split('|')
dut_hostname, dut_port = rand_one_dut_portname_oper_up.split('|')
dut_hostname2, lossless_prio = rand_one_dut_lossless_prio.split('|')
pytest_require(rand_one_dut_hostname == dut_hostname == dut_hostname2,
"Priority and port are not mapped to the expected DUT")

Expand Down
File renamed without changes.
Empty file added tests/ixia/pfc/__init__.py
Empty file.
File renamed without changes.
16 changes: 10 additions & 6 deletions tests/pfc/files/helper.py → tests/ixia/pfc/files/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ixia_api_serv_user, ixia_api_serv_passwd, ixia_api
from tests.common.ixia.ixia_helpers import get_dut_port_id
from tests.common.ixia.common_helpers import pfc_class_enable_vector,\
get_egress_lossless_buffer_size
get_egress_lossless_buffer_size, stop_pfcwd, disable_packet_aging

from abstract_open_traffic_generator.flow import DeviceTxRx, TxRx, Flow, Header,\
Size, Rate,Duration, FixedSeconds, PortTxRx, PfcPause, EthernetPause, Continuous
Expand Down Expand Up @@ -59,13 +59,13 @@ def run_pfc_test(api,
test_traffic_pause (bool): if test flows are expected to be paused

Returns:
None
N/A
"""

pytest_assert(testbed_config is not None, 'Fail to get L2/3 testbed config')

""" Disable PFC watchdog """
duthost.shell('sudo pfcwd stop')
stop_pfcwd(duthost)
disable_packet_aging(duthost)

""" Get the ID of the port to test """
port_id = get_dut_port_id(dut_hostname=duthost.hostname,
Expand Down Expand Up @@ -310,7 +310,10 @@ def __run_traffic(api,
api.set_state(State(FlowTransmitState(state='start')))
time.sleep(exp_dur_sec)

while True:
attempts = 0
max_attempts = 20

while attempts < max_attempts:
rows = api.get_flow_results(FlowRequest(flow_names=data_flow_names))

""" If all the data flows have stopped """
Expand All @@ -321,6 +324,7 @@ def __run_traffic(api,
break
else:
time.sleep(1)
attempts += 1

""" Dump per-flow statistics """
rows = api.get_flow_results(FlowRequest(flow_names=all_flow_names))
Expand Down Expand Up @@ -357,7 +361,7 @@ def __verify_results(rows,
tolerance (float): maximum allowable deviation

Returns:
None
N/A
"""

""" All the pause frames should be dropped """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_global_pause(ixia_api,
fanout_graph_facts,
duthosts,
rand_one_dut_hostname,
enum_dut_portname_oper_up,
rand_one_dut_portname_oper_up,
lossless_prio_list,
lossy_prio_list,
prio_dscp_map):
Expand All @@ -32,16 +32,16 @@ def test_global_pause(ixia_api,
fanout_graph_facts (pytest fixture): fanout graph
duthosts (pytest fixture): list of DUTs
rand_one_dut_hostname (str): hostname of DUT
enum_dut_portname_oper_up (str): name of port to test, e.g., 's6100-1|Ethernet0'
rand_one_dut_portname_oper_up (str): name of port to test, e.g., 's6100-1|Ethernet0'
lossless_prio_list (pytest fixture): list of all the lossless priorities
lossy_prio_list (pytest fixture): list of all the lossy priorities
prio_dscp_map (pytest fixture): priority vs. DSCP map (key = priority).

Returns:
None
N/A
"""

dut_hostname, dut_port = enum_dut_portname_oper_up.split('|')
dut_hostname, dut_port = rand_one_dut_portname_oper_up.split('|')
pytest_require(rand_one_dut_hostname == dut_hostname,
"Port is not mapped to the expected DUT")

Expand Down
Loading