Skip to content

Commit 1f1fc0d

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 c39a67d commit 1f1fc0d

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
@@ -350,8 +350,121 @@ def test_chassis_system_neigh(self, vct):
350350
assert is_local == "false", "is_local attribute is true for remote neigh"
351351

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

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

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

0 commit comments

Comments
 (0)