Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
making lgtm happy
Added two more test cases
  • Loading branch information
tahmed-dev committed Jun 22, 2020
1 parent 4c1b8cc commit be445f8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
3 changes: 2 additions & 1 deletion scripts/fast-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then
# Dump the ARP and FDB tables to files also as default routes for both IPv4 and IPv6
# into /host/fast-reboot
DUMP_DIR=/host/fast-reboot
CONFIG_DB_FILE=/etc/sonic/config_db.json
mkdir -p $DUMP_DIR
FAST_REBOOT_DUMP_RC=0
/usr/bin/fast-reboot-dump.py -t $DUMP_DIR || FAST_REBOOT_DUMP_RC=$?
Expand All @@ -426,7 +427,7 @@ if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then
FILTER_FDB_ENTRIES_RC=0
# Filter FDB entries using MAC addresses from ARP table
/usr/bin/filter_fdb_entries.py -f $DUMP_DIR/fdb.json -a $DUMP_DIR/arp.json -c $DUMP_DIR/config_db.json || FILTER_FDB_ENTRIES_RC=$?
/usr/bin/filter_fdb_entries.py -f $DUMP_DIR/fdb.json -a $DUMP_DIR/arp.json -c $CONFIG_DB_FILE || FILTER_FDB_ENTRIES_RC=$?
if [[ FILTER_FDB_ENTRIES_RC -ne 0 ]]; then
error "Failed to filter FDb entries. Exit code: $FILTER_FDB_ENTRIES_RC"
unload_kernel
Expand Down
3 changes: 1 addition & 2 deletions scripts/filter_fdb_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ def get_vlan_entries_map(filename):
Returns:
vlan_map(dict) map of Vlan configuration for SONiC device
"""
config_db_entries = defaultdict()
with open(filename, 'r') as fp:
config_db_entries = json.load(fp)

return config_db_entries["VLAN"] if "VLAN" in config_db_entries else defaultdict()
return config_db_entries["VLAN"] if "VLAN" in config_db_entries.keys() else defaultdict()

def get_arp_entries_map(arp_filename, config_db_filename):
"""
Expand Down
1 change: 0 additions & 1 deletion sonic-utilities-tests/filter_fdb_entries_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def __tearDown(self):
Returns:
None
"""
return
os.remove(self.ARP_FILENAME)
os.remove(self.EXPECTED_FDB_FILENAME)
fdbFiles = glob.glob(self.FDB_FILENAME + '*')
Expand Down
17 changes: 17 additions & 0 deletions sonic-utilities-tests/filter_fdb_input/test_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,21 @@
"config_db": "sonic-utilities-tests/filter_fdb_input/config_db.json",
"expected_fdb": "sonic-utilities-tests/filter_fdb_input/expected_fdb.json"
},
{
"arp": "sonic-utilities-tests/filter_fdb_input/arp.json",
"fdb": "sonic-utilities-tests/filter_fdb_input/fdb.json",
"config_db": {"VLAN": {
"Vlan1": {}
}},
"expected_fdb": [
],
},
{
"arp": "sonic-utilities-tests/filter_fdb_input/arp.json",
"fdb": "sonic-utilities-tests/filter_fdb_input/fdb.json",
"config_db": {
},
"expected_fdb": [
],
},
]

0 comments on commit be445f8

Please sign in to comment.