Skip to content

Commit a10aa69

Browse files
author
vedganes
committed
[voq/inbandif]Code review comments fix 2
Signed-off-by: vedganes <vedavinayagam.ganesan@nokia.com> Added vs test case for system neigh delete
1 parent 3030ee0 commit a10aa69

File tree

1 file changed

+114
-1
lines changed

1 file changed

+114
-1
lines changed

tests/test_virtual_chassis.py

+114-1
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,121 @@ def test_chassis_system_neigh(self, vct):
342342
assert is_local == "false", "is_local attribute is true for remote neigh"
343343

344344
break
345+
346+
def test_chassis_system_neigh_del(self, vct):
347+
"""Test neigh record deletion and syncing to chassis app db.
348+
349+
Pre-requisites:
350+
(i) Test case: test_chassis_system_neigh
351+
This test validates that:
352+
(i) Local neighbor entry is deleted when neighbor is deleted
353+
(ii) Local neighbor delete is synced to chassis ap db
354+
(iii) Remote neighbor entry is cleared in ASIC_DB
355+
"""
356+
357+
inband_port = "Ethernet0"
358+
359+
# Test neighbor on Ethernet4 since Ethernet0 is used as Inband port
360+
test_neigh_dev = "Ethernet4"
361+
test_neigh_ip = "10.8.104.3"
362+
363+
dvss = vct.dvss
364+
for name in dvss.keys():
365+
dvs = dvss[name]
366+
367+
config_db = dvs.get_config_db()
368+
metatbl = config_db.get_entry("DEVICE_METADATA", "localhost")
369+
370+
cfg_switch_type = metatbl.get("switch_type")
371+
372+
# Neighbor record verifiation done in line card
373+
if cfg_switch_type == "voq":
374+
lc_switch_id = metatbl.get("switch_id")
375+
assert lc_switch_id != "", "Got error in getting switch_id from CONFIG_DB DEVICE_METADATA"
376+
if lc_switch_id == "0":
377+
378+
# Delete the static neighbor neighbor
379+
_, res = dvs.runcmd(['sh', "-c", f"ip neigh del {test_neigh_ip} dev {test_neigh_dev}"])
380+
assert res == "", "Error deleting static neigh"
381+
382+
# Check for presence of the neighbor in ASIC_DB. The deleted neighbor should
383+
# not be present in the asic db
384+
asic_db = dvs.get_asic_db()
385+
neighkeys = asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY")
386+
387+
test_neigh = ""
388+
for nkey in neighkeys:
389+
ne = ast.literal_eval(nkey)
390+
if ne['ip'] == test_neigh_ip:
391+
test_neigh = nkey
392+
break
393+
394+
assert test_neigh == "", "Stale neigh entry found in ASIC_DB"
395+
396+
break
397+
398+
# Verify syncing of neighbor record delete in chassis app db
399+
dvss = vct.dvss
400+
for name in dvss.keys():
401+
if name.startswith("supervisor"):
402+
dvs = dvss[name]
403+
chassis_app_db = DVSDatabase(swsscommon.CHASSIS_APP_DB, dvs.redis_chassis_sock)
404+
sysneighkeys = chassis_app_db.get_keys("SYSTEM_NEIGH")
345405

346-
# Cleanup
406+
test_sysneigh = ""
407+
for sysnk in sysneighkeys:
408+
sysnk_tok = sysnk.split("|")
409+
assert len(sysnk_tok) == 3, "Invalid system neigh key in chassis app db"
410+
if sysnk_tok[2] == test_neigh_ip:
411+
test_sysneigh = sysnk
412+
break
413+
414+
assert test_sysneigh == "", "Stale neigh entry in chassis app db"
415+
416+
break
417+
418+
# Verify clearing of remote neighbor in non-owner linecard
419+
dvss = vct.dvss
420+
for name in dvss.keys():
421+
dvs = dvss[name]
422+
423+
config_db = dvs.get_config_db()
424+
metatbl = config_db.get_entry("DEVICE_METADATA", "localhost")
425+
426+
cfg_switch_type = metatbl.get("switch_type")
427+
428+
# Neighbor record verifiation done in line card
429+
if cfg_switch_type == "voq":
430+
lc_switch_id = metatbl.get("switch_id")
431+
assert lc_switch_id != "", "Got error in getting switch_id from CONFIG_DB DEVICE_METADATA"
432+
if lc_switch_id != "0":
433+
# Linecard other than linecard 1
434+
435+
# Check for presence of the remote neighbor in ASIC_DB. The remote neighbor corresponding
436+
# to the deleted static neigbor should not be present
437+
asic_db = dvs.get_asic_db()
438+
neighkeys = asic_db.get_keys("ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY")
439+
440+
remote_neigh = ""
441+
for nkey in neighkeys:
442+
ne = ast.literal_eval(nkey)
443+
if ne['ip'] == test_neigh_ip:
444+
remote_neigh = nkey
445+
break
446+
447+
assert remote_neigh == "", "Stale remote neigh in ASIC_DB"
448+
449+
# Check for kernel entries. Kernel entries (neigh and route) should have been removed
450+
451+
_, output = dvs.runcmd("ip neigh show")
452+
assert f"{test_neigh_ip} dev {inband_port}" not in output, "Kernel neigh of remote neighbor not removed"
453+
454+
_, output = dvs.runcmd("ip route show")
455+
assert f"{test_neigh_ip} dev {inband_port} scope link" not in output, "Kernel route of remote neighbor not removed"
456+
457+
break
458+
459+
# Cleanup inband if configuration
347460
self.del_inbandif_port(vct, inband_port)
348461

349462
# Add Dummy always-pass test at end as workaroud

0 commit comments

Comments
 (0)