From e75d773e3996b1d718cae2d0db07e86dc7e4090b Mon Sep 17 00:00:00 2001 From: Dipendu Ghosh Date: Wed, 18 Dec 2024 19:31:01 +0530 Subject: [PATCH 1/2] Added support for AresOneM 800G support and a testcase for the same. Remove redundant self._import(imports) in _set_l1config_properties causing delay in setting l1_settings. --- snappi_ixnetwork/vport.py | 5 +- tests/layer1/test_layer1_speed_AresOneM.py | 183 +++++++++++++++++++++ 2 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 tests/layer1/test_layer1_speed_AresOneM.py diff --git a/snappi_ixnetwork/vport.py b/snappi_ixnetwork/vport.py index 9ddc792b5..654a80012 100644 --- a/snappi_ixnetwork/vport.py +++ b/snappi_ixnetwork/vport.py @@ -38,6 +38,7 @@ class Vport(object): """ _SPEED_MAP = { + "speed_800_gbps": "speed800g", "speed_400_gbps": "speed400g", "speed_200_gbps": "speed200g", "speed_100_gbps": "speed100g", @@ -90,6 +91,7 @@ class Vport(object): "speed_100_gbps": "^(?!.*(twohundredgig|fourhundredgig)).*hundredgig.*$", "speed_200_gbps": "twohundredgig", "speed_400_gbps": "fourhundredgig", + "speed_800_gbps": "eighthundredgig", } _ADVERTISE_MAP = { @@ -437,7 +439,7 @@ def _set_l1config_properties(self, vport, layer1, imports): ]: return self._set_fcoe(vport, layer1, imports) - self._import(imports) + # self._import(imports) self._set_auto_negotiation(vport, layer1, imports) @@ -502,6 +504,7 @@ def _set_vport_type(self, vport, layer1, imports): "krakenFourHundredGigLan", "aresOneFourHundredGigLan", "starFourHundredGigLan", + "aresOneM", ] if fcoe is True and vport_type in elegible_fcoe_vport_types: vport_type = vport_type + "Fcoe" diff --git a/tests/layer1/test_layer1_speed_AresOneM.py b/tests/layer1/test_layer1_speed_AresOneM.py new file mode 100644 index 000000000..b21804fec --- /dev/null +++ b/tests/layer1/test_layer1_speed_AresOneM.py @@ -0,0 +1,183 @@ +import pytest + + +@pytest.mark.l1_manual +@pytest.mark.parametrize( + "speed", + ["speed_50_gbps", "speed_100_gbps", "speed_200_gbps", "speed_400_gbps", "speed_800_gbps"], +) +def test_layer1(api, utils, speed): + """Test that layer1 configuration settings are being applied correctly + A user should be able to configure ports with/without locations. + The expectation should be if a location is configured the user wants to + connect but debug should allow for config creation without location. + Ports with no location should not generate an error message. + Ports with location should generate an error message if unable to connect. + + Validation: Validate the layer1 properties applied using Restpy + """ + speed_type = { + "speed_50_gbps": "50000", + "speed_100_gbps": "100000", + "speed_200_gbps": "200000", + "speed_400_gbps": "400000", + "speed_800_gbps": "800000", + } + port_locations = get_port_locations(utils.settings.ports[0]) + location = port_locations[speed] + config = api.config() + port = config.ports.port(name="port1", location=location)[-1] + auto_negotiate = True + ieee_media_defaults = False + link_training = False + if speed in ["speed_50_gbps", "speed_200_gbps"]: + auto_negotiate = False + if speed in ["speed_100_gbps", "speed_400_gbps", "speed_800_gbps"]: + link_training = True + port_l1 = config.layer1.layer1()[-1] + port_l1.name = "port1 settings" + port_l1.port_names = [port.name] + port_l1.speed = speed + port_l1.media = utils.settings.media + port_l1.auto_negotiate = auto_negotiate + port_l1.ieee_media_defaults = ieee_media_defaults + port_l1.auto_negotiation.link_training = link_training + api.set_config(config) + validate_layer1_config( + api, + port_locations[speed], + speed_type, + speed, + auto_negotiate, + ieee_media_defaults, + link_training, + ) + + +def get_port_locations(location): + """ + Takes input port location given by the user and returns a dictionary with + speed mapped to port location as per RG + Ex: get_port_location_for_speed("10.36.87.215;1;57") + output: + {'speed_50_gbps': '10.36.87.215/177', + 'speed_100_gbps': '10.36.87.215/57', + 'speed_200_gbps': '10.36.87.215/25', + 'speed_400_gbps': '10.36.87.215/9', + 'speed_800_gbps': '10.36.87.215/1'} + """ + port_800g = "" + port_400g = "" + port_200g = "" + port_100g = "" + port_50g = "" + port_location = {} + port_num = int(location.split(";")[2]) + + rg_fanout400g = {} + rg_fanout400g_starting_port = 9 + rg_fanout200g = {} + rg_fanout200g_starting_port = 25 + rg_fanout100g = {} + rg_fanout100g_starting_port = 57 + rg_fanout50g = {} + rg_fanout50_starting_port = 177 + + for rg in range(1, 9): + rg_fanout400g[rg] = list( + range(rg_fanout400g_starting_port, rg_fanout400g_starting_port + 2) + ) + rg_fanout400g_starting_port += 2 + + for rg in range(1, 9): + rg_fanout200g[rg] = list( + range(rg_fanout200g_starting_port, rg_fanout200g_starting_port + 4) + ) + rg_fanout200g_starting_port += 4 + + for rg in range(1, 9): + rg_fanout100g[rg] = list( + range(rg_fanout100g_starting_port, rg_fanout100g_starting_port + 8) + ) + rg_fanout100g_starting_port += 8 + + for rg in range(1, 9): + rg_fanout50g[rg] = list( + range(rg_fanout50_starting_port, rg_fanout50_starting_port + 8) + ) + rg_fanout50_starting_port += 8 + + if port_num < 9: + port_800g = port_num + port_400g = rg_fanout400g[port_num][0] + port_200g = rg_fanout200g[port_num][0] + port_100g = rg_fanout100g[port_num][0] + port_50g = rg_fanout50g[port_num][0] + elif port_num > 8 and port_num < 25: + port_400g = port_num + port_800g = next( + key for key in rg_fanout400g if port_num in rg_fanout400g[key] + ) + port_200g = rg_fanout200g[port_800g][0] + port_100g = rg_fanout100g[port_800g][0] + port_50g = rg_fanout50g[port_800g][0] + elif port_num > 24 and port_num < 57: + port_200g = port_num + port_800g = next( + key for key in rg_fanout200g if port_num in rg_fanout200g[key] + ) + port_400g = rg_fanout400g[port_800g][0] + port_100g = rg_fanout100g[port_800g][0] + port_50g = rg_fanout50g[port_800g][0] + elif port_num > 56 and port_num < 121: + port_100g = port_num + port_800g = next( + key for key in rg_fanout100g if port_num in rg_fanout100g[key] + ) + port_200g = rg_fanout200g[port_800g][0] + port_400g = rg_fanout400g[port_800g][0] + port_50g = rg_fanout50g[port_800g][0] + elif port_num > 176 and port_num < 241: + port_50g = port_num + port_800g = next( + key for key in rg_fanout50g if port_num in rg_fanout50g[key] + ) + port_200g = rg_fanout200g[port_800g][0] + port_400g = rg_fanout400g[port_800g][0] + port_100g = rg_fanout100g[port_800g][0] + + port_800g = location.split(";")[0] + "/" + str(port_800g) + port_400g = location.split(";")[0] + "/" + str(port_400g) + port_200g = location.split(";")[0] + "/" + str(port_200g) + port_100g = location.split(";")[0] + "/" + str(port_100g) + port_50g = location.split(";")[0] + "/" + str(port_50g) + + port_location["speed_800_gbps"] = port_800g + port_location["speed_400_gbps"] = port_400g + port_location["speed_200_gbps"] = port_200g + port_location["speed_100_gbps"] = port_100g + port_location["speed_50_gbps"] = port_50g + + return port_location + + +def validate_layer1_config( + api, + port_location, + speed_type, + speed, + auto_negotiate, + ieee_media_defaults, + link_training, +): + """ + Validate Layer1 Configs using Restpy + """ + ixnetwork = api._ixnetwork + port = ixnetwork.Vport.find()[0] + type = (port.Type)[0].upper() + (port.Type)[1:] + assert port.Location == port_location + assert port.ActualSpeed == int(speed_type[speed]) + assert getattr(port.L1Config, type).EnableAutoNegotiation == auto_negotiate + assert getattr(port.L1Config, type).IeeeL1Defaults == ieee_media_defaults + assert getattr(port.L1Config, type).LinkTraining == link_training From 2d9991138bbbfd69a4ee16c752cea7db59f1b178 Mon Sep 17 00:00:00 2001 From: Dipendu Ghosh Date: Wed, 18 Dec 2024 21:11:34 +0530 Subject: [PATCH 2/2] remove commented line --- snappi_ixnetwork/vport.py | 1 - 1 file changed, 1 deletion(-) diff --git a/snappi_ixnetwork/vport.py b/snappi_ixnetwork/vport.py index 654a80012..8938a4f15 100644 --- a/snappi_ixnetwork/vport.py +++ b/snappi_ixnetwork/vport.py @@ -439,7 +439,6 @@ def _set_l1config_properties(self, vport, layer1, imports): ]: return self._set_fcoe(vport, layer1, imports) - # self._import(imports) self._set_auto_negotiation(vport, layer1, imports)