Skip to content

Commit 34e157e

Browse files
jipanyanglguohan
authored andcommitted
[VS]: fix swss warm restart test (#662)
Signed-off-by: Jipan Yang <[email protected]>
1 parent 6e76e9b commit 34e157e

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

tests/test_warm_reboot.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
import json
66

77
# Get restore count of all processes supporting warm restart
8-
def swss_get_RestoreCount(state_db):
8+
def swss_get_RestoreCount(dvs, state_db):
99
restore_count = {}
1010
warmtbl = swsscommon.Table(state_db, swsscommon.STATE_WARM_RESTART_TABLE_NAME)
1111
keys = warmtbl.getKeys()
1212
assert len(keys) != 0
1313
for key in keys:
14+
if key not in dvs.swssd:
15+
continue
1416
(status, fvs) = warmtbl.get(key)
1517
assert status == True
1618
for fv in fvs:
@@ -20,12 +22,14 @@ def swss_get_RestoreCount(state_db):
2022
return restore_count
2123

2224
# function to check the restore count incremented by 1 for all processes supporting warm restart
23-
def swss_check_RestoreCount(state_db, restore_count):
25+
def swss_check_RestoreCount(dvs, state_db, restore_count):
2426
warmtbl = swsscommon.Table(state_db, swsscommon.STATE_WARM_RESTART_TABLE_NAME)
2527
keys = warmtbl.getKeys()
2628
print(keys)
2729
assert len(keys) > 0
2830
for key in keys:
31+
if key not in dvs.swssd:
32+
continue
2933
(status, fvs) = warmtbl.get(key)
3034
assert status == True
3135
for fv in fvs:
@@ -144,7 +148,7 @@ def test_PortSyncdWarmRestart(dvs, testlog):
144148
(status, fvs) = neighTbl.get("Ethernet20:11.0.0.10")
145149
assert status == True
146150

147-
restore_count = swss_get_RestoreCount(state_db)
151+
restore_count = swss_get_RestoreCount(dvs, state_db)
148152

149153
# restart portsyncd
150154
dvs.runcmd(['sh', '-c', 'pkill -x portsyncd'])
@@ -255,7 +259,7 @@ def test_VlanMgrdWarmRestart(dvs, testlog):
255259
(exitcode, bv_before) = dvs.runcmd("bridge vlan")
256260
print(bv_before)
257261

258-
restore_count = swss_get_RestoreCount(state_db)
262+
restore_count = swss_get_RestoreCount(dvs, state_db)
259263

260264
dvs.runcmd(['sh', '-c', 'pkill -x vlanmgrd'])
261265

@@ -376,7 +380,7 @@ def test_swss_neighbor_syncup(dvs, testlog):
376380
#
377381

378382
# get restore_count
379-
restore_count = swss_get_RestoreCount(state_db)
383+
restore_count = swss_get_RestoreCount(dvs, state_db)
380384

381385
# stop neighsyncd and sairedis.rec
382386
stop_neighsyncd(dvs)
@@ -425,7 +429,7 @@ def test_swss_neighbor_syncup(dvs, testlog):
425429
# just that if we want to add the same neighbor again, use "change" instead of "add"
426430

427431
# get restore_count
428-
restore_count = swss_get_RestoreCount(state_db)
432+
restore_count = swss_get_RestoreCount(dvs, state_db)
429433

430434
# stop neighsyncd
431435
stop_neighsyncd(dvs)
@@ -496,7 +500,7 @@ def test_swss_neighbor_syncup(dvs, testlog):
496500
# Check the timer is not retrieved from configDB since it is not configured
497501

498502
# get restore_count
499-
restore_count = swss_get_RestoreCount(state_db)
503+
restore_count = swss_get_RestoreCount(dvs, state_db)
500504

501505
# stop neighsyncd
502506
stop_neighsyncd(dvs)
@@ -571,7 +575,7 @@ def test_swss_neighbor_syncup(dvs, testlog):
571575
dvs.runcmd("config warm_restart neighsyncd_timer {}".format(timer_value))
572576

573577
# get restore_count
574-
restore_count = swss_get_RestoreCount(state_db)
578+
restore_count = swss_get_RestoreCount(dvs, state_db)
575579

576580
# stop neighsyncd
577581
stop_neighsyncd(dvs)
@@ -719,7 +723,7 @@ def test_swss_port_state_syncup(dvs, testlog):
719723

720724
tbl = swsscommon.Table(appl_db, swsscommon.APP_PORT_TABLE_NAME)
721725

722-
restore_count = swss_get_RestoreCount(state_db)
726+
restore_count = swss_get_RestoreCount(dvs, state_db)
723727

724728
# update port admin state
725729
dvs.runcmd("ifconfig Ethernet0 10.0.0.0/31 up")
@@ -766,7 +770,7 @@ def test_swss_port_state_syncup(dvs, testlog):
766770
dvs.start_swss()
767771
time.sleep(10)
768772

769-
swss_check_RestoreCount(state_db, restore_count)
773+
swss_check_RestoreCount(dvs, state_db, restore_count)
770774

771775
for i in [0, 1, 2]:
772776
(status, fvs) = tbl.get("Ethernet%d" % (i * 4))

0 commit comments

Comments
 (0)