From 72b8249c5bcb9322f723006083d30fca19c7ced2 Mon Sep 17 00:00:00 2001 From: Jingwen Xie Date: Wed, 31 Aug 2022 06:55:53 +0000 Subject: [PATCH] Remove GCU unique lane check --- generic_config_updater/gu_common.py | 17 +- .../files/patch_sorter_test_success.json | 326 +----------------- .../generic_config_updater/gu_common_test.py | 35 +- 3 files changed, 28 insertions(+), 350 deletions(-) diff --git a/generic_config_updater/gu_common.py b/generic_config_updater/gu_common.py index 1397396b75..c138fad269 100644 --- a/generic_config_updater/gu_common.py +++ b/generic_config_updater/gu_common.py @@ -154,14 +154,15 @@ def validate_lanes(self, config_db): return False, f"PORT '{port}' has an invalid lane '{lane}'" port_to_lanes_map[port] = lanes - # Validate lanes are unique - existing = {} - for port in port_to_lanes_map: - lanes = port_to_lanes_map[port] - for lane in lanes: - if lane in existing: - return False, f"'{lane}' lane is used multiple times in PORT: {set([port, existing[lane]])}" - existing[lane] = port + #TODO: uncomment dup lane check + ## Validate lanes are unique + #existing = {} + #for port in port_to_lanes_map: + # lanes = port_to_lanes_map[port] + # for lane in lanes: + # if lane in existing: + # return False, f"'{lane}' lane is used multiple times in PORT: {set([port, existing[lane]])}" + # existing[lane] = port return True, None def validate_bgp_peer_group(self, config_db): diff --git a/tests/generic_config_updater/files/patch_sorter_test_success.json b/tests/generic_config_updater/files/patch_sorter_test_success.json index b4f1f141c3..54c0cfa6ed 100644 --- a/tests/generic_config_updater/files/patch_sorter_test_success.json +++ b/tests/generic_config_updater/files/patch_sorter_test_success.json @@ -656,330 +656,6 @@ ] ] }, - "DPB_1_TO_4__SUCCESS": { - "desc": "Dpb 1 to 4 success.", - "current_config": { - "PORT": { - "Ethernet0": { - "alias": "Eth1", - "lanes": "65, 66, 67, 68", - "description": "Ethernet0 100G link", - "speed": "100000" - } - }, - "ACL_TABLE": { - "NO-NSW-PACL-V4": { - "type": "L3", - "policy_desc": "NO-NSW-PACL-V4", - "ports": [ - "Ethernet0" - ] - } - }, - "VLAN_MEMBER": { - "Vlan100|Ethernet0": { - "tagging_mode": "untagged" - } - }, - "VLAN": { - "Vlan100": { - "vlanid": "100", - "dhcp_servers": [ - "192.0.0.1", - "192.0.0.2", - "192.0.0.3", - "192.0.0.4" - ] - } - } - }, - "patch": [ - { - "op": "add", - "path": "/VLAN_MEMBER/Vlan100|Ethernet1", - "value": { - "tagging_mode": "untagged" - } - }, - { - "op": "add", - "path": "/VLAN_MEMBER/Vlan100|Ethernet3", - "value": { - "tagging_mode": "untagged" - } - }, - { - "op": "add", - "path": "/VLAN_MEMBER/Vlan100|Ethernet2", - "value": { - "tagging_mode": "untagged" - } - }, - { - "op": "add", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports/1", - "value": "Ethernet1" - }, - { - "op": "add", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports/2", - "value": "Ethernet2" - }, - { - "op": "add", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports/3", - "value": "Ethernet3" - }, - { - "op": "add", - "path": "/PORT/Ethernet3", - "value": { - "alias": "Eth1/4", - "lanes": "68", - "description": "", - "speed": "10000" - } - }, - { - "op": "add", - "path": "/PORT/Ethernet2", - "value": { - "alias": "Eth1/3", - "lanes": "67", - "description": "", - "speed": "10000" - } - }, - { - "op": "add", - "path": "/PORT/Ethernet1", - "value": { - "alias": "Eth1/2", - "lanes": "66", - "description": "", - "speed": "10000" - } - }, - { - "op": "replace", - "path": "/PORT/Ethernet0/alias", - "value": "Eth1/1" - }, - { - "op": "replace", - "path": "/PORT/Ethernet0/description", - "value": "" - }, - { - "op": "replace", - "path": "/PORT/Ethernet0/lanes", - "value": "65" - }, - { - "op": "replace", - "path": "/PORT/Ethernet0/speed", - "value": "10000" - } - ], - "expected_changes": [ - [ - { - "op": "replace", - "path": "/PORT/Ethernet0/alias", - "value": "Eth1/1" - } - ], - [ - { - "op": "replace", - "path": "/PORT/Ethernet0/description", - "value": "" - } - ], - [ - { - "op": "replace", - "path": "/PORT/Ethernet0/speed", - "value": "10000" - } - ], - [ - { - "op": "remove", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports" - } - ], - [ - { - "op": "remove", - "path": "/ACL_TABLE" - } - ], - [ - { - "op": "add", - "path": "/ACL_TABLE", - "value": { - "NO-NSW-PACL-V4": { - "type": "L3" - } - } - } - ], - [ - { - "op": "add", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports", - "value": [ - "Ethernet0" - ] - } - ], - [ - { - "op": "remove", - "path": "/VLAN_MEMBER" - } - ], - [ - { - "op": "add", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/policy_desc", - "value": "NO-NSW-PACL-V4" - } - ], - [ - { - "op": "remove", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports" - } - ], - [ - { - "op": "remove", - "path": "/PORT" - } - ], - [ - { - "op": "add", - "path": "/PORT", - "value": { - "Ethernet0": { - "alias": "Eth1/1", - "lanes": "65", - "description": "", - "speed": "10000" - } - } - } - ], - [ - { - "op": "add", - "path": "/PORT/Ethernet3", - "value": { - "alias": "Eth1/4", - "lanes": "68", - "description": "", - "speed": "10000" - } - } - ], - [ - { - "op": "add", - "path": "/PORT/Ethernet2", - "value": { - "alias": "Eth1/3", - "lanes": "67", - "description": "", - "speed": "10000" - } - } - ], - [ - { - "op": "add", - "path": "/PORT/Ethernet1", - "value": { - "alias": "Eth1/2", - "lanes": "66", - "description": "", - "speed": "10000" - } - } - ], - [ - { - "op": "add", - "path": "/VLAN_MEMBER", - "value": { - "Vlan100|Ethernet0": { - "tagging_mode": "untagged" - } - } - } - ], - [ - { - "op": "add", - "path": "/VLAN_MEMBER/Vlan100|Ethernet1", - "value": { - "tagging_mode": "untagged" - } - } - ], - [ - { - "op": "add", - "path": "/VLAN_MEMBER/Vlan100|Ethernet3", - "value": { - "tagging_mode": "untagged" - } - } - ], - [ - { - "op": "add", - "path": "/VLAN_MEMBER/Vlan100|Ethernet2", - "value": { - "tagging_mode": "untagged" - } - } - ], - [ - { - "op": "add", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports", - "value": [ - "Ethernet0" - ] - } - ], - [ - { - "op": "add", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports/1", - "value": "Ethernet1" - } - ], - [ - { - "op": "add", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports/2", - "value": "Ethernet2" - } - ], - [ - { - "op": "add", - "path": "/ACL_TABLE/NO-NSW-PACL-V4/ports/3", - "value": "Ethernet3" - } - ] - ] - }, "DPB_4_TO_1__SUCCESS": { "desc": "Dpb 4 to 1 success.", "current_config": { @@ -6157,4 +5833,4 @@ ] ] } -} \ No newline at end of file +} diff --git a/tests/generic_config_updater/gu_common_test.py b/tests/generic_config_updater/gu_common_test.py index 6ba4923664..d0cb3374de 100644 --- a/tests/generic_config_updater/gu_common_test.py +++ b/tests/generic_config_updater/gu_common_test.py @@ -307,23 +307,24 @@ def test_validate_lanes__different_valid_lanes_multi_ports__success(self): }} self.validate_lanes(config) - def test_validate_lanes__same_valid_lanes_single_port__failure(self): - config = {"PORT": {"Ethernet0": {"lanes": "65 \r\t\n, 65", "speed":"10000"}}} - self.validate_lanes(config, '65') - - def test_validate_lanes__same_valid_lanes_multi_ports__failure(self): - config = {"PORT": { - "Ethernet0": {"lanes": "64, 65, 67", "speed":"10000"}, - "Ethernet1": {"lanes": "66, 67, 68", "speed":"10000"}, - }} - self.validate_lanes(config, '67') - - def test_validate_lanes__same_valid_lanes_multi_ports_no_spaces__failure(self): - config = {"PORT": { - "Ethernet0": {"lanes": "64,65,67", "speed":"10000"}, - "Ethernet1": {"lanes": "66,67,68", "speed":"10000"}, - }} - self.validate_lanes(config, '67') + #TODO: uncomment dup lane check test + #def test_validate_lanes__same_valid_lanes_single_port__failure(self): + # config = {"PORT": {"Ethernet0": {"lanes": "65 \r\t\n, 65", "speed":"10000"}}} + # self.validate_lanes(config, '65') + + #def test_validate_lanes__same_valid_lanes_multi_ports__failure(self): + # config = {"PORT": { + # "Ethernet0": {"lanes": "64, 65, 67", "speed":"10000"}, + # "Ethernet1": {"lanes": "66, 67, 68", "speed":"10000"}, + # }} + # self.validate_lanes(config, '67') + + #def test_validate_lanes__same_valid_lanes_multi_ports_no_spaces__failure(self): + # config = {"PORT": { + # "Ethernet0": {"lanes": "64,65,67", "speed":"10000"}, + # "Ethernet1": {"lanes": "66,67,68", "speed":"10000"}, + # }} + # self.validate_lanes(config, '67') def validate_lanes(self, config_db, expected_error=None): # Arrange