-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
updating pfc tests #5
base: master
Are you sure you want to change the base?
Changes from all commits
b4b48d4
6374a36
45ea427
5402a24
307fc99
4d5495c
cc2fd36
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,9 @@ | |
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 | ||
|
||
# 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 | ||
|
@@ -193,11 +195,34 @@ 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as discussed, we need a meeting with Wei |
||
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) | ||
# 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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a comment here mentioning:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
|
||
yield api | ||
|
||
if getattr(api, 'assistant', None) 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 +249,13 @@ 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 +264,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 +298,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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to get rid of
abstract_open_traffic_generator
everywhere.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And statements using abstract classes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added TODO as discussed