From b4b48d42e281e47f1a1d3822e1c60bf4e9ecdac4 Mon Sep 17 00:00:00 2001 From: Anish Date: Wed, 24 Mar 2021 11:18:48 +0000 Subject: [PATCH 1/6] updating pfc tests --- tests/common/ixia/ixia_fixtures.py | 103 +++++----- tests/ixia/pfc/files/helper.py | 234 +++++++++++----------- tests/ixia/pfc/test_global_pause.py | 8 +- tests/ixia/pfc/test_pfc_pause_lossless.py | 22 +- tests/ixia/pfc/test_pfc_pause_lossy.py | 22 +- 5 files changed, 197 insertions(+), 192 deletions(-) diff --git a/tests/common/ixia/ixia_fixtures.py b/tests/common/ixia/ixia_fixtures.py index 5b04c2f7783..838aab64ff5 100644 --- a/tests/common/ixia/ixia_fixtures.py +++ b/tests/common/ixia/ixia_fixtures.py @@ -11,6 +11,7 @@ from tests.common.ixia.common_helpers import get_vlan_subnet, get_addrs_in_subnet,\ get_peer_ixia_chassis from tests.common.ixia.ixia_helpers import IxiaFanoutManager, get_tgen_location +import snappi try: from abstract_open_traffic_generator.port import Port @@ -193,11 +194,31 @@ def ixia_api(ixia_api_serv_ip, if api_session: api_session.assistant.Session.remove() + +@pytest.fixture(scope='module') +def snappi_api(ixia_api_serv_ip, + ixia_api_serv_port): + """ + Snappi session fixture for snappi Tgen API + Args: + ixia_api_serv_ip (pytest fixture): ixia_api_serv_ip fixture + ixia_api_serv_port (pytest fixture): ixia_api_serv_port fixture. + """ + host = "https://" + ixia_api_serv_ip + ":" + str(ixia_api_serv_port) + api = snappi.api(host=host, ext="ixnetwork") + + yield api + + if api.assistant is not None: + api.assistant.Session.remove() + + @pytest.fixture(scope = "function") def ixia_testbed(conn_graph_facts, fanout_graph_facts, duthosts, - rand_one_dut_hostname): + rand_one_dut_hostname, + snappi_api): """ L2/L3 Tgen API config for the T0 testbed @@ -224,17 +245,14 @@ def ixia_testbed(conn_graph_facts, ixia_ports = ixia_fanout_list.get_ports(peer_device=duthost.hostname) - ports = list() port_names = list() port_speed = None """ L1 config """ + config = snappi_api.config() for i in range(len(ixia_ports)): - port = Port(name='Port {}'.format(i), - location=get_tgen_location(ixia_ports[i])) - - ports.append(port) - port_names.append(port.name) + config.ports.port(name='Port {}'.format(i), + location=get_tgen_location(ixia_ports[i])) if port_speed is None: port_speed = int(ixia_ports[i]['speed']) @@ -243,32 +261,29 @@ def ixia_testbed(conn_graph_facts, """ All the ports should have the same bandwidth """ return None - pfc = Ieee8021qbb(pfc_delay=0, - pfc_class_0=0, - pfc_class_1=1, - pfc_class_2=2, - pfc_class_3=3, - pfc_class_4=4, - pfc_class_5=5, - pfc_class_6=6, - pfc_class_7=7) - - flow_ctl = FlowControl(choice=pfc) - - auto_negotiation = AutoNegotiation(link_training=True, - rs_fec=True) - - l1_config = Layer1(name='L1 config', - speed='speed_%d_gbps' % int(port_speed/1000), - auto_negotiate=False, - auto_negotiation=auto_negotiation, - ieee_media_defaults=False, - flow_control=flow_ctl, - port_names=port_names) - - config = Config(ports=ports, - layer1=[l1_config], - options=Options(PortOptions(location_preemption=True))) + port_names = [port.name for port in config.ports] + config.options.port_options.location_preemption = True + l1_config = config.layer1.layer1()[-1] + l1_config.name = 'port settings' + l1_config.port_names = [port.name for port in config.ports] + l1_config.speed = 'speed_%d_gbps' % int(port_speed/1000) + l1_config.auto_negotiate = False + l1_config.auto_negotiation.link_training = True + l1_config.auto_negotiation.rs_fec = True + l1_config.ieee_media_defaults = False + + pfc = l1_config.flow_control.ieee_802_1qbb + pfc.pfc_delay = 0 + pfc.pfc_class_0 = 0 + pfc.pfc_class_1 = 1 + pfc.pfc_class_2 = 2 + pfc.pfc_class_3 = 3 + pfc.pfc_class_4 = 4 + pfc.pfc_class_5 = 5 + pfc.pfc_class_6 = 6 + pfc.pfc_class_7 = 7 + + l1_config.flow_control.choice = l1_config.flow_control.IEEE_802_1QBB """ L2/L3 config """ vlan_subnet = get_vlan_subnet(duthost) @@ -280,17 +295,15 @@ def ixia_testbed(conn_graph_facts, prefix = vlan_subnet.split('/')[1] for i in range(len(ixia_ports)): - ip_stack = Ipv4(name='Ipv4 {}'.format(i), - address=Pattern(vlan_ip_addrs[i]), - prefix=Pattern(prefix), - gateway=Pattern(gw_addr), - ethernet=Ethernet(name='Ethernet {}'.format(i))) - - device = Device(name='Device {}'.format(i), - device_count=1, - container_name=port_names[i], - choice=ip_stack) - - config.devices.append(device) + dev = config.devices.device(name='Device {}'.format(i), + container_name=port_names[i])[-1] + + eth = dev.ethernet + eth.name = 'Ethernet {}'.format(i) + ipv4 = eth.ipv4 + ipv4.name = 'Ipv4 {}'.format(i) + ipv4.address = vlan_ip_addrs[i] + ipv4.prefix = prefix + ipv4.gateway = gw_addr return config diff --git a/tests/ixia/pfc/files/helper.py b/tests/ixia/pfc/files/helper.py index 0b93e02e6a9..fa89e554b63 100644 --- a/tests/ixia/pfc/files/helper.py +++ b/tests/ixia/pfc/files/helper.py @@ -1,4 +1,5 @@ import time +import logging from tests.common.helpers.assertions import pytest_assert from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ @@ -9,14 +10,7 @@ from tests.common.ixia.common_helpers import pfc_class_enable_vector,\ 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 -from abstract_open_traffic_generator.flow_ipv4 import Priority, Dscp -from abstract_open_traffic_generator.flow import Pattern as FieldPattern -from abstract_open_traffic_generator.flow import Ipv4 as Ipv4Header -from abstract_open_traffic_generator.flow import Ethernet as EthernetHeader -from abstract_open_traffic_generator.control import State, ConfigState, FlowTransmitState -from abstract_open_traffic_generator.result import FlowRequest +logger = logging.getLogger(__name__) PAUSE_FLOW_NAME = 'Pause Storm' TEST_FLOW_NAME = 'Test Flow' @@ -76,31 +70,29 @@ def run_pfc_test(api, pytest_assert(port_id is not None, 'Fail to get ID for port {}'.format(dut_port)) - """ Rate percent must be an integer """ test_flow_rate_percent = int(TEST_FLOW_AGGR_RATE_PERCENT / len(test_prio_list)) bg_flow_rate_percent = int(BG_FLOW_AGGR_RATE_PERCENT / len(bg_prio_list)) """ Generate traffic config """ - flows = __gen_traffic(testbed_config=testbed_config, - port_id=port_id, - pause_flow_name=PAUSE_FLOW_NAME, - global_pause=global_pause, - pause_prio_list=pause_prio_list, - test_flow_name=TEST_FLOW_NAME, - test_flow_prio_list=test_prio_list, - test_flow_rate_percent=test_flow_rate_percent, - bg_flow_name=BG_FLOW_NAME, - bg_flow_prio_list=bg_prio_list, - bg_flow_rate_percent=bg_flow_rate_percent, - data_flow_dur_sec=DATA_FLOW_DURATION_SEC, - data_flow_delay_sec=DATA_FLOW_DELAY_SEC, - data_pkt_size=DATA_PKT_SIZE, - prio_dscp_map=prio_dscp_map) + __gen_traffic(testbed_config=testbed_config, + port_id=port_id, + pause_flow_name=PAUSE_FLOW_NAME, + global_pause=global_pause, + pause_prio_list=pause_prio_list, + test_flow_name=TEST_FLOW_NAME, + test_flow_prio_list=test_prio_list, + test_flow_rate_percent=test_flow_rate_percent, + bg_flow_name=BG_FLOW_NAME, + bg_flow_prio_list=bg_prio_list, + bg_flow_rate_percent=bg_flow_rate_percent, + data_flow_dur_sec=DATA_FLOW_DURATION_SEC, + data_flow_delay_sec=DATA_FLOW_DELAY_SEC, + data_pkt_size=DATA_PKT_SIZE, + prio_dscp_map=prio_dscp_map) """ Tgen config = testbed config + flow config """ - config = testbed_config - config.flows = flows + flows = testbed_config.flows """ import json @@ -113,12 +105,12 @@ def run_pfc_test(api, """ Run traffic """ flow_stats = __run_traffic(api=api, - config=config, + config=testbed_config, data_flow_names=data_flow_names, all_flow_names=all_flow_names, exp_dur_sec=DATA_FLOW_DURATION_SEC+DATA_FLOW_DELAY_SEC) - speed_str = config.layer1[0].speed + speed_str = testbed_config.layer1[0].speed speed_gbps = int(speed_str.split('_')[1]) """ Verify experiment results """ @@ -179,68 +171,65 @@ def __gen_traffic(testbed_config, flows and a pause storm. """ - result = list() - rx_port_id = port_id tx_port_id = (port_id + 1) % len(testbed_config.devices) - data_endpoint = DeviceTxRx( - tx_device_names=[testbed_config.devices[tx_port_id].name], - rx_device_names=[testbed_config.devices[rx_port_id].name], - ) - + tx_device_names = [testbed_config.devices[tx_port_id].name] + rx_device_names = [testbed_config.devices[rx_port_id].name] data_flow_delay_nanosec = sec_to_nanosec(data_flow_delay_sec) """ Test flows """ for prio in test_flow_prio_list: - ip_prio = Priority(Dscp(phb=FieldPattern(choice=prio_dscp_map[prio]), - ecn=FieldPattern(choice=Dscp.ECN_CAPABLE_TRANSPORT_1))) - pfc_queue = FieldPattern([prio]) - - test_flow = Flow( - name='{} Prio {}'.format(test_flow_name, prio), - tx_rx=TxRx(data_endpoint), - packet=[ - Header(choice=EthernetHeader(pfc_queue=pfc_queue)), - Header(choice=Ipv4Header(priority=ip_prio)) - ], - size=Size(data_pkt_size), - rate=Rate('line', test_flow_rate_percent), - duration=Duration(FixedSeconds(seconds=data_flow_dur_sec, - delay=data_flow_delay_nanosec, - delay_unit='nanoseconds')) - ) - - result.append(test_flow) + test_flow = testbed_config.flows.flow( + name='{} Prio {}'.format(test_flow_name, prio))[-1] + test_flow.tx_rx.device.tx_names = tx_device_names + test_flow.tx_rx.device.rx_names = rx_device_names + + eth, ipv4 = test_flow.packet.ethernet().ipv4() + eth.pfc_queue.value = prio + ipv4.priority.choice = ipv4.priority.DSCP + ipv4.priority.dscp.phb.values = prio_dscp_map[prio] + ipv4.priority.dscp.ecn.value = ( + ipv4.priority.dscp.ecn.CAPABLE_TRANSPORT_1) + + test_flow.size.fixed = data_pkt_size + test_flow.rate.percentage = test_flow_rate_percent + test_flow.duration.fixed_seconds.seconds = data_flow_dur_sec + test_flow.duration.fixed_seconds.delay = data_flow_delay_nanosec + test_flow.duration.fixed_seconds.delay_unit = ( + test_flow.duration.fixed_seconds.NANOSECONDS) """ Background flows """ for prio in bg_flow_prio_list: - ip_prio = Priority(Dscp(phb=FieldPattern(choice=prio_dscp_map[prio]), - ecn=FieldPattern(choice=Dscp.ECN_CAPABLE_TRANSPORT_1))) - pfc_queue = FieldPattern([prio]) - - bg_flow = Flow( - name='{} Prio {}'.format(bg_flow_name, prio), - tx_rx=TxRx(data_endpoint), - packet=[ - Header(choice=EthernetHeader(pfc_queue=pfc_queue)), - Header(choice=Ipv4Header(priority=ip_prio)) - ], - size=Size(data_pkt_size), - rate=Rate('line', bg_flow_rate_percent), - duration=Duration(FixedSeconds(seconds=data_flow_dur_sec, - delay=data_flow_delay_nanosec, - delay_unit='nanoseconds')) - ) - - result.append(bg_flow) + bg_flow = testbed_config.flows.flow( + name='{} Prio {}'.format(bg_flow_name, prio))[-1] + bg_flow.tx_rx.device.tx_names = tx_device_names + bg_flow.tx_rx.device.rx_names = rx_device_names + + eth, ipv4 = bg_flow.packet.ethernet().ipv4() + eth.pfc_queue.value = prio + ipv4.priority.choice = ipv4.priority.DSCP + ipv4.priority.dscp.phb.values = prio_dscp_map[prio] + ipv4.priority.dscp.ecn.value = ( + ipv4.priority.dscp.ecn.CAPABLE_TRANSPORT_1) + + bg_flow.size.fixed = data_pkt_size + bg_flow.rate.percentage = bg_flow_rate_percent + bg_flow.duration.fixed_seconds.seconds = data_flow_dur_sec + bg_flow.duration.fixed_seconds.delay = data_flow_delay_nanosec + bg_flow.duration.fixed_seconds.delay_unit = ( + bg_flow.duration.fixed_seconds.NANOSECONDS) """ Pause storm """ + pause_flow = testbed_config.flows.flow(name=pause_flow_name)[-1] + pause_flow.tx_rx.port.tx_name = testbed_config.ports[rx_port_id].name + pause_flow.tx_rx.port.rx_name = testbed_config.ports[tx_port_id].name + + pause_pkt = pause_flow.packet.pfcpause()[-1] + if global_pause: - pause_pkt = Header(EthernetPause( - dst=FieldPattern(choice='01:80:C2:00:00:01'), - src=FieldPattern(choice='00:00:fa:ce:fa:ce') - )) + pause_pkt.src.value = '00:00:fa:ce:fa:ce' + pause_pkt.dst.value = '01:80:C2:00:00:01' else: pause_time = [] @@ -252,40 +241,33 @@ def __gen_traffic(testbed_config, vector = pfc_class_enable_vector(pause_prio_list) - pause_pkt = Header(PfcPause( - dst=FieldPattern(choice='01:80:C2:00:00:01'), - src=FieldPattern(choice='00:00:fa:ce:fa:ce'), - class_enable_vector=FieldPattern(choice=vector), - pause_class_0=FieldPattern(choice=pause_time[0]), - pause_class_1=FieldPattern(choice=pause_time[1]), - pause_class_2=FieldPattern(choice=pause_time[2]), - pause_class_3=FieldPattern(choice=pause_time[3]), - pause_class_4=FieldPattern(choice=pause_time[4]), - pause_class_5=FieldPattern(choice=pause_time[5]), - pause_class_6=FieldPattern(choice=pause_time[6]), - pause_class_7=FieldPattern(choice=pause_time[7]), - )) + pause_pkt.src.value = '00:00:fa:ce:fa:ce' + pause_pkt.dst.value = '01:80:C2:00:00:01' + pause_pkt.class_enable_vector.value = vector + pause_pkt.pause_class_0.value = pause_time[0] + pause_pkt.pause_class_1.value = pause_time[1] + pause_pkt.pause_class_2.value = pause_time[2] + pause_pkt.pause_class_3.value = pause_time[3] + pause_pkt.pause_class_4.value = pause_time[4] + pause_pkt.pause_class_5.value = pause_time[5] + pause_pkt.pause_class_6.value = pause_time[6] + pause_pkt.pause_class_7.value = pause_time[7] """ Pause frames are sent from the RX port """ - pause_src_point = PortTxRx(tx_port_name=testbed_config.ports[rx_port_id].name, - rx_port_name=testbed_config.ports[tx_port_id].name) speed_str = testbed_config.layer1[0].speed speed_gbps = int(speed_str.split('_')[1]) pause_dur = 65535 * 64 * 8.0 / (speed_gbps * 1e9) pps = int(2 / pause_dur) - pause_flow = Flow( - name=pause_flow_name, - tx_rx=TxRx(pause_src_point), - packet=[pause_pkt], - size=Size(64), - rate=Rate('pps', value=pps), - duration=Duration(Continuous(delay=0, delay_unit='nanoseconds')) + pause_flow.rate.pps = pps + pause_flow.size.fixed = 64 + pause_flow.duration.choice = pause_flow.duration.CONTINUOUS + pause_flow.duration.continuous.delay = 0 + pause_flow.duration.continuous.delay_unit = ( + pause_flow.duration.continuous.NANOSECONDS ) - result.append(pause_flow) - return result def __run_traffic(api, config, @@ -306,18 +288,23 @@ def __run_traffic(api, Returns: per-flow statistics (list) """ - api.set_state(State(ConfigState(config=config, state='set'))) - api.set_state(State(FlowTransmitState(state='start'))) + api.set_config(config) + logger.info('Starting transmit on all flows ...') + ts = api.transmit_state() + ts.state = ts.START + api.set_transmit_state(ts) time.sleep(exp_dur_sec) attempts = 0 max_attempts = 20 while attempts < max_attempts: - rows = api.get_flow_results(FlowRequest(flow_names=data_flow_names)) + request = api.metrics_request() + request.flow.flow_names = data_flow_names + rows = api.get_metrics(request).flow_metrics """ If all the data flows have stopped """ - transmit_states = [row['transmit'] for row in rows] + transmit_states = [row.transmit for row in rows] if len(rows) == len(data_flow_names) and\ list(set(transmit_states)) == ['stopped']: time.sleep(IXIA_POLL_DELAY_SEC) @@ -330,8 +317,13 @@ def __run_traffic(api, "Flows do not stop in {} seconds".format(max_attempts)) """ Dump per-flow statistics """ - rows = api.get_flow_results(FlowRequest(flow_names=all_flow_names)) - api.set_state(State(FlowTransmitState(state='stop'))) + request = api.metrics_request() + request.flow.flow_names = all_flow_names + rows = api.get_metrics(request).flow_metrics + logger.info('Stop transmit on all flows ...') + ts = api.transmit_state() + ts.state = ts.STOP + api.set_transmit_state(ts) return rows @@ -368,44 +360,44 @@ def __verify_results(rows, """ """ All the pause frames should be dropped """ - pause_flow_row = next(row for row in rows if row["name"] == pause_flow_name) - tx_frames = pause_flow_row['frames_tx'] - rx_frames = pause_flow_row['frames_rx'] + pause_flow_row = next(row for row in rows if row.name == pause_flow_name) + tx_frames = pause_flow_row.frames_tx + rx_frames = pause_flow_row.frames_rx pytest_assert(tx_frames > 0 and rx_frames == 0, 'All the pause frames should be dropped') """ Check background flows """ for row in rows: - if bg_flow_name not in row['name']: + if bg_flow_name not in row.name: continue - tx_frames = row['frames_tx'] - rx_frames = row['frames_rx'] + tx_frames = row.frames_tx + rx_frames = row.frames_rx pytest_assert(tx_frames == rx_frames, - '{} should not have any dropped packet'.format(row['name'])) + '{} should not have any dropped packet'.format(row.name)) exp_bg_flow_rx_pkts = bg_flow_rate_percent / 100.0 * speed_gbps \ * 1e9 * data_flow_dur_sec / 8.0 / data_pkt_size deviation = (rx_frames - exp_bg_flow_rx_pkts) / float(exp_bg_flow_rx_pkts) pytest_assert(abs(deviation) < tolerance, '{} should receive {} packets (actual {})'.\ - format(row['name'], exp_bg_flow_rx_pkts, rx_frames)) + format(row.name, exp_bg_flow_rx_pkts, rx_frames)) """ Check test flows """ for row in rows: - if test_flow_name not in row['name']: + if test_flow_name not in row.name: continue - tx_frames = row['frames_tx'] - rx_frames = row['frames_rx'] + tx_frames = row.frames_tx + rx_frames = row.frames_rx if test_flow_pause: pytest_assert(tx_frames > 0 and rx_frames == 0, - '{} should be paused'.format(row['name'])) + '{} should be paused'.format(row.name)) else: pytest_assert(tx_frames == rx_frames, - '{} should not have any dropped packet'.format(row['name'])) + '{} should not have any dropped packet'.format(row.name)) exp_test_flow_rx_pkts = test_flow_rate_percent / 100.0 * speed_gbps \ * 1e9 * data_flow_dur_sec / 8.0 / data_pkt_size @@ -416,7 +408,7 @@ def __verify_results(rows, if test_flow_pause: """ In-flight TX bytes of test flows should be held by switch buffer """ - tx_frames_total = sum(row['frames_tx'] for row in rows if test_flow_name in row['name']) + tx_frames_total = sum(row.frames_tx for row in rows if test_flow_name in row.name) tx_bytes_total = tx_frames_total * data_pkt_size dut_buffer_size = get_egress_lossless_buffer_size(host_ans=duthost) diff --git a/tests/ixia/pfc/test_global_pause.py b/tests/ixia/pfc/test_global_pause.py index 503c1ba5d6b..24df8adc042 100644 --- a/tests/ixia/pfc/test_global_pause.py +++ b/tests/ixia/pfc/test_global_pause.py @@ -4,7 +4,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_api, ixia_testbed + ixia_api_serv_user, ixia_api_serv_passwd, ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, all_prio_list, lossless_prio_list,\ lossy_prio_list @@ -12,7 +12,7 @@ @pytest.mark.topology("tgen") -def test_global_pause(ixia_api, +def test_global_pause(snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -26,7 +26,7 @@ def test_global_pause(ixia_api, Test if IEEE 802.3X pause (a.k.a., global pause) will impact any priority Args: - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -49,7 +49,7 @@ def test_global_pause(ixia_api, test_prio_list = lossless_prio_list bg_prio_list = lossy_prio_list - run_pfc_test(api=ixia_api, + run_pfc_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, diff --git a/tests/ixia/pfc/test_pfc_pause_lossless.py b/tests/ixia/pfc/test_pfc_pause_lossless.py index b9714f35746..516fdbd14aa 100644 --- a/tests/ixia/pfc/test_pfc_pause_lossless.py +++ b/tests/ixia/pfc/test_pfc_pause_lossless.py @@ -6,7 +6,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_api, ixia_testbed + ixia_api_serv_user, ixia_api_serv_passwd, ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, all_prio_list, lossless_prio_list,\ lossy_prio_list from tests.common.reboot import reboot @@ -16,7 +16,7 @@ @pytest.mark.topology("tgen") -def test_pfc_pause_single_lossless_prio(ixia_api, +def test_pfc_pause_single_lossless_prio(snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -30,7 +30,7 @@ def test_pfc_pause_single_lossless_prio(ixia_api, Test if PFC can pause a single lossless priority Args: - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -58,7 +58,7 @@ def test_pfc_pause_single_lossless_prio(ixia_api, bg_prio_list = [p for p in all_prio_list] bg_prio_list.remove(lossless_prio) - run_pfc_test(api=ixia_api, + run_pfc_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, @@ -71,7 +71,7 @@ def test_pfc_pause_single_lossless_prio(ixia_api, prio_dscp_map=prio_dscp_map, test_traffic_pause=True) -def test_pfc_pause_multi_lossless_prio(ixia_api, +def test_pfc_pause_multi_lossless_prio(snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -85,7 +85,7 @@ def test_pfc_pause_multi_lossless_prio(ixia_api, Test if PFC can pause multiple lossless priorities Args: - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -109,7 +109,7 @@ def test_pfc_pause_multi_lossless_prio(ixia_api, test_prio_list = lossless_prio_list bg_prio_list = lossy_prio_list - run_pfc_test(api=ixia_api, + run_pfc_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, @@ -123,7 +123,7 @@ def test_pfc_pause_multi_lossless_prio(ixia_api, test_traffic_pause=True) @pytest.mark.parametrize('reboot_type', ['warm', 'cold', 'fast']) -def test_pfc_pause_single_lossless_prio_reboot(ixia_api, +def test_pfc_pause_single_lossless_prio_reboot(snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -175,7 +175,7 @@ def test_pfc_pause_single_lossless_prio_reboot(ixia_api, pytest_assert(wait_until(300, 20, duthost.critical_services_fully_started), "Not all critical services are fully started") - run_pfc_test(api=ixia_api, + run_pfc_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, @@ -189,7 +189,7 @@ def test_pfc_pause_single_lossless_prio_reboot(ixia_api, test_traffic_pause=True) @pytest.mark.parametrize('reboot_type', ['warm', 'cold', 'fast']) -def test_pfc_pause_multi_lossless_prio_reboot(ixia_api, +def test_pfc_pause_multi_lossless_prio_reboot(snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -237,7 +237,7 @@ def test_pfc_pause_multi_lossless_prio_reboot(ixia_api, pytest_assert(wait_until(300, 20, duthost.critical_services_fully_started), "Not all critical services are fully started") - run_pfc_test(api=ixia_api, + run_pfc_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, diff --git a/tests/ixia/pfc/test_pfc_pause_lossy.py b/tests/ixia/pfc/test_pfc_pause_lossy.py index 44e7ff87e3b..7064adf0006 100644 --- a/tests/ixia/pfc/test_pfc_pause_lossy.py +++ b/tests/ixia/pfc/test_pfc_pause_lossy.py @@ -6,7 +6,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_api, ixia_testbed + ixia_api_serv_user, ixia_api_serv_passwd, ixia_api, ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, all_prio_list, lossless_prio_list,\ lossy_prio_list from tests.common.reboot import reboot @@ -16,7 +16,7 @@ @pytest.mark.topology("tgen") -def test_pfc_pause_single_lossy_prio(ixia_api, +def test_pfc_pause_single_lossy_prio(snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -58,7 +58,7 @@ def test_pfc_pause_single_lossy_prio(ixia_api, bg_prio_list = [p for p in all_prio_list] bg_prio_list.remove(lossy_prio) - run_pfc_test(api=ixia_api, + run_pfc_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, @@ -71,7 +71,7 @@ def test_pfc_pause_single_lossy_prio(ixia_api, prio_dscp_map=prio_dscp_map, test_traffic_pause=False) -def test_pfc_pause_multi_lossy_prio(ixia_api, +def test_pfc_pause_multi_lossy_prio(snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -109,7 +109,7 @@ def test_pfc_pause_multi_lossy_prio(ixia_api, test_prio_list = lossy_prio_list bg_prio_list = lossless_prio_list - run_pfc_test(api=ixia_api, + run_pfc_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, @@ -123,7 +123,7 @@ def test_pfc_pause_multi_lossy_prio(ixia_api, test_traffic_pause=False) @pytest.mark.parametrize('reboot_type', ['warm', 'cold', 'fast']) -def test_pfc_pause_single_lossy_prio_reboot(ixia_api, +def test_pfc_pause_single_lossy_prio_reboot(snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -139,7 +139,7 @@ def test_pfc_pause_single_lossy_prio_reboot(ixia_api, Test if PFC will impact a single lossy priority after various kinds of reboots Args: - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -175,7 +175,7 @@ def test_pfc_pause_single_lossy_prio_reboot(ixia_api, pytest_assert(wait_until(300, 20, duthost.critical_services_fully_started), "Not all critical services are fully started") - run_pfc_test(api=ixia_api, + run_pfc_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, @@ -189,7 +189,7 @@ def test_pfc_pause_single_lossy_prio_reboot(ixia_api, test_traffic_pause=False) @pytest.mark.parametrize('reboot_type', ['warm', 'cold', 'fast']) -def test_pfc_pause_multi_lossy_prio_reboot(ixia_api, +def test_pfc_pause_multi_lossy_prio_reboot(snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -205,7 +205,7 @@ def test_pfc_pause_multi_lossy_prio_reboot(ixia_api, Test if PFC will impact multiple lossy priorities after various kinds of reboots Args: - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -237,7 +237,7 @@ def test_pfc_pause_multi_lossy_prio_reboot(ixia_api, pytest_assert(wait_until(300, 20, duthost.critical_services_fully_started), "Not all critical services are fully started") - run_pfc_test(api=ixia_api, + run_pfc_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, From 45ea427fccf810cca08f92c0caf9ef701b1ba2e2 Mon Sep 17 00:00:00 2001 From: Anish Date: Thu, 1 Apr 2021 15:42:09 +0000 Subject: [PATCH 2/6] updating pfc tests --- tests/ixia/pfc/files/helper.py | 6 +++--- tests/ixia/pfc/test_pfc_pause_lossless.py | 4 ++-- tests/ixia/pfc/test_pfc_pause_lossy.py | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/ixia/pfc/files/helper.py b/tests/ixia/pfc/files/helper.py index fa89e554b63..3772f77d4e3 100644 --- a/tests/ixia/pfc/files/helper.py +++ b/tests/ixia/pfc/files/helper.py @@ -5,7 +5,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_api + ixia_api_serv_user, ixia_api_serv_passwd 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, stop_pfcwd, disable_packet_aging @@ -225,9 +225,8 @@ def __gen_traffic(testbed_config, pause_flow.tx_rx.port.tx_name = testbed_config.ports[rx_port_id].name pause_flow.tx_rx.port.rx_name = testbed_config.ports[tx_port_id].name - pause_pkt = pause_flow.packet.pfcpause()[-1] - if global_pause: + pause_pkt = pause_flow.packet.ethernetpause()[-1] pause_pkt.src.value = '00:00:fa:ce:fa:ce' pause_pkt.dst.value = '01:80:C2:00:00:01' @@ -241,6 +240,7 @@ def __gen_traffic(testbed_config, vector = pfc_class_enable_vector(pause_prio_list) + pause_pkt = pause_flow.packet.pfcpause()[-1] pause_pkt.src.value = '00:00:fa:ce:fa:ce' pause_pkt.dst.value = '01:80:C2:00:00:01' pause_pkt.class_enable_vector.value = vector diff --git a/tests/ixia/pfc/test_pfc_pause_lossless.py b/tests/ixia/pfc/test_pfc_pause_lossless.py index 516fdbd14aa..c5b8b424f10 100644 --- a/tests/ixia/pfc/test_pfc_pause_lossless.py +++ b/tests/ixia/pfc/test_pfc_pause_lossless.py @@ -139,7 +139,7 @@ def test_pfc_pause_single_lossless_prio_reboot(snappi_api, Test if PFC can pause a single lossless priority even after various types of reboot Args: - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -205,7 +205,7 @@ def test_pfc_pause_multi_lossless_prio_reboot(snappi_api, Test if PFC can pause multiple lossless priorities even after various types of reboot Args: - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph diff --git a/tests/ixia/pfc/test_pfc_pause_lossy.py b/tests/ixia/pfc/test_pfc_pause_lossy.py index 7064adf0006..8b64f873b32 100644 --- a/tests/ixia/pfc/test_pfc_pause_lossy.py +++ b/tests/ixia/pfc/test_pfc_pause_lossy.py @@ -6,7 +6,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_api, ixia_testbed, snappi_api + ixia_api_serv_user, ixia_api_serv_passwd, ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, all_prio_list, lossless_prio_list,\ lossy_prio_list from tests.common.reboot import reboot @@ -30,7 +30,7 @@ def test_pfc_pause_single_lossy_prio(snappi_api, Test if PFC will impact a single lossy priority Args: - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -85,7 +85,7 @@ def test_pfc_pause_multi_lossy_prio(snappi_api, Test if PFC will impact multiple lossy priorities Args: - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph From 5402a24ae0f62c23e9135bc22b1f70f6736951b1 Mon Sep 17 00:00:00 2001 From: Anish Date: Thu, 1 Apr 2021 15:45:18 +0000 Subject: [PATCH 3/6] adding ecn tests --- tests/ixia/ecn/files/helper.py | 186 +++++++++++++--------------- tests/ixia/ecn/test_dequeue_ecn.py | 8 +- tests/ixia/ecn/test_red_accuracy.py | 8 +- 3 files changed, 97 insertions(+), 105 deletions(-) diff --git a/tests/ixia/ecn/files/helper.py b/tests/ixia/ecn/files/helper.py index a57823899c0..7fa14ad69b5 100644 --- a/tests/ixia/ecn/files/helper.py +++ b/tests/ixia/ecn/files/helper.py @@ -1,26 +1,17 @@ import time import dpkt +import logging from tests.common.helpers.assertions import pytest_assert from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_api + ixia_api_serv_user, ixia_api_serv_passwd 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, stop_pfcwd, disable_packet_aging -from abstract_open_traffic_generator.capture import CustomFilter, Capture,\ - BasicFilter -from abstract_open_traffic_generator.flow import DeviceTxRx, TxRx, Flow, Header,\ - Size, Rate,Duration, FixedSeconds, FixedPackets, PortTxRx, PfcPause -from abstract_open_traffic_generator.flow_ipv4 import Priority, Dscp -from abstract_open_traffic_generator.flow import Pattern as FieldPattern -from abstract_open_traffic_generator.flow import Ipv4 as Ipv4Header -from abstract_open_traffic_generator.flow import Ethernet as EthernetHeader -from abstract_open_traffic_generator.control import State, ConfigState,\ - FlowTransmitState, PortCaptureState -from abstract_open_traffic_generator.result import FlowRequest, CaptureRequest +logger = logging.getLogger(__name__) EXP_DURATION_SEC = 1 DATA_START_DELAY_SEC = 0.1 @@ -99,31 +90,26 @@ def run_ecn_test(api, capture_config = __config_capture_ip_pkt(testbed_config=testbed_config, port_id=port_id) """ Generate traffic config """ - flows = __gen_traffic(testbed_config=testbed_config, - port_id=port_id, - pause_flow_name=PAUSE_FLOW_NAME, - data_flow_name=DATA_FLOW_NAME, - prio=lossless_prio, - data_pkt_size=pkt_size, - data_pkt_cnt=pkt_cnt, - data_flow_delay_sec=DATA_START_DELAY_SEC, - exp_dur_sec=EXP_DURATION_SEC, - prio_dscp_map=prio_dscp_map) - - """ Tgen config = testbed config + flow config + capture config""" - config = testbed_config - config.flows = flows - config.captures = capture_config + __gen_traffic(testbed_config=testbed_config, + port_id=port_id, + pause_flow_name=PAUSE_FLOW_NAME, + data_flow_name=DATA_FLOW_NAME, + prio=lossless_prio, + data_pkt_size=pkt_size, + data_pkt_cnt=pkt_cnt, + data_flow_delay_sec=DATA_START_DELAY_SEC, + exp_dur_sec=EXP_DURATION_SEC, + prio_dscp_map=prio_dscp_map) """ Run traffic and capture packets """ - capture_port_name = capture_config[0].port_names[0] + capture_port_name = testbed_config.captures[0].port_names[0] result = [] for i in range(iters): pcap_file_name = '{}-{}.pcap'.format(capture_port_name, i) __run_traffic(api=api, - config=config, + config=testbed_config, all_flow_names=[PAUSE_FLOW_NAME, DATA_FLOW_NAME], exp_dur_sec=EXP_DURATION_SEC, capture_port_name=capture_port_name, @@ -166,38 +152,32 @@ def __gen_traffic(testbed_config, """ - result = list() - rx_port_id = port_id tx_port_id = (port_id + 1) % len(testbed_config.devices) - data_endpoint = DeviceTxRx( - tx_device_names=[testbed_config.devices[tx_port_id].name], - rx_device_names=[testbed_config.devices[rx_port_id].name], - ) + tx_device_names = [testbed_config.devices[tx_port_id].name] + rx_device_names = [testbed_config.devices[rx_port_id].name] data_flow_delay_nanosec = sec_to_nanosec(data_flow_delay_sec) """ Data Flow """ - ip_prio = Priority(Dscp(phb=FieldPattern(choice=prio_dscp_map[prio]), - ecn=FieldPattern(choice=Dscp.ECN_CAPABLE_TRANSPORT_1))) - pfc_queue = FieldPattern([prio]) - - data_flow = Flow( - name=data_flow_name, - tx_rx=TxRx(data_endpoint), - packet=[ - Header(choice=EthernetHeader(pfc_queue=pfc_queue)), - Header(choice=Ipv4Header(priority=ip_prio)) - ], - size=Size(data_pkt_size), - rate=Rate('line', 100), - duration=Duration(FixedPackets(packets=data_pkt_cnt, - delay=data_flow_delay_nanosec, - delay_unit='nanoseconds')) - ) - - result.append(data_flow) + data_flow = testbed_config.flows.flow(name=data_flow_name)[-1] + data_flow.tx_rx.device.tx_names = tx_device_names + data_flow.tx_rx.device.rx_names = rx_device_names + + eth, ipv4 = data_flow.packet.ethernet().ipv4() + eth.pfc_queue.value = prio + ipv4.priority.choice = ipv4.priority.DSCP + ipv4.priority.dscp.phb.values = prio_dscp_map[prio] + ipv4.priority.dscp.ecn.value = ( + ipv4.priority.dscp.ecn.CAPABLE_TRANSPORT_1) + + data_flow.size.fixed = data_pkt_size + data_flow.rate.percentage = 100 + data_flow.duration.fixed_packets.packets = data_pkt_cnt + data_flow.duration.fixed_packets.delay = data_flow_delay_nanosec + data_flow.duration.fixed_packets.delay_unit = ( + data_flow.duration.fixed_packets.NANOSECONDS) """ PFC Pause Storm """ pause_time = [] @@ -208,42 +188,36 @@ def __gen_traffic(testbed_config, pause_time.append('0000') vector = pfc_class_enable_vector([prio]) - pause_pkt = Header(PfcPause( - dst=FieldPattern(choice='01:80:C2:00:00:01'), - src=FieldPattern(choice='00:00:fa:ce:fa:ce'), - class_enable_vector=FieldPattern(choice=vector), - pause_class_0=FieldPattern(choice=pause_time[0]), - pause_class_1=FieldPattern(choice=pause_time[1]), - pause_class_2=FieldPattern(choice=pause_time[2]), - pause_class_3=FieldPattern(choice=pause_time[3]), - pause_class_4=FieldPattern(choice=pause_time[4]), - pause_class_5=FieldPattern(choice=pause_time[5]), - pause_class_6=FieldPattern(choice=pause_time[6]), - pause_class_7=FieldPattern(choice=pause_time[7]), - )) - + pause_flow = testbed_config.flows.flow(name=pause_flow_name)[-1] """ Pause frames are sent from the RX port """ - pause_src_point = PortTxRx(tx_port_name=testbed_config.ports[rx_port_id].name, - rx_port_name=testbed_config.ports[tx_port_id].name) + pause_flow.tx_rx.port.tx_name = testbed_config.ports[rx_port_id].name + pause_flow.tx_rx.port.rx_name = testbed_config.ports[tx_port_id].name + + pause_pkt = pause_flow.packet.pfcpause()[-1] + + pause_pkt.src.value = '00:00:fa:ce:fa:ce' + pause_pkt.dst.value = '01:80:C2:00:00:01' + pause_pkt.class_enable_vector.value = vector + pause_pkt.pause_class_0.value = pause_time[0] + pause_pkt.pause_class_1.value = pause_time[1] + pause_pkt.pause_class_2.value = pause_time[2] + pause_pkt.pause_class_3.value = pause_time[3] + pause_pkt.pause_class_4.value = pause_time[4] + pause_pkt.pause_class_5.value = pause_time[5] + pause_pkt.pause_class_6.value = pause_time[6] + pause_pkt.pause_class_7.value = pause_time[7] speed_str = testbed_config.layer1[0].speed speed_gbps = int(speed_str.split('_')[1]) pause_dur = 65535 * 64 * 8.0 / (speed_gbps * 1e9) pps = int(2 / pause_dur) - pause_flow = Flow( - name=pause_flow_name, - tx_rx=TxRx(pause_src_point), - packet=[pause_pkt], - size=Size(64), - rate=Rate('pps', value=pps), - duration=Duration(FixedSeconds(seconds=exp_dur_sec, - delay=0, - delay_unit='nanoseconds')) - ) - - result.append(pause_flow) - return result + pause_flow.rate.pps = pps + pause_flow.size.fixed = 64 + pause_flow.duration.fixed_seconds.seconds = exp_dur_sec + pause_flow.duration.fixed_seconds.delay = 0 + pause_flow.duration.fixed_seconds.delay_unit = ( + pause_flow.duration.fixed_seconds.NANOSECONDS) def __config_capture_ip_pkt(testbed_config, port_id): @@ -259,12 +233,15 @@ def __config_capture_ip_pkt(testbed_config, port_id): """ """ We only capture IP packets """ - ip_filter = CustomFilter(filter='40', mask='0f', offset=14) - result = [Capture(name='rx_capture', - port_names=[testbed_config.ports[port_id].name], - choice=[BasicFilter(ip_filter)], - enable=True)] - return result + cap = testbed_config.captures.capture(name='rx_capture')[-1] + cap.port_names = [testbed_config.ports[port_id].name] + cap.format = cap.PCAP + + ip_filter, = cap.filters.filter() + ip_filter.custom.value = '40' + ip_filter.custom.offset = 14 + ip_filter.custom.mask = '0f' + def __run_traffic(api, config, @@ -285,21 +262,29 @@ def __run_traffic(api, Returns: N/A """ - api.set_state(State(ConfigState(config=config, state='set'))) + api.set_config(config) - api.set_state(State(PortCaptureState(port_names=[capture_port_name], - state='start'))) + cs = api.capture_state() + cs.port_names = [capture_port_name] + cs.state = cs.START + api.set_capture_state(cs) - api.set_state(State(FlowTransmitState(state='start'))) + logger.info('Starting transmit on all flows ...') + ts = api.transmit_state() + ts.state = ts.START + api.set_transmit_state(ts) time.sleep(exp_dur_sec) attempts = 0 max_attempts = 20 while attempts < max_attempts: - rows = api.get_flow_results(FlowRequest(flow_names=all_flow_names)) + request = api.metrics_request() + request.flow.flow_names = all_flow_names + rows = api.get_metrics(request).flow_metrics + """ If all the flows have stopped """ - transmit_states = [row['transmit'] for row in rows] + transmit_states = [row.transmit for row in rows] if len(rows) == len(all_flow_names) and\ list(set(transmit_states)) == ['stopped']: time.sleep(IXIA_POLL_DELAY_SEC) @@ -312,12 +297,19 @@ def __run_traffic(api, "Flows do not stop in {} seconds".format(max_attempts)) """ Dump captured packets """ - pcap_bytes = api.get_capture_results(CaptureRequest(port_name=capture_port_name)) + request = api.capture_request() + request.port_name = capture_port_name + pcap_bytes = api.get_capture(request) + pcap_bytes = pcap_bytes.getvalue() + with open(pcap_file_name, 'wb') as fid: fid.write(pcap_bytes) """ Stop all the flows """ - api.set_state(State(FlowTransmitState(state='stop'))) + logger.info('Stop transmit on all flows ...') + ts = api.transmit_state() + ts.state = ts.STOP + api.set_transmit_state(ts) def __get_ip_pkts(pcap_file_name): diff --git a/tests/ixia/ecn/test_dequeue_ecn.py b/tests/ixia/ecn/test_dequeue_ecn.py index 4031ffe3016..e11f946457b 100644 --- a/tests/ixia/ecn/test_dequeue_ecn.py +++ b/tests/ixia/ecn/test_dequeue_ecn.py @@ -4,7 +4,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_api, ixia_testbed + ixia_api_serv_user, ixia_api_serv_passwd, ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, lossless_prio_list from files.helper import run_ecn_test, is_ecn_marked @@ -12,7 +12,7 @@ @pytest.mark.topology("tgen") def test_dequeue_ecn(request, - ixia_api, + snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -26,7 +26,7 @@ def test_dequeue_ecn(request, Args: request (pytest fixture): pytest request object - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -57,7 +57,7 @@ def test_dequeue_ecn(request, pkt_size = 1024 pkt_cnt = 100 - ip_pkts = run_ecn_test(api=ixia_api, + ip_pkts = run_ecn_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, diff --git a/tests/ixia/ecn/test_red_accuracy.py b/tests/ixia/ecn/test_red_accuracy.py index 3a9b6b11087..6c23ba01954 100644 --- a/tests/ixia/ecn/test_red_accuracy.py +++ b/tests/ixia/ecn/test_red_accuracy.py @@ -5,7 +5,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_api, ixia_testbed + ixia_api_serv_user, ixia_api_serv_passwd, ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, lossless_prio_list from files.helper import run_ecn_test, is_ecn_marked @@ -13,7 +13,7 @@ @pytest.mark.topology("tgen") def test_red_accuracy(request, - ixia_api, + snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -28,7 +28,7 @@ def test_red_accuracy(request, Args: request (pytest fixture): pytest request object - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -61,7 +61,7 @@ def test_red_accuracy(request, iters = 100 result_file_name = 'result.txt' - ip_pkts_list = run_ecn_test(api=ixia_api, + ip_pkts_list = run_ecn_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, From 307fc996e036d63e11c50827a194f430279d3257 Mon Sep 17 00:00:00 2001 From: Anish Date: Thu, 1 Apr 2021 15:57:56 +0000 Subject: [PATCH 4/6] adding pfcwd tests --- tests/ixia/pfcwd/files/pfcwd_basic_helper.py | 166 ++++--- .../pfcwd/files/pfcwd_multi_node_helper.py | 424 ++++++++---------- .../files/pfcwd_runtime_traffic_helper.py | 95 ++-- .../pfcwd/test_pfcwd_2sender_2receiver.py | 8 +- tests/ixia/pfcwd/test_pfcwd_a2a.py | 8 +- tests/ixia/pfcwd/test_pfcwd_basic.py | 38 +- tests/ixia/pfcwd/test_pfcwd_m2o.py | 8 +- .../ixia/pfcwd/test_pfcwd_runtime_traffic.py | 8 +- 8 files changed, 360 insertions(+), 395 deletions(-) diff --git a/tests/ixia/pfcwd/files/pfcwd_basic_helper.py b/tests/ixia/pfcwd/files/pfcwd_basic_helper.py index fb9d309d3ba..76fce368b85 100644 --- a/tests/ixia/pfcwd/files/pfcwd_basic_helper.py +++ b/tests/ixia/pfcwd/files/pfcwd_basic_helper.py @@ -1,25 +1,19 @@ import time from math import ceil +import logging from tests.common.helpers.assertions import pytest_assert from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_api + ixia_api_serv_user, ixia_api_serv_passwd from tests.common.ixia.ixia_helpers import get_dut_port_id from tests.common.ixia.common_helpers import pfc_class_enable_vector,\ get_pfcwd_poll_interval, get_pfcwd_detect_time, get_pfcwd_restore_time,\ enable_packet_aging, start_pfcwd -from abstract_open_traffic_generator.flow import DeviceTxRx, TxRx, Flow, Header,\ - Size, Rate,Duration, FixedSeconds, FixedPackets, PortTxRx, PfcPause -from abstract_open_traffic_generator.flow_ipv4 import Priority, Dscp -from abstract_open_traffic_generator.flow import Pattern as FieldPattern -from abstract_open_traffic_generator.flow import Ipv4 as Ipv4Header -from abstract_open_traffic_generator.flow import Ethernet as EthernetHeader -from abstract_open_traffic_generator.control import State, ConfigState,\ - FlowTransmitState -from abstract_open_traffic_generator.result import FlowRequest + +logger = logging.getLogger(__name__) PAUSE_FLOW_NAME = "Pause Storm" DATA_FLOW1_NAME = "Data Flow 1" @@ -102,25 +96,24 @@ def run_pfcwd_basic_test(api, exp_dur_sec = flow2_delay_sec + flow2_dur_sec + 1 """ Generate traffic config """ - flows = __gen_traffic(testbed_config=testbed_config, - port_id=port_id, - pause_flow_name=PAUSE_FLOW_NAME, - pause_flow_dur_sec=pfc_storm_dur_sec, - data_flow_name_list=[DATA_FLOW1_NAME, DATA_FLOW2_NAME], - data_flow_delay_sec_list=[flow1_delay_sec, flow2_delay_sec], - data_flow_dur_sec_list=[flow1_dur_sec, flow2_dur_sec], - data_pkt_size=DATA_PKT_SIZE, - prio_list=prio_list, - prio_dscp_map=prio_dscp_map) + __gen_traffic(testbed_config=testbed_config, + port_id=port_id, + pause_flow_name=PAUSE_FLOW_NAME, + pause_flow_dur_sec=pfc_storm_dur_sec, + data_flow_name_list=[DATA_FLOW1_NAME, DATA_FLOW2_NAME], + data_flow_delay_sec_list=[flow1_delay_sec, flow2_delay_sec], + data_flow_dur_sec_list=[flow1_dur_sec, flow2_dur_sec], + data_pkt_size=DATA_PKT_SIZE, + prio_list=prio_list, + prio_dscp_map=prio_dscp_map) """ Tgen config = testbed config + flow config """ - config = testbed_config - config.flows = flows + flows = testbed_config.flows all_flow_names = [flow.name for flow in flows] flow_stats = __run_traffic(api=api, - config=config, + config=testbed_config, all_flow_names=all_flow_names, exp_dur_sec=exp_dur_sec) @@ -160,17 +153,20 @@ def __gen_traffic(testbed_config, flows configurations (list): the list should have configurations of len(prio_list) * 2 data flows, and a pause storm. """ - result = list() rx_port_id = port_id tx_port_id = (port_id + 1) % len(testbed_config.devices) - data_endpoint = DeviceTxRx( - tx_device_names=[testbed_config.devices[tx_port_id].name], - rx_device_names=[testbed_config.devices[rx_port_id].name], - ) + tx_device_names = [testbed_config.devices[tx_port_id].name] + rx_device_names = [testbed_config.devices[rx_port_id].name] """ PFC storm """ + pause_flow = testbed_config.flows.flow(name=pause_flow_name)[-1] + pause_flow.tx_rx.port.tx_name = testbed_config.ports[rx_port_id].name + pause_flow.tx_rx.port.rx_name = testbed_config.ports[tx_port_id].name + + pause_pkt = pause_flow.packet.pfcpause()[-1] + pause_time = [] for x in range(8): if x in prio_list: @@ -180,22 +176,17 @@ def __gen_traffic(testbed_config, vector = pfc_class_enable_vector(prio_list) - pause_pkt = Header(PfcPause( - dst=FieldPattern(choice='01:80:C2:00:00:01'), - src=FieldPattern(choice='00:00:fa:ce:fa:ce'), - class_enable_vector=FieldPattern(choice=vector), - pause_class_0=FieldPattern(choice=pause_time[0]), - pause_class_1=FieldPattern(choice=pause_time[1]), - pause_class_2=FieldPattern(choice=pause_time[2]), - pause_class_3=FieldPattern(choice=pause_time[3]), - pause_class_4=FieldPattern(choice=pause_time[4]), - pause_class_5=FieldPattern(choice=pause_time[5]), - pause_class_6=FieldPattern(choice=pause_time[6]), - pause_class_7=FieldPattern(choice=pause_time[7]), - )) - - pause_src_point = PortTxRx(tx_port_name=testbed_config.ports[rx_port_id].name, - rx_port_name=testbed_config.ports[tx_port_id].name) + pause_pkt.src.value = '00:00:fa:ce:fa:ce' + pause_pkt.dst.value = '01:80:C2:00:00:01' + pause_pkt.class_enable_vector.value = vector + pause_pkt.pause_class_0.value = pause_time[0] + pause_pkt.pause_class_1.value = pause_time[1] + pause_pkt.pause_class_2.value = pause_time[2] + pause_pkt.pause_class_3.value = pause_time[3] + pause_pkt.pause_class_4.value = pause_time[4] + pause_pkt.pause_class_5.value = pause_time[5] + pause_pkt.pause_class_6.value = pause_time[6] + pause_pkt.pause_class_7.value = pause_time[7] speed_str = testbed_config.layer1[0].speed speed_gbps = int(speed_str.split('_')[1]) @@ -203,16 +194,10 @@ def __gen_traffic(testbed_config, pps = int(2 / pause_dur) pause_pkt_cnt = pps * pause_flow_dur_sec - pause_flow = Flow( - name=pause_flow_name, - tx_rx=TxRx(pause_src_point), - packet=[pause_pkt], - size=Size(64), - rate=Rate('pps', value=pps), - duration=Duration(FixedPackets(packets=pause_pkt_cnt, delay=0)) - ) - - result.append(pause_flow) + pause_flow.rate.pps = pps + pause_flow.size.fixed = 64 + pause_flow.duration.fixed_packets.packets = pause_pkt_cnt + pause_flow.duration.fixed_packets.delay = 0 data_flow_rate_percent = int(100 / len(prio_list)) @@ -221,27 +206,27 @@ def __gen_traffic(testbed_config, """ For each priority """ for prio in prio_list: - ip_prio = Priority(Dscp(phb=FieldPattern(choice=prio_dscp_map[prio]), - ecn=FieldPattern(choice=Dscp.ECN_CAPABLE_TRANSPORT_1))) - pfc_queue = FieldPattern([prio]) - - data_flow = Flow( - name='{} Prio {}'.format(data_flow_name_list[i], prio), - tx_rx=TxRx(data_endpoint), - packet=[ - Header(choice=EthernetHeader(pfc_queue=pfc_queue)), - Header(choice=Ipv4Header(priority=ip_prio)) - ], - size=Size(data_pkt_size), - rate=Rate('line', data_flow_rate_percent), - duration=Duration(FixedSeconds(seconds=data_flow_dur_sec_list[i], - delay=sec_to_nanosec(data_flow_delay_sec_list[i]), - delay_unit='nanoseconds')) - ) - - result.append(data_flow) - - return result + data_flow = testbed_config.flows.flow( + name='{} Prio {}'.format(data_flow_name_list[i], prio))[-1] + data_flow.tx_rx.device.tx_names = tx_device_names + data_flow.tx_rx.device.rx_names = rx_device_names + + eth, ipv4 = data_flow.packet.ethernet().ipv4() + eth.pfc_queue.value = prio + ipv4.priority.choice = ipv4.priority.DSCP + ipv4.priority.dscp.phb.values = prio_dscp_map[prio] + ipv4.priority.dscp.ecn.value = ( + ipv4.priority.dscp.ecn.CAPABLE_TRANSPORT_1) + + data_flow.size.fixed = data_pkt_size + data_flow.rate.percentage = data_flow_rate_percent + data_flow.duration.fixed_seconds.seconds = ( + data_flow_dur_sec_list[i]) + data_flow.duration.fixed_seconds.delay = sec_to_nanosec( + data_flow_delay_sec_list[i]) + data_flow.duration.fixed_seconds.delay_unit = ( + data_flow.duration.fixed_seconds.NANOSECONDS) + def __run_traffic(api, config, all_flow_names, exp_dur_sec): """ @@ -256,17 +241,23 @@ def __run_traffic(api, config, all_flow_names, exp_dur_sec): Returns: per-flow statistics (list) """ - api.set_state(State(ConfigState(config=config, state='set'))) - api.set_state(State(FlowTransmitState(state='start'))) + + api.set_config(config) + logger.info('Starting transmit on all flows ...') + ts = api.transmit_state() + ts.state = ts.START + api.set_transmit_state(ts) time.sleep(exp_dur_sec) attempts = 0 max_attempts = 20 while attempts < max_attempts: - rows = api.get_flow_results(FlowRequest(flow_names=all_flow_names)) + request = api.metrics_request() + request.flow.flow_names = all_flow_names + rows = api.get_metrics(request).flow_metrics """ If all the flows have stopped """ - transmit_states = [row['transmit'] for row in rows] + transmit_states = [row.transmit for row in rows] if len(rows) == len(all_flow_names) and\ list(set(transmit_states)) == ['stopped']: time.sleep(IXIA_POLL_DELAY_SEC) @@ -279,11 +270,18 @@ def __run_traffic(api, config, all_flow_names, exp_dur_sec): "Flows do not stop in {} seconds".format(max_attempts)) """ Dump per-flow statistics """ - rows = api.get_flow_results(FlowRequest(flow_names=all_flow_names)) - api.set_state(State(FlowTransmitState(state='stop'))) + request = api.metrics_request() + request.flow.flow_names = all_flow_names + rows = api.get_metrics(request).flow_metrics + + logger.info('Stop transmit on all flows ...') + ts = api.transmit_state() + ts.state = ts.STOP + api.set_transmit_state(ts) return rows + def __verify_results(rows, data_flow_name_list, data_flow_min_loss_rate_list, @@ -305,9 +303,9 @@ def __verify_results(rows, data_flow_rx_frames_list = num_data_flows * [0] for row in rows: - flow_name = row['name'] - tx_frames = row['frames_tx'] - rx_frames = row['frames_rx'] + flow_name = row.name + tx_frames = row.frames_tx + rx_frames = row.frames_rx for i in range(num_data_flows): if data_flow_name_list[i] in flow_name: diff --git a/tests/ixia/pfcwd/files/pfcwd_multi_node_helper.py b/tests/ixia/pfcwd/files/pfcwd_multi_node_helper.py index 0dbf7038aaf..194395bd89f 100644 --- a/tests/ixia/pfcwd/files/pfcwd_multi_node_helper.py +++ b/tests/ixia/pfcwd/files/pfcwd_multi_node_helper.py @@ -1,24 +1,19 @@ import time from math import ceil from itertools import permutations +import logging from tests.common.helpers.assertions import pytest_assert, pytest_require from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_api + ixia_api_serv_user, ixia_api_serv_passwd from tests.common.ixia.ixia_helpers import get_dut_port_id from tests.common.ixia.common_helpers import pfc_class_enable_vector,\ start_pfcwd, enable_packet_aging, get_pfcwd_poll_interval, get_pfcwd_detect_time -from abstract_open_traffic_generator.flow import DeviceTxRx, TxRx, Flow, Header,\ - Size, Rate, Duration, FixedSeconds, FixedPackets, PortTxRx, PfcPause -from abstract_open_traffic_generator.flow_ipv4 import Priority, Dscp -from abstract_open_traffic_generator.flow import Pattern as FieldPattern -from abstract_open_traffic_generator.flow import Ipv4 as Ipv4Header -from abstract_open_traffic_generator.flow import Ethernet as EthernetHeader -from abstract_open_traffic_generator.control import State, ConfigState, FlowTransmitState -from abstract_open_traffic_generator.result import FlowRequest +logger = logging.getLogger(__name__) + PAUSE_FLOW_NAME = 'Pause Storm' TEST_FLOW_NAME = 'Test Flow' @@ -101,20 +96,20 @@ def run_pfcwd_multi_node_test(api, (num_devices - 1) / \ len(bg_prio_list)) - flows = __gen_a2a_traffic(testbed_config=testbed_config, - port_id=port_id, - pause_flow_name=PAUSE_FLOW_NAME, - pause_prio_list=pause_prio_list, - test_flow_name=TEST_FLOW_NAME, - test_flow_prio_list=test_prio_list, - test_flow_rate_percent=test_flow_rate_percent, - bg_flow_name=BG_FLOW_NAME, - bg_flow_prio_list=bg_prio_list, - bg_flow_rate_percent=bg_flow_rate_percent, - data_flow_dur_sec=exp_dur_sec, - pfc_storm_dur_sec=pfc_storm_dur_sec, - data_pkt_size=DATA_PKT_SIZE, - prio_dscp_map=prio_dscp_map) + __gen_a2a_traffic(testbed_config=testbed_config, + port_id=port_id, + pause_flow_name=PAUSE_FLOW_NAME, + pause_prio_list=pause_prio_list, + test_flow_name=TEST_FLOW_NAME, + test_flow_prio_list=test_prio_list, + test_flow_rate_percent=test_flow_rate_percent, + bg_flow_name=BG_FLOW_NAME, + bg_flow_prio_list=bg_prio_list, + bg_flow_rate_percent=bg_flow_rate_percent, + data_flow_dur_sec=exp_dur_sec, + pfc_storm_dur_sec=pfc_storm_dur_sec, + data_pkt_size=DATA_PKT_SIZE, + prio_dscp_map=prio_dscp_map) elif pattern == "many to one": test_flow_rate_percent = int(TEST_FLOW_AGGR_RATE_PERCENT / \ @@ -125,20 +120,20 @@ def run_pfcwd_multi_node_test(api, (num_devices - 1) / \ len(bg_prio_list)) - flows = __gen_m2o_traffic(testbed_config=testbed_config, - port_id=port_id, - pause_flow_name=PAUSE_FLOW_NAME, - pause_prio_list=pause_prio_list, - test_flow_name=TEST_FLOW_NAME, - test_flow_prio_list=test_prio_list, - test_flow_rate_percent=test_flow_rate_percent, - bg_flow_name=BG_FLOW_NAME, - bg_flow_prio_list=bg_prio_list, - bg_flow_rate_percent=bg_flow_rate_percent, - data_flow_dur_sec=exp_dur_sec, - pfc_storm_dur_sec=pfc_storm_dur_sec, - data_pkt_size=DATA_PKT_SIZE, - prio_dscp_map=prio_dscp_map) + __gen_m2o_traffic(testbed_config=testbed_config, + port_id=port_id, + pause_flow_name=PAUSE_FLOW_NAME, + pause_prio_list=pause_prio_list, + test_flow_name=TEST_FLOW_NAME, + test_flow_prio_list=test_prio_list, + test_flow_rate_percent=test_flow_rate_percent, + bg_flow_name=BG_FLOW_NAME, + bg_flow_prio_list=bg_prio_list, + bg_flow_rate_percent=bg_flow_rate_percent, + data_flow_dur_sec=exp_dur_sec, + pfc_storm_dur_sec=pfc_storm_dur_sec, + data_pkt_size=DATA_PKT_SIZE, + prio_dscp_map=prio_dscp_map) elif pattern == "2 sender 2 receiver": test_flow_rate_percent = int(TEST_FLOW_AGGR_RATE_PERCENT / \ @@ -148,34 +143,33 @@ def run_pfcwd_multi_node_test(api, 2.0 / \ len(bg_prio_list)) - flows = __gen_2sender_2receiver_traffic(testbed_config=testbed_config, - port_id=port_id, - pause_flow_name=PAUSE_FLOW_NAME, - pause_prio_list=pause_prio_list, - test_flow_name=TEST_FLOW_NAME, - test_flow_prio_list=test_prio_list, - test_flow_rate_percent=test_flow_rate_percent, - bg_flow_name=BG_FLOW_NAME, - bg_flow_prio_list=bg_prio_list, - bg_flow_rate_percent=bg_flow_rate_percent, - data_flow_dur_sec=exp_dur_sec, - pfc_storm_dur_sec=pfc_storm_dur_sec, - data_pkt_size=DATA_PKT_SIZE, - prio_dscp_map=prio_dscp_map) + __gen_2sender_2receiver_traffic(testbed_config=testbed_config, + port_id=port_id, + pause_flow_name=PAUSE_FLOW_NAME, + pause_prio_list=pause_prio_list, + test_flow_name=TEST_FLOW_NAME, + test_flow_prio_list=test_prio_list, + test_flow_rate_percent=test_flow_rate_percent, + bg_flow_name=BG_FLOW_NAME, + bg_flow_prio_list=bg_prio_list, + bg_flow_rate_percent=bg_flow_rate_percent, + data_flow_dur_sec=exp_dur_sec, + pfc_storm_dur_sec=pfc_storm_dur_sec, + data_pkt_size=DATA_PKT_SIZE, + prio_dscp_map=prio_dscp_map) """ Tgen config = testbed config + flow config """ - config = testbed_config - config.flows = flows + flows = testbed_config.flows all_flow_names = [flow.name for flow in flows] flow_stats = __run_traffic(api=api, - config=config, + config=testbed_config, all_flow_names=all_flow_names, exp_dur_sec=exp_dur_sec) - speed_str = config.layer1[0].speed + speed_str = testbed_config.layer1[0].speed speed_gbps = int(speed_str.split('_')[1]) __verify_results(rows=flow_stats, @@ -272,17 +266,13 @@ def __gen_2sender_2receiver_traffic(testbed_config, Returns: flows configurations (list) """ - result = list() - """ Generate a PFC pause storm """ pause_port_id = port_id - pause_flow = __gen_pause_flow(testbed_config=testbed_config, - src_port_id=pause_port_id, - flow_name=pause_flow_name, - pause_prio_list=pause_prio_list, - flow_dur_sec=pfc_storm_dur_sec) - - result.append(pause_flow) + __gen_pause_flow(testbed_config=testbed_config, + src_port_id=pause_port_id, + flow_name=pause_flow_name, + pause_prio_list=pause_prio_list, + flow_dur_sec=pfc_storm_dur_sec) """ Generate bi-birectional data flows between [port_id+2] and @@ -294,31 +284,28 @@ def __gen_2sender_2receiver_traffic(testbed_config, perm = permutations([one_port_id_list, two_port_id_list]) for src_port_id_list, dst_port_id_list in list(perm): - test_flows = __gen_data_flows(testbed_config=testbed_config, - src_port_id_list=src_port_id_list, - dst_port_id_list=dst_port_id_list, - flow_name_prefix=TEST_FLOW_NAME, - flow_prio_list=test_flow_prio_list, - flow_rate_percent=test_flow_rate_percent, - flow_dur_sec=data_flow_dur_sec, - data_pkt_size=data_pkt_size, - prio_dscp_map=prio_dscp_map) - - result.extend(test_flows) - - bg_flows = __gen_data_flows(testbed_config=testbed_config, - src_port_id_list=src_port_id_list, - dst_port_id_list=dst_port_id_list, - flow_name_prefix=BG_FLOW_NAME, - flow_prio_list=bg_flow_prio_list, - flow_rate_percent=bg_flow_rate_percent, - flow_dur_sec=data_flow_dur_sec, - data_pkt_size=data_pkt_size, - prio_dscp_map=prio_dscp_map) - - result.extend(bg_flows) - - return result + # Generate test flows + __gen_data_flows(testbed_config=testbed_config, + src_port_id_list=src_port_id_list, + dst_port_id_list=dst_port_id_list, + flow_name_prefix=TEST_FLOW_NAME, + flow_prio_list=test_flow_prio_list, + flow_rate_percent=test_flow_rate_percent, + flow_dur_sec=data_flow_dur_sec, + data_pkt_size=data_pkt_size, + prio_dscp_map=prio_dscp_map) + + # Generate background flows + __gen_data_flows(testbed_config=testbed_config, + src_port_id_list=src_port_id_list, + dst_port_id_list=dst_port_id_list, + flow_name_prefix=BG_FLOW_NAME, + flow_prio_list=bg_flow_prio_list, + flow_rate_percent=bg_flow_rate_percent, + flow_dur_sec=data_flow_dur_sec, + data_pkt_size=data_pkt_size, + prio_dscp_map=prio_dscp_map) + def __gen_a2a_traffic(testbed_config, port_id, @@ -358,50 +345,42 @@ def __gen_a2a_traffic(testbed_config, Returns: flows configurations (list) """ - result = list() - """ Generate a PFC pause storm """ pause_port_id = port_id - pause_flow = __gen_pause_flow(testbed_config=testbed_config, - src_port_id=pause_port_id, - flow_name=pause_flow_name, - pause_prio_list=pause_prio_list, - flow_dur_sec=pfc_storm_dur_sec) - - result.append(pause_flow) + __gen_pause_flow(testbed_config=testbed_config, + src_port_id=pause_port_id, + flow_name=pause_flow_name, + pause_prio_list=pause_prio_list, + flow_dur_sec=pfc_storm_dur_sec) """ Generate all-to-all traffic pattern """ num_devices = len(testbed_config.devices) for src_port_id in range(num_devices): src_port_id_list = [src_port_id] - dst_port_id_list =[i for i in range(num_devices) if i != src_port_id] - - test_flows = __gen_data_flows(testbed_config=testbed_config, - src_port_id_list=src_port_id_list, - dst_port_id_list=dst_port_id_list, - flow_name_prefix=TEST_FLOW_NAME, - flow_prio_list=test_flow_prio_list, - flow_rate_percent=test_flow_rate_percent, - flow_dur_sec=data_flow_dur_sec, - data_pkt_size=data_pkt_size, - prio_dscp_map=prio_dscp_map) - - result.extend(test_flows) - - bg_flows = __gen_data_flows(testbed_config=testbed_config, - src_port_id_list=src_port_id_list, - dst_port_id_list=dst_port_id_list, - flow_name_prefix=BG_FLOW_NAME, - flow_prio_list=bg_flow_prio_list, - flow_rate_percent=bg_flow_rate_percent, - flow_dur_sec=data_flow_dur_sec, - data_pkt_size=data_pkt_size, - prio_dscp_map=prio_dscp_map) - - result.extend(bg_flows) - - return result + dst_port_id_list = [i for i in range(num_devices) if i != src_port_id] + + # Generate test flows + __gen_data_flows(testbed_config=testbed_config, + src_port_id_list=src_port_id_list, + dst_port_id_list=dst_port_id_list, + flow_name_prefix=TEST_FLOW_NAME, + flow_prio_list=test_flow_prio_list, + flow_rate_percent=test_flow_rate_percent, + flow_dur_sec=data_flow_dur_sec, + data_pkt_size=data_pkt_size, + prio_dscp_map=prio_dscp_map) + # Generate background flows + __gen_data_flows(testbed_config=testbed_config, + src_port_id_list=src_port_id_list, + dst_port_id_list=dst_port_id_list, + flow_name_prefix=BG_FLOW_NAME, + flow_prio_list=bg_flow_prio_list, + flow_rate_percent=bg_flow_rate_percent, + flow_dur_sec=data_flow_dur_sec, + data_pkt_size=data_pkt_size, + prio_dscp_map=prio_dscp_map) + def __gen_m2o_traffic(testbed_config, port_id, @@ -441,48 +420,40 @@ def __gen_m2o_traffic(testbed_config, Returns: flows configurations (list) """ - result = list() """ Generate a PFC pause storm """ pause_port_id = port_id - pause_flow = __gen_pause_flow(testbed_config=testbed_config, - src_port_id=pause_port_id, - flow_name=pause_flow_name, - pause_prio_list=pause_prio_list, - flow_dur_sec=pfc_storm_dur_sec) - - result.append(pause_flow) + __gen_pause_flow(testbed_config=testbed_config, + src_port_id=pause_port_id, + flow_name=pause_flow_name, + pause_prio_list=pause_prio_list, + flow_dur_sec=pfc_storm_dur_sec) """ Generate many-to-one traffic pattern """ num_devices = len(testbed_config.devices) - src_port_id_list =[i for i in range(num_devices) if i != port_id] + src_port_id_list = [i for i in range(num_devices) if i != port_id] dst_port_id_list = [port_id] - test_flows = __gen_data_flows(testbed_config=testbed_config, - src_port_id_list=src_port_id_list, - dst_port_id_list=dst_port_id_list, - flow_name_prefix=TEST_FLOW_NAME, - flow_prio_list=test_flow_prio_list, - flow_rate_percent=test_flow_rate_percent, - flow_dur_sec=data_flow_dur_sec, - data_pkt_size=data_pkt_size, - prio_dscp_map=prio_dscp_map) - - result.extend(test_flows) - - bg_flows = __gen_data_flows(testbed_config=testbed_config, - src_port_id_list=src_port_id_list, - dst_port_id_list=dst_port_id_list, - flow_name_prefix=BG_FLOW_NAME, - flow_prio_list=bg_flow_prio_list, - flow_rate_percent=bg_flow_rate_percent, - flow_dur_sec=data_flow_dur_sec, - data_pkt_size=data_pkt_size, - prio_dscp_map=prio_dscp_map) - - result.extend(bg_flows) + __gen_data_flows(testbed_config=testbed_config, + src_port_id_list=src_port_id_list, + dst_port_id_list=dst_port_id_list, + flow_name_prefix=TEST_FLOW_NAME, + flow_prio_list=test_flow_prio_list, + flow_rate_percent=test_flow_rate_percent, + flow_dur_sec=data_flow_dur_sec, + data_pkt_size=data_pkt_size, + prio_dscp_map=prio_dscp_map) + + __gen_data_flows(testbed_config=testbed_config, + src_port_id_list=src_port_id_list, + dst_port_id_list=dst_port_id_list, + flow_name_prefix=BG_FLOW_NAME, + flow_prio_list=bg_flow_prio_list, + flow_rate_percent=bg_flow_rate_percent, + flow_dur_sec=data_flow_dur_sec, + data_pkt_size=data_pkt_size, + prio_dscp_map=prio_dscp_map) - return result def __gen_data_flows(testbed_config, src_port_id_list, @@ -512,23 +483,20 @@ def __gen_data_flows(testbed_config, len(src_port_id_list) * len(dst_port_id_list) * len(flow_prio_list) data flows """ - flows = [] for src_port_id in src_port_id_list: for dst_port_id in dst_port_id_list: for prio in flow_prio_list: - flow = __gen_data_flow(testbed_config=testbed_config, - src_port_id=src_port_id, - dst_port_id=dst_port_id, - flow_name_prefix=flow_name_prefix, - flow_prio=prio, - flow_rate_percent=flow_rate_percent, - flow_dur_sec=flow_dur_sec, - data_pkt_size=data_pkt_size, - prio_dscp_map=prio_dscp_map) - flows.append(flow) - - return flows + __gen_data_flow(testbed_config=testbed_config, + src_port_id=src_port_id, + dst_port_id=dst_port_id, + flow_name_prefix=flow_name_prefix, + flow_prio=prio, + flow_rate_percent=flow_rate_percent, + flow_dur_sec=flow_dur_sec, + data_pkt_size=data_pkt_size, + prio_dscp_map=prio_dscp_map) + def __gen_data_flow(testbed_config, src_port_id, @@ -556,34 +524,29 @@ def __gen_data_flow(testbed_config, Returns: flow configuration (obj): including name, packet format, rate, ... """ - data_endpoint = DeviceTxRx( - tx_device_names=[testbed_config.devices[src_port_id].name], - rx_device_names=[testbed_config.devices[dst_port_id].name], - ) - - ip_prio = Priority(Dscp(phb=FieldPattern(choice=prio_dscp_map[flow_prio]), - ecn=FieldPattern(choice=Dscp.ECN_CAPABLE_TRANSPORT_1))) - - pfc_queue = FieldPattern([flow_prio]) + tx_device_names = [testbed_config.devices[src_port_id].name] + rx_device_names = [testbed_config.devices[dst_port_id].name] flow_name = __data_flow_name(name_prefix=flow_name_prefix, src_id=src_port_id, dst_id=dst_port_id, prio=flow_prio) - flow = Flow( - name=flow_name, - tx_rx=TxRx(data_endpoint), - packet=[ - Header(choice=EthernetHeader(pfc_queue=pfc_queue)), - Header(choice=Ipv4Header(priority=ip_prio)) - ], - size=Size(data_pkt_size), - rate=Rate('line', flow_rate_percent), - duration=Duration(FixedSeconds(seconds=flow_dur_sec)) - ) + data_flow = testbed_config.flows.flow(name=flow_name)[-1] + data_flow.tx_rx.device.tx_names = tx_device_names + data_flow.tx_rx.device.rx_names = rx_device_names + + eth, ipv4 = data_flow.packet.ethernet().ipv4() + eth.pfc_queue.value = flow_prio + ipv4.priority.choice = ipv4.priority.DSCP + ipv4.priority.dscp.phb.values = prio_dscp_map[flow_prio] + ipv4.priority.dscp.ecn.value = ( + ipv4.priority.dscp.ecn.CAPABLE_TRANSPORT_1) + + data_flow.size.fixed = data_pkt_size + data_flow.rate.percentage = flow_rate_percent + data_flow.duration.fixed_seconds.seconds = flow_dur_sec - return flow def __gen_pause_flow(testbed_config, src_port_id, @@ -612,24 +575,24 @@ def __gen_pause_flow(testbed_config, vector = pfc_class_enable_vector(pause_prio_list) - pause_pkt = Header(PfcPause( - dst=FieldPattern(choice='01:80:C2:00:00:01'), - src=FieldPattern(choice='00:00:fa:ce:fa:ce'), - class_enable_vector=FieldPattern(choice=vector), - pause_class_0=FieldPattern(choice=pause_time[0]), - pause_class_1=FieldPattern(choice=pause_time[1]), - pause_class_2=FieldPattern(choice=pause_time[2]), - pause_class_3=FieldPattern(choice=pause_time[3]), - pause_class_4=FieldPattern(choice=pause_time[4]), - pause_class_5=FieldPattern(choice=pause_time[5]), - pause_class_6=FieldPattern(choice=pause_time[6]), - pause_class_7=FieldPattern(choice=pause_time[7]), - )) - - + pause_flow = testbed_config.flows.flow(name=flow_name)[-1] dst_port_id = (src_port_id + 1) % len(testbed_config.devices) - pause_src_point = PortTxRx(tx_port_name=testbed_config.ports[src_port_id].name, - rx_port_name=testbed_config.ports[dst_port_id].name) + pause_flow.tx_rx.port.tx_name = testbed_config.ports[src_port_id].name + pause_flow.tx_rx.port.rx_name = testbed_config.ports[dst_port_id].name + + pause_pkt = pause_flow.packet.pfcpause()[-1] + + pause_pkt.src.value = '00:00:fa:ce:fa:ce' + pause_pkt.dst.value = '01:80:C2:00:00:01' + pause_pkt.class_enable_vector.value = vector + pause_pkt.pause_class_0.value = pause_time[0] + pause_pkt.pause_class_1.value = pause_time[1] + pause_pkt.pause_class_2.value = pause_time[2] + pause_pkt.pause_class_3.value = pause_time[3] + pause_pkt.pause_class_4.value = pause_time[4] + pause_pkt.pause_class_5.value = pause_time[5] + pause_pkt.pause_class_6.value = pause_time[6] + pause_pkt.pause_class_7.value = pause_time[7] """ The minimal fixed time duration in IXIA is 1 second. @@ -641,16 +604,11 @@ def __gen_pause_flow(testbed_config, pps = int(2 / pause_dur) pkt_cnt = pps * flow_dur_sec - pause_flow = Flow( - name=flow_name, - tx_rx=TxRx(pause_src_point), - packet=[pause_pkt], - size=Size(64), - rate=Rate('pps', value=pps), - duration=Duration(FixedPackets(packets=pkt_cnt, delay=0)) - ) + pause_flow.rate.pps = pps + pause_flow.size.fixed = 64 + pause_flow.duration.fixed_packets.packets = pkt_cnt + pause_flow.duration.fixed_packets.delay = 0 - return pause_flow def __run_traffic(api, config, all_flow_names, exp_dur_sec): """ @@ -665,18 +623,23 @@ def __run_traffic(api, config, all_flow_names, exp_dur_sec): Returns: per-flow statistics (list) """ - api.set_state(State(ConfigState(config=config, state='set'))) - api.set_state(State(FlowTransmitState(state='start'))) + api.set_config(config) + logger.info('Starting transmit on all flows ...') + ts = api.transmit_state() + ts.state = ts.START + api.set_transmit_state(ts) time.sleep(exp_dur_sec) attempts = 0 max_attempts = 20 while attempts < max_attempts: - rows = api.get_flow_results(FlowRequest(flow_names=all_flow_names)) + request = api.metrics_request() + request.flow.flow_names = all_flow_names + rows = api.get_metrics(request).flow_metrics """ If all the data flows have stopped """ - transmit_states = [row['transmit'] for row in rows] + transmit_states = [row.transmit for row in rows] if len(rows) == len(all_flow_names) and\ list(set(transmit_states)) == ['stopped']: time.sleep(IXIA_POLL_DELAY_SEC) @@ -689,11 +652,16 @@ def __run_traffic(api, config, all_flow_names, exp_dur_sec): "Flows do not stop in {} seconds".format(max_attempts)) """ Dump per-flow statistics """ - rows = api.get_flow_results(FlowRequest(flow_names=all_flow_names)) - api.set_state(State(FlowTransmitState(state='stop'))) - + request = api.metrics_request() + request.flow.flow_names = all_flow_names + rows = api.get_metrics(request).flow_metrics + logger.info('Stop transmit on all flows ...') + ts = api.transmit_state() + ts.state = ts.STOP + api.set_transmit_state(ts) return rows + def __verify_results(rows, speed_gbps, pause_flow_name, @@ -727,9 +695,9 @@ def __verify_results(rows, N/A """ for row in rows: - flow_name = row['name'] - tx_frames = row['frames_tx'] - rx_frames = row['frames_rx'] + flow_name = row.name + tx_frames = row.frames_tx + rx_frames = row.frames_rx if pause_flow_name in flow_name: """ PFC pause storm """ diff --git a/tests/ixia/pfcwd/files/pfcwd_runtime_traffic_helper.py b/tests/ixia/pfcwd/files/pfcwd_runtime_traffic_helper.py index a3c1260624e..27782f776c7 100644 --- a/tests/ixia/pfcwd/files/pfcwd_runtime_traffic_helper.py +++ b/tests/ixia/pfcwd/files/pfcwd_runtime_traffic_helper.py @@ -1,20 +1,13 @@ import time +import logging from tests.common.helpers.assertions import pytest_assert from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_api + ixia_api_serv_user, ixia_api_serv_passwd from tests.common.ixia.ixia_helpers import get_dut_port_id from tests.common.ixia.common_helpers import start_pfcwd, stop_pfcwd -from abstract_open_traffic_generator.flow import DeviceTxRx, TxRx, Flow, Header,\ - Size, Rate, Duration, FixedSeconds -from abstract_open_traffic_generator.flow_ipv4 import Priority, Dscp -from abstract_open_traffic_generator.flow import Pattern as FieldPattern -from abstract_open_traffic_generator.flow import Ipv4 as Ipv4Header -from abstract_open_traffic_generator.flow import Ethernet as EthernetHeader -from abstract_open_traffic_generator.control import State, ConfigState,\ - FlowTransmitState -from abstract_open_traffic_generator.result import FlowRequest +logger = logging.getLogger(__name__) DATA_FLOW_NAME = "Data Flow" DATA_PKT_SIZE = 1024 @@ -69,19 +62,18 @@ def run_pfcwd_runtime_traffic_test(api, prio_dscp_map=prio_dscp_map) """ Tgen config = testbed config + flow config """ - config = testbed_config - config.flows = flows + flows = testbed_config.flows all_flow_names = [flow.name for flow in flows] flow_stats = __run_traffic(api=api, - config=config, + config=testbed_config, duthost=duthost, all_flow_names=all_flow_names, pfcwd_start_delay_sec=PFCWD_START_DELAY_SEC, exp_dur_sec=DATA_FLOW_DURATION_SEC) - speed_str = config.layer1[0].speed + speed_str = testbed_config.layer1[0].speed speed_gbps = int(speed_str.split('_')[1]) __verify_results(rows=flow_stats, @@ -90,6 +82,7 @@ def run_pfcwd_runtime_traffic_test(api, data_pkt_size=DATA_PKT_SIZE, tolerance=TOLERANCE_THRESHOLD) + def __gen_traffic(testbed_config, port_id, data_flow_name, @@ -116,35 +109,29 @@ def __gen_traffic(testbed_config, rx_port_id = port_id tx_port_id = (port_id + 1) % len(testbed_config.devices) - data_endpoint = DeviceTxRx( - tx_device_names=[testbed_config.devices[tx_port_id].name], - rx_device_names=[testbed_config.devices[rx_port_id].name], - ) + tx_device_names = [testbed_config.devices[tx_port_id].name] + rx_device_names = [testbed_config.devices[rx_port_id].name] - result = list() data_flow_rate_percent = int(100 / len(prio_list)) """ For each priority """ for prio in prio_list: - ip_prio = Priority(Dscp(phb=FieldPattern(choice=prio_dscp_map[prio]), - ecn=FieldPattern(choice=Dscp.ECN_CAPABLE_TRANSPORT_1))) - pfc_queue = FieldPattern([prio]) - - data_flow = Flow( - name='{} Prio {}'.format(data_flow_name, prio), - tx_rx=TxRx(data_endpoint), - packet=[ - Header(choice=EthernetHeader(pfc_queue=pfc_queue)), - Header(choice=Ipv4Header(priority=ip_prio)) - ], - size=Size(data_pkt_size), - rate=Rate('line', data_flow_rate_percent), - duration=Duration(FixedSeconds(seconds=data_flow_dur_sec)) - ) - - result.append(data_flow) - - return result + data_flow = testbed_config.flows.flow( + name='{} Prio {}'.format(data_flow_name, prio))[-1] + data_flow.tx_rx.device.tx_names = tx_device_names + data_flow.tx_rx.device.rx_names = rx_device_names + + eth, ipv4 = data_flow.packet.ethernet().ipv4() + eth.pfc_queue.value = prio + ipv4.priority.choice = ipv4.priority.DSCP + ipv4.priority.dscp.phb.values = prio_dscp_map[prio] + ipv4.priority.dscp.ecn.value = ( + ipv4.priority.dscp.ecn.CAPABLE_TRANSPORT_1) + + data_flow.size.fixed = data_pkt_size + data_flow.rate.percentage = data_flow_rate_percent + data_flow.duration.fixed_seconds.seconds = data_flow_dur_sec + def __run_traffic(api, config, duthost, all_flow_names, pfcwd_start_delay_sec, exp_dur_sec): """ @@ -161,9 +148,12 @@ def __run_traffic(api, config, duthost, all_flow_names, pfcwd_start_delay_sec, e Returns: per-flow statistics (list) """ - - api.set_state(State(ConfigState(config=config, state='set'))) - api.set_state(State(FlowTransmitState(state='start'))) + api.set_config(config) + logger.info('Starting transmit on all flows ...') + ts = api.transmit_state() + ts.state = ts.START + api.set_transmit_state(ts) + time.sleep(exp_dur_sec) time.sleep(pfcwd_start_delay_sec) start_pfcwd(duthost) @@ -173,9 +163,12 @@ def __run_traffic(api, config, duthost, all_flow_names, pfcwd_start_delay_sec, e max_attempts = 20 while attempts < max_attempts: - rows = api.get_flow_results(FlowRequest(flow_names=all_flow_names)) + request = api.metrics_request() + request.flow.flow_names = all_flow_names + rows = api.get_metrics(request).flow_metrics + """ If all the flows have stopped """ - transmit_states = [row['transmit'] for row in rows] + transmit_states = [row.transmit for row in rows] if len(rows) == len(all_flow_names) and\ list(set(transmit_states)) == ['stopped']: time.sleep(IXIA_POLL_DELAY_SEC) @@ -188,11 +181,17 @@ def __run_traffic(api, config, duthost, all_flow_names, pfcwd_start_delay_sec, e "Flows do not stop in {} seconds".format(max_attempts)) """ Dump per-flow statistics """ - rows = api.get_flow_results(FlowRequest(flow_names=all_flow_names)) - api.set_state(State(FlowTransmitState(state='stop'))) + request = api.metrics_request() + request.flow.flow_names = all_flow_names + rows = api.get_metrics(request).flow_metrics + logger.info('Stop transmit on all flows ...') + ts = api.transmit_state() + ts.state = ts.STOP + api.set_transmit_state(ts) return rows + def __verify_results(rows, speed_gbps, data_flow_dur_sec, data_pkt_size, tolerance): """ Verify if we get expected experiment results @@ -210,9 +209,9 @@ def __verify_results(rows, speed_gbps, data_flow_dur_sec, data_pkt_size, toleran data_flow_rate_percent = int(100 / len(rows)) for row in rows: - flow_name = row['name'] - tx_frames = row['frames_tx'] - rx_frames = row['frames_rx'] + flow_name = row.name + tx_frames = row.frames_tx + rx_frames = row.frames_rx pytest_assert(tx_frames == rx_frames, "{} packets of {} are dropped".\ format(tx_frames-rx_frames, flow_name)) diff --git a/tests/ixia/pfcwd/test_pfcwd_2sender_2receiver.py b/tests/ixia/pfcwd/test_pfcwd_2sender_2receiver.py index 377930d9413..4036130488a 100644 --- a/tests/ixia/pfcwd/test_pfcwd_2sender_2receiver.py +++ b/tests/ixia/pfcwd/test_pfcwd_2sender_2receiver.py @@ -4,7 +4,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_api, ixia_testbed + ixia_api_serv_user, ixia_api_serv_passwd, ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, all_prio_list,\ lossless_prio_list, lossy_prio_list @@ -13,7 +13,7 @@ @pytest.mark.topology("tgen") @pytest.mark.parametrize("trigger_pfcwd", [True, False]) -def test_pfcwd_2sender_2receiver(ixia_api, +def test_pfcwd_2sender_2receiver(snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -29,7 +29,7 @@ def test_pfcwd_2sender_2receiver(ixia_api, Run PFC watchdog test in a 3-host topology with 2 senders and 2 receivers Args: - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -52,7 +52,7 @@ def test_pfcwd_2sender_2receiver(ixia_api, duthost = duthosts[rand_one_dut_hostname] lossless_prio = int(lossless_prio) - run_pfcwd_multi_node_test(api=ixia_api, + run_pfcwd_multi_node_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, diff --git a/tests/ixia/pfcwd/test_pfcwd_a2a.py b/tests/ixia/pfcwd/test_pfcwd_a2a.py index 17f2f8f0220..0517f1281c8 100644 --- a/tests/ixia/pfcwd/test_pfcwd_a2a.py +++ b/tests/ixia/pfcwd/test_pfcwd_a2a.py @@ -4,7 +4,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_api, ixia_testbed + ixia_api_serv_user, ixia_api_serv_passwd, ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, all_prio_list,\ lossless_prio_list, lossy_prio_list @@ -13,7 +13,7 @@ @pytest.mark.topology("tgen") @pytest.mark.parametrize("trigger_pfcwd", [True, False]) -def test_pfcwd_all_to_all(ixia_api, +def test_pfcwd_all_to_all(snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -29,7 +29,7 @@ def test_pfcwd_all_to_all(ixia_api, Run PFC watchdog test under all to all traffic pattern Args: - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -52,7 +52,7 @@ def test_pfcwd_all_to_all(ixia_api, duthost = duthosts[rand_one_dut_hostname] lossless_prio = int(lossless_prio) - run_pfcwd_multi_node_test(api=ixia_api, + run_pfcwd_multi_node_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, diff --git a/tests/ixia/pfcwd/test_pfcwd_basic.py b/tests/ixia/pfcwd/test_pfcwd_basic.py index a3f1b856c2b..0489232d899 100644 --- a/tests/ixia/pfcwd/test_pfcwd_basic.py +++ b/tests/ixia/pfcwd/test_pfcwd_basic.py @@ -4,7 +4,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_api, ixia_testbed + ixia_api_serv_user, ixia_api_serv_passwd, ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, lossless_prio_list from tests.common.reboot import reboot from tests.common.utilities import wait_until @@ -16,7 +16,7 @@ @pytest.mark.topology("tgen") @pytest.mark.parametrize("trigger_pfcwd", [True, False]) -def test_pfcwd_basic_single_lossless_prio(ixia_api, +def test_pfcwd_basic_single_lossless_prio(snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -30,7 +30,7 @@ def test_pfcwd_basic_single_lossless_prio(ixia_api, Run PFC watchdog basic test on a single lossless priority Args: - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -52,7 +52,7 @@ def test_pfcwd_basic_single_lossless_prio(ixia_api, duthost = duthosts[rand_one_dut_hostname] lossless_prio = int(lossless_prio) - run_pfcwd_basic_test(api=ixia_api, + run_pfcwd_basic_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, @@ -64,7 +64,7 @@ def test_pfcwd_basic_single_lossless_prio(ixia_api, @pytest.mark.parametrize("trigger_pfcwd", [True, False]) -def test_pfcwd_basic_multi_lossless_prio(ixia_api, +def test_pfcwd_basic_multi_lossless_prio(snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -78,7 +78,7 @@ def test_pfcwd_basic_multi_lossless_prio(ixia_api, Run PFC watchdog basic test on multiple lossless priorities Args: - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -98,7 +98,7 @@ def test_pfcwd_basic_multi_lossless_prio(ixia_api, duthost = duthosts[rand_one_dut_hostname] - run_pfcwd_basic_test(api=ixia_api, + run_pfcwd_basic_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, @@ -111,7 +111,7 @@ def test_pfcwd_basic_multi_lossless_prio(ixia_api, @pytest.mark.disable_loganalyzer @pytest.mark.parametrize('reboot_type', ['warm', 'cold', 'fast']) @pytest.mark.parametrize("trigger_pfcwd", [True, False]) -def test_pfcwd_basic_single_lossless_prio_reboot(ixia_api, +def test_pfcwd_basic_single_lossless_prio_reboot(snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -127,7 +127,7 @@ def test_pfcwd_basic_single_lossless_prio_reboot(ixia_api, Verify PFC watchdog basic test works on a single lossless priority after various types of reboot Args: - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -157,7 +157,7 @@ def test_pfcwd_basic_single_lossless_prio_reboot(ixia_api, pytest_assert(wait_until(300, 20, duthost.critical_services_fully_started), "Not all critical services are fully started") - run_pfcwd_basic_test(api=ixia_api, + run_pfcwd_basic_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, @@ -171,7 +171,7 @@ def test_pfcwd_basic_single_lossless_prio_reboot(ixia_api, @pytest.mark.disable_loganalyzer @pytest.mark.parametrize('reboot_type', ['warm', 'cold', 'fast']) @pytest.mark.parametrize("trigger_pfcwd", [True, False]) -def test_pfcwd_basic_multi_lossless_prio_reboot(ixia_api, +def test_pfcwd_basic_multi_lossless_prio_reboot(snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -187,7 +187,7 @@ def test_pfcwd_basic_multi_lossless_prio_reboot(ixia_api, Verify PFC watchdog basic test works on multiple lossless priorities after various kinds of reboots Args: - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -215,7 +215,7 @@ def test_pfcwd_basic_multi_lossless_prio_reboot(ixia_api, pytest_assert(wait_until(300, 20, duthost.critical_services_fully_started), "Not all critical services are fully started") - run_pfcwd_basic_test(api=ixia_api, + run_pfcwd_basic_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, @@ -228,7 +228,7 @@ def test_pfcwd_basic_multi_lossless_prio_reboot(ixia_api, @pytest.mark.disable_loganalyzer @pytest.mark.parametrize('restart_service', ['swss']) @pytest.mark.parametrize("trigger_pfcwd", [True, False]) -def test_pfcwd_basic_single_lossless_prio_service_restart(ixia_api, +def test_pfcwd_basic_single_lossless_prio_service_restart(snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -243,7 +243,7 @@ def test_pfcwd_basic_single_lossless_prio_service_restart(ixia_api, Verify PFC watchdog basic test works on a single lossless priority after various service restarts Args: - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -273,7 +273,7 @@ def test_pfcwd_basic_single_lossless_prio_service_restart(ixia_api, pytest_assert(wait_until(300, 20, duthost.critical_services_fully_started), "Not all critical services are fully started") - run_pfcwd_basic_test(api=ixia_api, + run_pfcwd_basic_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, @@ -287,7 +287,7 @@ def test_pfcwd_basic_single_lossless_prio_service_restart(ixia_api, @pytest.mark.disable_loganalyzer @pytest.mark.parametrize('restart_service', ['swss']) @pytest.mark.parametrize("trigger_pfcwd", [True, False]) -def test_pfcwd_basic_multi_lossless_prio_restart_service(ixia_api, +def test_pfcwd_basic_multi_lossless_prio_restart_service(snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -302,7 +302,7 @@ def test_pfcwd_basic_multi_lossless_prio_restart_service(ixia_api, Verify PFC watchdog basic test works on multiple lossless priorities after various service restarts Args: - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -330,7 +330,7 @@ def test_pfcwd_basic_multi_lossless_prio_restart_service(ixia_api, pytest_assert(wait_until(300, 20, duthost.critical_services_fully_started), "Not all critical services are fully started") - run_pfcwd_basic_test(api=ixia_api, + run_pfcwd_basic_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, diff --git a/tests/ixia/pfcwd/test_pfcwd_m2o.py b/tests/ixia/pfcwd/test_pfcwd_m2o.py index 1b3110347d5..026c7aa1225 100644 --- a/tests/ixia/pfcwd/test_pfcwd_m2o.py +++ b/tests/ixia/pfcwd/test_pfcwd_m2o.py @@ -4,7 +4,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_api, ixia_testbed + ixia_api_serv_user, ixia_api_serv_passwd, ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, all_prio_list,\ lossless_prio_list, lossy_prio_list @@ -13,7 +13,7 @@ @pytest.mark.topology("tgen") @pytest.mark.parametrize("trigger_pfcwd", [True, False]) -def test_pfcwd_many_to_one(ixia_api, +def test_pfcwd_many_to_one(snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -29,7 +29,7 @@ def test_pfcwd_many_to_one(ixia_api, Run PFC watchdog test under many to one traffic pattern Args: - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -52,7 +52,7 @@ def test_pfcwd_many_to_one(ixia_api, duthost = duthosts[rand_one_dut_hostname] lossless_prio = int(lossless_prio) - run_pfcwd_multi_node_test(api=ixia_api, + run_pfcwd_multi_node_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, diff --git a/tests/ixia/pfcwd/test_pfcwd_runtime_traffic.py b/tests/ixia/pfcwd/test_pfcwd_runtime_traffic.py index 6c7063bb0ce..6d099116540 100644 --- a/tests/ixia/pfcwd/test_pfcwd_runtime_traffic.py +++ b/tests/ixia/pfcwd/test_pfcwd_runtime_traffic.py @@ -4,14 +4,14 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_api, ixia_testbed + ixia_api_serv_user, ixia_api_serv_passwd, ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, all_prio_list from files.pfcwd_runtime_traffic_helper import run_pfcwd_runtime_traffic_test @pytest.mark.topology("tgen") -def test_pfcwd_runtime_traffic(ixia_api, +def test_pfcwd_runtime_traffic(snappi_api, ixia_testbed, conn_graph_facts, fanout_graph_facts, @@ -24,7 +24,7 @@ def test_pfcwd_runtime_traffic(ixia_api, Test PFC watchdog's impact on runtime traffic Args: - ixia_api (pytest fixture): IXIA session + snappi_api (pytest fixture): IXIA session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -43,7 +43,7 @@ def test_pfcwd_runtime_traffic(ixia_api, duthost = duthosts[rand_one_dut_hostname] - run_pfcwd_runtime_traffic_test(api=ixia_api, + run_pfcwd_runtime_traffic_test(api=snappi_api, testbed_config=ixia_testbed, conn_data=conn_graph_facts, fanout_data=fanout_graph_facts, From 4d5495c5d9242d0e0dc0fe06a5be877f320a6973 Mon Sep 17 00:00:00 2001 From: Anish Date: Tue, 6 Apr 2021 14:40:27 +0000 Subject: [PATCH 5/6] updating review comments --- tests/common/ixia/ixia_fixtures.py | 6 +++- tests/ixia/ecn/files/helper.py | 30 ++++++++++------- tests/ixia/ecn/test_dequeue_ecn.py | 4 +-- tests/ixia/ecn/test_red_accuracy.py | 4 +-- tests/ixia/pfc/files/helper.py | 23 +++++++------ tests/ixia/pfc/test_global_pause.py | 4 +-- tests/ixia/pfc/test_pfc_pause_lossless.py | 10 +++--- tests/ixia/pfc/test_pfc_pause_lossy.py | 10 +++--- tests/ixia/pfcwd/files/pfcwd_basic_helper.py | 22 ++++++++----- .../pfcwd/files/pfcwd_multi_node_helper.py | 33 ++++++++++--------- .../files/pfcwd_runtime_traffic_helper.py | 22 ++++++++----- .../pfcwd/test_pfcwd_2sender_2receiver.py | 4 +-- tests/ixia/pfcwd/test_pfcwd_a2a.py | 4 +-- tests/ixia/pfcwd/test_pfcwd_basic.py | 14 ++++---- tests/ixia/pfcwd/test_pfcwd_m2o.py | 4 +-- .../ixia/pfcwd/test_pfcwd_runtime_traffic.py | 4 +-- 16 files changed, 111 insertions(+), 87 deletions(-) diff --git a/tests/common/ixia/ixia_fixtures.py b/tests/common/ixia/ixia_fixtures.py index 838aab64ff5..b95cb2519e9 100644 --- a/tests/common/ixia/ixia_fixtures.py +++ b/tests/common/ixia/ixia_fixtures.py @@ -13,6 +13,7 @@ from tests.common.ixia.ixia_helpers import IxiaFanoutManager, get_tgen_location import snappi +# TODO: remove abstract imports after all tests are migrated to snappi. try: from abstract_open_traffic_generator.port import Port from abstract_open_traffic_generator.config import Options, Config @@ -205,11 +206,14 @@ def snappi_api(ixia_api_serv_ip, ixia_api_serv_port (pytest fixture): ixia_api_serv_port fixture. """ host = "https://" + ixia_api_serv_ip + ":" + str(ixia_api_serv_port) + # TODO: Currently extension is defaulted to ixnetwork. + # Going forward, we should be able to specify extension + # from command line while running pytest. api = snappi.api(host=host, ext="ixnetwork") yield api - if api.assistant is not None: + if getattr(api, 'assistant', None) is not None: api.assistant.Session.remove() diff --git a/tests/ixia/ecn/files/helper.py b/tests/ixia/ecn/files/helper.py index 7fa14ad69b5..9e2d3954ca0 100644 --- a/tests/ixia/ecn/files/helper.py +++ b/tests/ixia/ecn/files/helper.py @@ -5,8 +5,7 @@ from tests.common.helpers.assertions import pytest_assert from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts -from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd +from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port 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, stop_pfcwd, disable_packet_aging @@ -37,7 +36,7 @@ def run_ecn_test(api, Run a ECN test Args: - api (obj): IXIA session + api (obj): snappi API session testbed_config (obj): L2/L3 config of a T0 testbed conn_data (dict): the dictionary returned by conn_graph_fact. fanout_data (dict): the dictionary returned by fanout_graph_fact. @@ -148,7 +147,7 @@ def __gen_traffic(testbed_config, prio_dscp_map (dict): Priority vs. DSCP map (key = priority). Returns: - Configurations of the data flow and the PFC pause storm (list) + N/A """ @@ -229,7 +228,7 @@ def __config_capture_ip_pkt(testbed_config, port_id): port_id (int): ID of DUT port to capture packets Returns: - Packet capture configuration (list) + N/A """ """ We only capture IP packets """ @@ -253,7 +252,7 @@ def __run_traffic(api, Run traffic and capture packets Args: - api (obj): IXIA session + api (obj): snappi API session config (obj): experiment config all_flow_names (list): names of all the flows capture_port_name (str): name of the port to capture packets @@ -262,17 +261,23 @@ def __run_traffic(api, Returns: N/A """ - api.set_config(config) + response = api.set_config(config) + pytest_assert(len(response.errors) == 0, + 'Set Config failed due to errors') cs = api.capture_state() cs.port_names = [capture_port_name] cs.state = cs.START - api.set_capture_state(cs) + response = api.set_capture_state(cs) + pytest_assert(len(response.errors) == 0, + 'Set Capture failed due to errors') logger.info('Starting transmit on all flows ...') ts = api.transmit_state() ts.state = ts.START - api.set_transmit_state(ts) + response = api.set_transmit_state(ts) + pytest_assert(len(response.errors) == 0, + 'Start traffic failed due to errors') time.sleep(exp_dur_sec) attempts = 0 @@ -300,16 +305,17 @@ def __run_traffic(api, request = api.capture_request() request.port_name = capture_port_name pcap_bytes = api.get_capture(request) - pcap_bytes = pcap_bytes.getvalue() with open(pcap_file_name, 'wb') as fid: - fid.write(pcap_bytes) + fid.write(pcap_bytes.getvalue()) """ Stop all the flows """ logger.info('Stop transmit on all flows ...') ts = api.transmit_state() ts.state = ts.STOP - api.set_transmit_state(ts) + response = api.set_transmit_state(ts) + pytest_assert(len(response.errors) == 0, + 'Stop traffic failed due to errors') def __get_ip_pkts(pcap_file_name): diff --git a/tests/ixia/ecn/test_dequeue_ecn.py b/tests/ixia/ecn/test_dequeue_ecn.py index e11f946457b..463412ca036 100644 --- a/tests/ixia/ecn/test_dequeue_ecn.py +++ b/tests/ixia/ecn/test_dequeue_ecn.py @@ -4,7 +4,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_testbed, snappi_api + ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, lossless_prio_list from files.helper import run_ecn_test, is_ecn_marked @@ -26,7 +26,7 @@ def test_dequeue_ecn(request, Args: request (pytest fixture): pytest request object - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph diff --git a/tests/ixia/ecn/test_red_accuracy.py b/tests/ixia/ecn/test_red_accuracy.py index 6c23ba01954..1d356ccd53c 100644 --- a/tests/ixia/ecn/test_red_accuracy.py +++ b/tests/ixia/ecn/test_red_accuracy.py @@ -5,7 +5,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_testbed, snappi_api + ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, lossless_prio_list from files.helper import run_ecn_test, is_ecn_marked @@ -28,7 +28,7 @@ def test_red_accuracy(request, Args: request (pytest fixture): pytest request object - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph diff --git a/tests/ixia/pfc/files/helper.py b/tests/ixia/pfc/files/helper.py index 3772f77d4e3..d8143be6546 100644 --- a/tests/ixia/pfc/files/helper.py +++ b/tests/ixia/pfc/files/helper.py @@ -4,8 +4,7 @@ from tests.common.helpers.assertions import pytest_assert from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts -from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd +from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port 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, stop_pfcwd, disable_packet_aging @@ -39,7 +38,7 @@ def run_pfc_test(api, Run a PFC test Args: - api (obj): IXIA session + api (obj): snappi API session testbed_config (obj): L2/L3 config of a T0 testbed conn_data (dict): the dictionary returned by conn_graph_fact. fanout_data (dict): the dictionary returned by fanout_graph_fact. @@ -166,9 +165,7 @@ def __gen_traffic(testbed_config, prio_dscp_map (dict): Priority vs. DSCP map (key = priority). Returns: - flows configurations (list): the list should have configurations of - len(test_flow_prio_list) test flow, len(bg_flow_prio_list) background - flows and a pause storm. + N/A """ rx_port_id = port_id @@ -279,7 +276,7 @@ def __run_traffic(api, Run traffic and dump per-flow statistics Args: - api (obj): IXIA session + api (obj): snappi API session config (obj): experiment config (testbed config + flow config) data_flow_names (list): list of names of data (test and background) flows all_flow_names (list): list of names of all the flows @@ -288,11 +285,15 @@ def __run_traffic(api, Returns: per-flow statistics (list) """ - api.set_config(config) + response = api.set_config(config) + pytest_assert(len(response.errors) == 0, + 'Set Config failed due to errors') logger.info('Starting transmit on all flows ...') ts = api.transmit_state() ts.state = ts.START - api.set_transmit_state(ts) + response = api.set_transmit_state(ts) + pytest_assert(len(response.errors) == 0, + 'Start traffic failed due to errors') time.sleep(exp_dur_sec) attempts = 0 @@ -323,7 +324,9 @@ def __run_traffic(api, logger.info('Stop transmit on all flows ...') ts = api.transmit_state() ts.state = ts.STOP - api.set_transmit_state(ts) + response = api.set_transmit_state(ts) + pytest_assert(len(response.errors) == 0, + 'Stop traffic failed due to errors') return rows diff --git a/tests/ixia/pfc/test_global_pause.py b/tests/ixia/pfc/test_global_pause.py index 24df8adc042..8b6e143bcec 100644 --- a/tests/ixia/pfc/test_global_pause.py +++ b/tests/ixia/pfc/test_global_pause.py @@ -4,7 +4,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_testbed, snappi_api + ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, all_prio_list, lossless_prio_list,\ lossy_prio_list @@ -26,7 +26,7 @@ def test_global_pause(snappi_api, Test if IEEE 802.3X pause (a.k.a., global pause) will impact any priority Args: - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph diff --git a/tests/ixia/pfc/test_pfc_pause_lossless.py b/tests/ixia/pfc/test_pfc_pause_lossless.py index c5b8b424f10..b885103274c 100644 --- a/tests/ixia/pfc/test_pfc_pause_lossless.py +++ b/tests/ixia/pfc/test_pfc_pause_lossless.py @@ -6,7 +6,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_testbed, snappi_api + ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, all_prio_list, lossless_prio_list,\ lossy_prio_list from tests.common.reboot import reboot @@ -30,7 +30,7 @@ def test_pfc_pause_single_lossless_prio(snappi_api, Test if PFC can pause a single lossless priority Args: - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -85,7 +85,7 @@ def test_pfc_pause_multi_lossless_prio(snappi_api, Test if PFC can pause multiple lossless priorities Args: - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -139,7 +139,7 @@ def test_pfc_pause_single_lossless_prio_reboot(snappi_api, Test if PFC can pause a single lossless priority even after various types of reboot Args: - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -205,7 +205,7 @@ def test_pfc_pause_multi_lossless_prio_reboot(snappi_api, Test if PFC can pause multiple lossless priorities even after various types of reboot Args: - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph diff --git a/tests/ixia/pfc/test_pfc_pause_lossy.py b/tests/ixia/pfc/test_pfc_pause_lossy.py index 8b64f873b32..eec4cd3e70c 100644 --- a/tests/ixia/pfc/test_pfc_pause_lossy.py +++ b/tests/ixia/pfc/test_pfc_pause_lossy.py @@ -6,7 +6,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_testbed, snappi_api + ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, all_prio_list, lossless_prio_list,\ lossy_prio_list from tests.common.reboot import reboot @@ -30,7 +30,7 @@ def test_pfc_pause_single_lossy_prio(snappi_api, Test if PFC will impact a single lossy priority Args: - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -85,7 +85,7 @@ def test_pfc_pause_multi_lossy_prio(snappi_api, Test if PFC will impact multiple lossy priorities Args: - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -139,7 +139,7 @@ def test_pfc_pause_single_lossy_prio_reboot(snappi_api, Test if PFC will impact a single lossy priority after various kinds of reboots Args: - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -205,7 +205,7 @@ def test_pfc_pause_multi_lossy_prio_reboot(snappi_api, Test if PFC will impact multiple lossy priorities after various kinds of reboots Args: - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph diff --git a/tests/ixia/pfcwd/files/pfcwd_basic_helper.py b/tests/ixia/pfcwd/files/pfcwd_basic_helper.py index 76fce368b85..5775e410fa0 100644 --- a/tests/ixia/pfcwd/files/pfcwd_basic_helper.py +++ b/tests/ixia/pfcwd/files/pfcwd_basic_helper.py @@ -5,8 +5,7 @@ from tests.common.helpers.assertions import pytest_assert from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts -from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd +from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port from tests.common.ixia.ixia_helpers import get_dut_port_id from tests.common.ixia.common_helpers import pfc_class_enable_vector,\ get_pfcwd_poll_interval, get_pfcwd_detect_time, get_pfcwd_restore_time,\ @@ -35,7 +34,7 @@ def run_pfcwd_basic_test(api, Run a basic PFC watchdog test Args: - api (obj): IXIA session + api (obj): snappi API session testbed_config (obj): L2/L3 config of a T0 testbed conn_data (dict): the dictionary returned by conn_graph_fact. fanout_data (dict): the dictionary returned by fanout_graph_fact. @@ -150,8 +149,7 @@ def __gen_traffic(testbed_config, prio_dscp_map (dict): Priority vs. DSCP map (key = priority). Returns: - flows configurations (list): the list should have configurations of - len(prio_list) * 2 data flows, and a pause storm. + N/A """ rx_port_id = port_id @@ -233,7 +231,7 @@ def __run_traffic(api, config, all_flow_names, exp_dur_sec): Run traffic and dump per-flow statistics Args: - api (obj): IXIA session + api (obj): snappi API session config (obj): experiment config (testbed config + flow config) all_flow_names (list): list of names of all the flows exp_dur_sec (float): experiment duration in second @@ -242,11 +240,15 @@ def __run_traffic(api, config, all_flow_names, exp_dur_sec): per-flow statistics (list) """ - api.set_config(config) + response = api.set_config(config) + pytest_assert(len(response.errors) == 0, + 'Set Config failed due to errors') logger.info('Starting transmit on all flows ...') ts = api.transmit_state() ts.state = ts.START - api.set_transmit_state(ts) + response = api.set_transmit_state(ts) + pytest_assert(len(response.errors) == 0, + 'Start traffic failed due to errors') time.sleep(exp_dur_sec) attempts = 0 @@ -277,7 +279,9 @@ def __run_traffic(api, config, all_flow_names, exp_dur_sec): logger.info('Stop transmit on all flows ...') ts = api.transmit_state() ts.state = ts.STOP - api.set_transmit_state(ts) + response = api.set_transmit_state(ts) + pytest_assert(len(response.errors) == 0, + 'Stop traffic failed due to errors') return rows diff --git a/tests/ixia/pfcwd/files/pfcwd_multi_node_helper.py b/tests/ixia/pfcwd/files/pfcwd_multi_node_helper.py index 194395bd89f..603cd7ec30f 100644 --- a/tests/ixia/pfcwd/files/pfcwd_multi_node_helper.py +++ b/tests/ixia/pfcwd/files/pfcwd_multi_node_helper.py @@ -6,8 +6,7 @@ from tests.common.helpers.assertions import pytest_assert, pytest_require from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts -from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd +from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port from tests.common.ixia.ixia_helpers import get_dut_port_id from tests.common.ixia.common_helpers import pfc_class_enable_vector,\ start_pfcwd, enable_packet_aging, get_pfcwd_poll_interval, get_pfcwd_detect_time @@ -40,7 +39,7 @@ def run_pfcwd_multi_node_test(api, Run PFC watchdog test in a multi-node (>=3) topoology Args: - api (obj): IXIA session + api (obj): snappi API session testbed_config (obj): L2/L3 config of a T0 testbed conn_data (dict): the dictionary returned by conn_graph_fact. fanout_data (dict): the dictionary returned by fanout_graph_fact. @@ -264,7 +263,7 @@ def __gen_2sender_2receiver_traffic(testbed_config, prio_dscp_map (dict): Priority vs. DSCP map (key = priority). Returns: - flows configurations (list) + N/A """ """ Generate a PFC pause storm """ pause_port_id = port_id @@ -343,7 +342,7 @@ def __gen_a2a_traffic(testbed_config, prio_dscp_map (dict): Priority vs. DSCP map (key = priority). Returns: - flows configurations (list) + N/A """ """ Generate a PFC pause storm """ pause_port_id = port_id @@ -418,7 +417,7 @@ def __gen_m2o_traffic(testbed_config, prio_dscp_map (dict): Priority vs. DSCP map (key = priority). Returns: - flows configurations (list) + N/A """ """ Generate a PFC pause storm """ @@ -479,9 +478,7 @@ def __gen_data_flows(testbed_config, prio_dscp_map (dict): Priority vs. DSCP map (key = priority). Returns: - flows configurations (list): the list should have configurations of - len(src_port_id_list) * len(dst_port_id_list) * len(flow_prio_list) - data flows + N/A """ for src_port_id in src_port_id_list: @@ -522,7 +519,7 @@ def __gen_data_flow(testbed_config, prio_dscp_map (dict): Priority vs. DSCP map (key = priority). Returns: - flow configuration (obj): including name, packet format, rate, ... + N/A """ tx_device_names = [testbed_config.devices[src_port_id].name] rx_device_names = [testbed_config.devices[dst_port_id].name] @@ -564,7 +561,7 @@ def __gen_pause_flow(testbed_config, flow_dur_sec (float): duration of the flow in second Returns: - flow configuration (obj): including name, packet format, rate, ... + N/A """ pause_time = [] for x in range(8): @@ -615,7 +612,7 @@ def __run_traffic(api, config, all_flow_names, exp_dur_sec): Run traffic and dump per-flow statistics Args: - api (obj): IXIA session + api (obj): snappi API session config (obj): experiment config (testbed config + flow config) all_flow_names (list): list of names of all the flows exp_dur_sec (int): experiment duration in second @@ -623,11 +620,15 @@ def __run_traffic(api, config, all_flow_names, exp_dur_sec): Returns: per-flow statistics (list) """ - api.set_config(config) + response = api.set_config(config) + pytest_assert(len(response.errors) == 0, + 'Set Config failed due to errors') logger.info('Starting transmit on all flows ...') ts = api.transmit_state() ts.state = ts.START - api.set_transmit_state(ts) + response = api.set_transmit_state(ts) + pytest_assert(len(response.errors) == 0, + 'Start traffic failed due to errors') time.sleep(exp_dur_sec) attempts = 0 @@ -658,7 +659,9 @@ def __run_traffic(api, config, all_flow_names, exp_dur_sec): logger.info('Stop transmit on all flows ...') ts = api.transmit_state() ts.state = ts.STOP - api.set_transmit_state(ts) + response = api.set_transmit_state(ts) + pytest_assert(len(response.errors) == 0, + 'Stop traffic failed due to errors') return rows diff --git a/tests/ixia/pfcwd/files/pfcwd_runtime_traffic_helper.py b/tests/ixia/pfcwd/files/pfcwd_runtime_traffic_helper.py index 27782f776c7..13fd6a5ee19 100644 --- a/tests/ixia/pfcwd/files/pfcwd_runtime_traffic_helper.py +++ b/tests/ixia/pfcwd/files/pfcwd_runtime_traffic_helper.py @@ -2,8 +2,7 @@ import logging from tests.common.helpers.assertions import pytest_assert -from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd +from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port from tests.common.ixia.ixia_helpers import get_dut_port_id from tests.common.ixia.common_helpers import start_pfcwd, stop_pfcwd @@ -28,7 +27,7 @@ def run_pfcwd_runtime_traffic_test(api, Test PFC watchdog's impact on runtime traffic Args: - api (obj): IXIA session + api (obj): snappi API session testbed_config (obj): L2/L3 config of a T0 testbed conn_data (dict): the dictionary returned by conn_graph_fact. fanout_data (dict): the dictionary returned by fanout_graph_fact. @@ -103,8 +102,7 @@ def __gen_traffic(testbed_config, prio_dscp_map (dict): Priority vs. DSCP map (key = priority). Returns: - flows configurations (list): the list should have configurations of - len(prio_list) data flows + N/A """ rx_port_id = port_id tx_port_id = (port_id + 1) % len(testbed_config.devices) @@ -138,7 +136,7 @@ def __run_traffic(api, config, duthost, all_flow_names, pfcwd_start_delay_sec, e Start traffic at time 0 and enable PFC watchdog at pfcwd_start_delay_sec Args: - api (obj): IXIA session + api (obj): snappi API session config (obj): experiment config (testbed config + flow config) duthost (Ansible host instance): device under test all_flow_names (list): list of names of all the flows @@ -148,11 +146,15 @@ def __run_traffic(api, config, duthost, all_flow_names, pfcwd_start_delay_sec, e Returns: per-flow statistics (list) """ - api.set_config(config) + response = api.set_config(config) + pytest_assert(len(response.errors) == 0, + 'Set Config failed due to errors') logger.info('Starting transmit on all flows ...') ts = api.transmit_state() ts.state = ts.START - api.set_transmit_state(ts) + response = api.set_transmit_state(ts) + pytest_assert(len(response.errors) == 0, + 'Start traffic failed due to errors') time.sleep(exp_dur_sec) time.sleep(pfcwd_start_delay_sec) @@ -187,7 +189,9 @@ def __run_traffic(api, config, duthost, all_flow_names, pfcwd_start_delay_sec, e logger.info('Stop transmit on all flows ...') ts = api.transmit_state() ts.state = ts.STOP - api.set_transmit_state(ts) + response = api.set_transmit_state(ts) + pytest_assert(len(response.errors) == 0, + 'stop traffic failed due to errors') return rows diff --git a/tests/ixia/pfcwd/test_pfcwd_2sender_2receiver.py b/tests/ixia/pfcwd/test_pfcwd_2sender_2receiver.py index 4036130488a..bae334c26b9 100644 --- a/tests/ixia/pfcwd/test_pfcwd_2sender_2receiver.py +++ b/tests/ixia/pfcwd/test_pfcwd_2sender_2receiver.py @@ -4,7 +4,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_testbed, snappi_api + ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, all_prio_list,\ lossless_prio_list, lossy_prio_list @@ -29,7 +29,7 @@ def test_pfcwd_2sender_2receiver(snappi_api, Run PFC watchdog test in a 3-host topology with 2 senders and 2 receivers Args: - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph diff --git a/tests/ixia/pfcwd/test_pfcwd_a2a.py b/tests/ixia/pfcwd/test_pfcwd_a2a.py index 0517f1281c8..72344d587bd 100644 --- a/tests/ixia/pfcwd/test_pfcwd_a2a.py +++ b/tests/ixia/pfcwd/test_pfcwd_a2a.py @@ -4,7 +4,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_testbed, snappi_api + ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, all_prio_list,\ lossless_prio_list, lossy_prio_list @@ -29,7 +29,7 @@ def test_pfcwd_all_to_all(snappi_api, Run PFC watchdog test under all to all traffic pattern Args: - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph diff --git a/tests/ixia/pfcwd/test_pfcwd_basic.py b/tests/ixia/pfcwd/test_pfcwd_basic.py index 0489232d899..a2e1e091348 100644 --- a/tests/ixia/pfcwd/test_pfcwd_basic.py +++ b/tests/ixia/pfcwd/test_pfcwd_basic.py @@ -4,7 +4,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_testbed, snappi_api + ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, lossless_prio_list from tests.common.reboot import reboot from tests.common.utilities import wait_until @@ -30,7 +30,7 @@ def test_pfcwd_basic_single_lossless_prio(snappi_api, Run PFC watchdog basic test on a single lossless priority Args: - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -78,7 +78,7 @@ def test_pfcwd_basic_multi_lossless_prio(snappi_api, Run PFC watchdog basic test on multiple lossless priorities Args: - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -127,7 +127,7 @@ def test_pfcwd_basic_single_lossless_prio_reboot(snappi_api, Verify PFC watchdog basic test works on a single lossless priority after various types of reboot Args: - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -187,7 +187,7 @@ def test_pfcwd_basic_multi_lossless_prio_reboot(snappi_api, Verify PFC watchdog basic test works on multiple lossless priorities after various kinds of reboots Args: - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -243,7 +243,7 @@ def test_pfcwd_basic_single_lossless_prio_service_restart(snappi_api, Verify PFC watchdog basic test works on a single lossless priority after various service restarts Args: - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph @@ -302,7 +302,7 @@ def test_pfcwd_basic_multi_lossless_prio_restart_service(snappi_api, Verify PFC watchdog basic test works on multiple lossless priorities after various service restarts Args: - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph diff --git a/tests/ixia/pfcwd/test_pfcwd_m2o.py b/tests/ixia/pfcwd/test_pfcwd_m2o.py index 026c7aa1225..2ba1e20c5d1 100644 --- a/tests/ixia/pfcwd/test_pfcwd_m2o.py +++ b/tests/ixia/pfcwd/test_pfcwd_m2o.py @@ -4,7 +4,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_testbed, snappi_api + ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, all_prio_list,\ lossless_prio_list, lossy_prio_list @@ -29,7 +29,7 @@ def test_pfcwd_many_to_one(snappi_api, Run PFC watchdog test under many to one traffic pattern Args: - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph diff --git a/tests/ixia/pfcwd/test_pfcwd_runtime_traffic.py b/tests/ixia/pfcwd/test_pfcwd_runtime_traffic.py index 6d099116540..44e15ceb1de 100644 --- a/tests/ixia/pfcwd/test_pfcwd_runtime_traffic.py +++ b/tests/ixia/pfcwd/test_pfcwd_runtime_traffic.py @@ -4,7 +4,7 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts from tests.common.ixia.ixia_fixtures import ixia_api_serv_ip, ixia_api_serv_port,\ - ixia_api_serv_user, ixia_api_serv_passwd, ixia_testbed, snappi_api + ixia_testbed, snappi_api from tests.common.ixia.qos_fixtures import prio_dscp_map, all_prio_list from files.pfcwd_runtime_traffic_helper import run_pfcwd_runtime_traffic_test @@ -24,7 +24,7 @@ def test_pfcwd_runtime_traffic(snappi_api, Test PFC watchdog's impact on runtime traffic Args: - snappi_api (pytest fixture): IXIA session + snappi_api (pytest fixture): snappi API session ixia_testbed (pytest fixture): L2/L3 config of a T0 testbed conn_graph_facts (pytest fixture): connection graph fanout_graph_facts (pytest fixture): fanout graph From cc2fd36b21eef18f32f28b238d74c6111e321b95 Mon Sep 17 00:00:00 2001 From: Anish Date: Wed, 7 Apr 2021 09:45:21 +0000 Subject: [PATCH 6/6] updating tests lgtm alerts --- tests/common/ixia/ixia_fixtures.py | 1 - tests/ixia/ecn/files/helper.py | 2 +- .../pfcwd/files/pfcwd_runtime_traffic_helper.py | 14 +++++++------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/common/ixia/ixia_fixtures.py b/tests/common/ixia/ixia_fixtures.py index b95cb2519e9..ab1a5aefc7b 100644 --- a/tests/common/ixia/ixia_fixtures.py +++ b/tests/common/ixia/ixia_fixtures.py @@ -249,7 +249,6 @@ def ixia_testbed(conn_graph_facts, ixia_ports = ixia_fanout_list.get_ports(peer_device=duthost.hostname) - port_names = list() port_speed = None """ L1 config """ diff --git a/tests/ixia/ecn/files/helper.py b/tests/ixia/ecn/files/helper.py index 9e2d3954ca0..748188e07db 100644 --- a/tests/ixia/ecn/files/helper.py +++ b/tests/ixia/ecn/files/helper.py @@ -86,7 +86,7 @@ def run_ecn_test(api, 'Failed to get ID for port {}'.format(dut_port)) """ Generate packet capture config """ - capture_config = __config_capture_ip_pkt(testbed_config=testbed_config, port_id=port_id) + __config_capture_ip_pkt(testbed_config=testbed_config, port_id=port_id) """ Generate traffic config """ __gen_traffic(testbed_config=testbed_config, diff --git a/tests/ixia/pfcwd/files/pfcwd_runtime_traffic_helper.py b/tests/ixia/pfcwd/files/pfcwd_runtime_traffic_helper.py index 13fd6a5ee19..8d9ce3c58be 100644 --- a/tests/ixia/pfcwd/files/pfcwd_runtime_traffic_helper.py +++ b/tests/ixia/pfcwd/files/pfcwd_runtime_traffic_helper.py @@ -52,13 +52,13 @@ def run_pfcwd_runtime_traffic_test(api, pytest_assert(port_id is not None, 'Fail to get ID for port {}'.format(dut_port)) - flows = __gen_traffic(testbed_config=testbed_config, - port_id=port_id, - data_flow_name=DATA_FLOW_NAME, - data_flow_dur_sec=DATA_FLOW_DURATION_SEC, - data_pkt_size=DATA_PKT_SIZE, - prio_list=prio_list, - prio_dscp_map=prio_dscp_map) + __gen_traffic(testbed_config=testbed_config, + port_id=port_id, + data_flow_name=DATA_FLOW_NAME, + data_flow_dur_sec=DATA_FLOW_DURATION_SEC, + data_pkt_size=DATA_PKT_SIZE, + prio_list=prio_list, + prio_dscp_map=prio_dscp_map) """ Tgen config = testbed config + flow config """ flows = testbed_config.flows