Skip to content
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

fix(vport): correct auto_negotiate/fec behavior #562

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion snappi_ixnetwork/vport.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,25 @@ def _set_gigabit_auto_negotiation(self, vport, layer1, imports):
"{0}".format(auto_field_name): False
if auto_negotiate is None
else auto_negotiate,
"enableRsFec": False if rs_fec is None else rs_fec,
"linkTraining": False if link_training is None else link_training,
"speedAuto": advertise,
}
if auto_negotiate:
proposed_import.update(
useANResults=True,
firecodeForceOn=False,
rsFecForceOn=False,
forceDisableFEC=False,
rsFecAdvertise=False if rs_fec is None else rs_fec,
rsFecRequest=False if rs_fec is None else rs_fec,
)
else:
proposed_import.update(
useANResults=False,
firecodeForceOn=False,
rsFecForceOn=False if rs_fec is None else rs_fec,
forceDisableFEC=True if rs_fec is None else not rs_fec,
)
proposed_import["media"] = layer1.get("media", with_default=True)
self._add_l1config_import(vport, proposed_import, imports)

Expand Down
54 changes: 54 additions & 0 deletions tests/layer1/test_layer1_auto_negotiate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from itertools import product

import pytest


_PORT_NAME = "p1"


@pytest.mark.parametrize(
"autonego, rs_fec",
product([True, False], [True, False])
)
def test_auto_negotiate(api, utils, autonego, rs_fec):
"""
Configure a port layer1 configuration with,
- ieee_media_defaults: false

Validate,
- layer1 auto negotiate properties is as expected
"""
config = api.config()
p1 = config.ports.port(name=_PORT_NAME, location=utils.settings.ports[0])[-1]
l1 = config.layer1.layer1(name="l1")[-1]
l1.port_names = [p1.name]
l1.speed = utils.settings.speed
l1.media = utils.settings.media
l1.ieee_media_defaults = False
l1.auto_negotiate = autonego
l1.auto_negotiation.rs_fec = rs_fec
api.set_config(config)
validate_auto_negotiate_config(api, autonego, rs_fec)


def validate_auto_negotiate_config(api, autonego, rs_fec):
"""
Validate layer1 auto negotiate configs using restpy
"""
ixnetwork = api._ixnetwork
port = ixnetwork.Vport.find(Name=_PORT_NAME)
lan = getattr(port.L1Config, port.Type[0].upper() + port.Type[1:])

assert lan.EnableAutoNegotiation == autonego
if autonego:
assert lan.UseANResults
assert not lan.FirecodeForceOn
assert not lan.RsFecForceOn
assert not lan.ForceDisableFEC
assert lan.RsFecAdvertise == rs_fec
assert lan.RsFecRequest == rs_fec
else:
assert not lan.UseANResults
assert not lan.FirecodeForceOn
assert lan.RsFecForceOn == rs_fec
assert lan.ForceDisableFEC != rs_fec