-
Notifications
You must be signed in to change notification settings - Fork 666
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fast-reboot] Fix dump script to support PortChannels in a VLAN group (…
…#1393) Add PortChannels to the list of interfaces (port_id_2_iface) to support FDB dump for PortChannel in a VLAN group. Fix sonic-net/sonic-buildimage#4793 - How I did it - Get LAG ID from the DB. - Find the LAG name from APP DB. - Add it to the list of 'port_id_2_iface' to be used. - How to verify it Reproduce the issue mentioned on this PR and try to run fast-reboot with this fix. - Previous command output (if the output of a command-line utility has changed) Traceback: src_ifs = {map_mac_ip_per_vlan[vlan_name][dst_mac] for vlan_name, dst_mac, _ in arp_entries} KeyError: 'b8:59:9f:a8:e2:00' Signed-off-by: Shlomi Bitton <shlomibi@nvidia.com>
- Loading branch information
1 parent
716e2af
commit f99c5f1
Showing
5 changed files
with
187 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"LAG_MEMBER_TABLE:PortChannel0001:Ethernet128": { | ||
"expireat": 1613562033.6011732, | ||
"ttl": -0.001, | ||
"type": "hash", | ||
"value": { | ||
"status": "enabled" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"ASIC_STATE:SAI_OBJECT_TYPE_BRIDGE_PORT:oid:0x3a000000001724": { | ||
"expireat": 1613562026.636173, | ||
"ttl": -0.001, | ||
"type": "hash", | ||
"value": { | ||
"SAI_BRIDGE_PORT_ATTR_ADMIN_STATE": "true", | ||
"SAI_BRIDGE_PORT_ATTR_FDB_LEARNING_MODE": "SAI_BRIDGE_PORT_FDB_LEARNING_MODE_HW", | ||
"SAI_BRIDGE_PORT_ATTR_PORT_ID": "oid:0x20000000016ea", | ||
"SAI_BRIDGE_PORT_ATTR_TYPE": "SAI_BRIDGE_PORT_TYPE_PORT" | ||
} | ||
}, | ||
"ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF:oid:0xd000000000eea": { | ||
"expireat": 1613562026.59113, | ||
"ttl": -0.001, | ||
"type": "hash", | ||
"value": { | ||
"SAI_HOSTIF_ATTR_NAME": "Ethernet128", | ||
"SAI_HOSTIF_ATTR_OBJ_ID": "oid:0x1000000000ec1", | ||
"SAI_HOSTIF_ATTR_OPER_STATUS": "true", | ||
"SAI_HOSTIF_ATTR_TYPE": "SAI_HOSTIF_TYPE_NETDEV", | ||
"SAI_HOSTIF_ATTR_VLAN_TAG": "SAI_HOSTIF_VLAN_TAG_KEEP" | ||
} | ||
}, | ||
"ASIC_STATE:SAI_OBJECT_TYPE_LAG_MEMBER:oid:0x1b0000000016ee": { | ||
"expireat": 1613562026.634684, | ||
"ttl": -0.001, | ||
"type": "hash", | ||
"value": { | ||
"SAI_LAG_MEMBER_ATTR_EGRESS_DISABLE": "false", | ||
"SAI_LAG_MEMBER_ATTR_INGRESS_DISABLE": "false", | ||
"SAI_LAG_MEMBER_ATTR_LAG_ID": "oid:0x20000000016ea", | ||
"SAI_LAG_MEMBER_ATTR_PORT_ID": "oid:0x1000000000ec1" | ||
} | ||
}, | ||
"ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY:{\"bvid\":\"oid:0x260000000016f3\",\"mac\":\"52:54:00:5D:FC:B7\",\"switch_id\":\"oid:0x21000000000000\"}": { | ||
"expireat": 1613562026.593537, | ||
"ttl": -0.001, | ||
"type": "hash", | ||
"value": { | ||
"SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID": "oid:0x3a000000001724", | ||
"SAI_FDB_ENTRY_ATTR_PACKET_ACTION": "SAI_PACKET_ACTION_FORWARD", | ||
"SAI_FDB_ENTRY_ATTR_TYPE": "SAI_FDB_ENTRY_TYPE_DYNAMIC" | ||
} | ||
}, | ||
"ASIC_STATE:SAI_OBJECT_TYPE_VLAN:oid:0x26000000000013": { | ||
"expireat": 1613562026.598609, | ||
"ttl": -0.001, | ||
"type": "hash", | ||
"value": { | ||
"NULL": "NULL" | ||
} | ||
}, | ||
"ASIC_STATE:SAI_OBJECT_TYPE_VLAN:oid:0x260000000016f3": { | ||
"expireat": 1613562026.589369, | ||
"ttl": -0.001, | ||
"type": "hash", | ||
"value": { | ||
"SAI_VLAN_ATTR_VLAN_ID": "2" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import json | ||
import os | ||
from deepdiff import DeepDiff | ||
from utilities_common.db import Db | ||
import importlib | ||
fast_reboot_dump = importlib.import_module("scripts.fast-reboot-dump") | ||
|
||
class TestFastRebootDump(object): | ||
|
||
@classmethod | ||
def setup_class(cls): | ||
print("SETUP") | ||
|
||
test_db_dumps_directory = os.getcwd() + '/tests/fast_reboot_dump_dbs' | ||
asic_db_object = Db() | ||
app_db_object = Db() | ||
asic_db = asic_db_object.db | ||
app_db = app_db_object.db | ||
populate_db(asic_db, test_db_dumps_directory, 'ASIC_DB.json') | ||
populate_db(app_db, test_db_dumps_directory, 'APPL_DB.json') | ||
|
||
cls.asic_db = asic_db | ||
cls.app_db = app_db | ||
|
||
#Test fast-reboot-dump script to generate all required objects when there is a VLAN interface with a PortChannel member. | ||
def test_generate_fdb_entries_vlan_portcahnnel_member(self): | ||
vlan_ifaces = ['Vlan2'] | ||
|
||
fdb_entries, all_available_macs, map_mac_ip_per_vlan = fast_reboot_dump.generate_fdb_entries_logic(self.asic_db, self.app_db, vlan_ifaces) | ||
|
||
expectd_fdb_entries = [{'FDB_TABLE:Vlan2:52-54-00-5D-FC-B7': {'type': 'dynamic', 'port': 'PortChannel0001'}, 'OP': 'SET'}] | ||
assert not DeepDiff(fdb_entries, expectd_fdb_entries, ignore_order=True) | ||
|
||
expectd_all_available_macs = {('Vlan2', '52:54:00:5d:fc:b7')} | ||
assert not DeepDiff(all_available_macs, expectd_all_available_macs, ignore_order=True) | ||
|
||
expectd_map_mac_ip_per_vlan = {'Vlan2': {'52:54:00:5d:fc:b7': 'PortChannel0001'}} | ||
assert not DeepDiff(map_mac_ip_per_vlan, expectd_map_mac_ip_per_vlan, ignore_order=True) | ||
|
||
@classmethod | ||
def teardown_class(cls): | ||
print("TEARDOWN") | ||
|
||
def populate_db(dbconn, test_db_dumps_directory, db_dump_filename): | ||
db = getattr(dbconn, db_dump_filename.replace('.json','')) | ||
with open(test_db_dumps_directory + '/' + db_dump_filename) as DB: | ||
db_dump = json.load(DB) | ||
for table, fields in db_dump.items(): | ||
for key, value in fields['value'].items(): | ||
dbconn.set(db, table, key, value) |