Skip to content

Commit a2d9be4

Browse files
committed
simplify start_swss/stop_swss
Signed-off-by: Guohan Lu <gulv@microsoft.com>
1 parent d76a560 commit a2d9be4

2 files changed

Lines changed: 33 additions & 45 deletions

File tree

tests/conftest.py

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -128,21 +128,20 @@ def runcmd_async(self, cmd):
128128

129129
class DockerVirtualSwitch(object):
130130
def __init__(self, name=None):
131-
self.pnames = ['fpmsyncd',
132-
'intfmgrd',
133-
'intfsyncd',
134-
'neighsyncd',
135-
'orchagent',
136-
'portsyncd',
137-
'redis-server',
138-
'rsyslogd',
139-
'syncd',
140-
'teamsyncd',
141-
'vlanmgrd',
142-
'vrfmgrd',
143-
'teammgrd',
144-
'portmgrd',
145-
'zebra']
131+
self.basicd = ['redis-server',
132+
'rsyslogd']
133+
self.swssd = ['orchagent',
134+
'intfmgrd',
135+
'intfsyncd',
136+
'neighsyncd',
137+
'portsyncd',
138+
'vlanmgrd',
139+
'vrfmgrd',
140+
'portmgrd']
141+
self.syncd = ['syncd']
142+
self.rtd = ['fpmsyncd', 'zebra']
143+
self.teamd = ['teamsyncd', 'teammgrd']
144+
self.alld = self.basicd + self.swssd + self.syncd + self.rtd + self.teamd
146145
self.mount = "/var/run/redis-vs"
147146
self.redis_sock = self.mount + '/' + "redis.sock"
148147
self.client = docker.from_env()
@@ -236,7 +235,7 @@ def check_ready(self, timeout=30):
236235

237236
# check if all processes are running
238237
ready = True
239-
for pname in self.pnames:
238+
for pname in self.alld:
240239
try:
241240
if process_status[pname] != "RUNNING":
242241
ready = False
@@ -259,6 +258,20 @@ def check_ready(self, timeout=30):
259258
def restart(self):
260259
self.ctn.restart()
261260

261+
# start processes in SWSS
262+
def start_swss(self):
263+
cmd = ""
264+
for pname in self.swssd:
265+
cmd += "supervisorctl start {}; ".format(pname)
266+
self.runcmd(['sh', '-c', cmd])
267+
268+
# stop processes in SWSS
269+
def stop_swss(self):
270+
cmd = ""
271+
for pname in self.swssd:
272+
cmd += "supervisorctl stop {}; ".format(pname)
273+
self.runcmd(['sh', '-c', cmd])
274+
262275
def init_asicdb_validator(self):
263276
self.asicdb = AsicDbValidator(self)
264277

@@ -523,18 +536,6 @@ def setReadOnlyAttr(self, obj, attr, val):
523536

524537
ntf.send("set_ro", key, fvp)
525538

526-
# start processes in SWSS
527-
def start_swss(self):
528-
self.runcmd(['sh', '-c', 'supervisorctl start orchagent; supervisorctl start portsyncd; supervisorctl start intfsyncd; \
529-
supervisorctl start neighsyncd; supervisorctl start intfmgrd; supervisorctl start vlanmgrd; \
530-
supervisorctl start buffermgrd; supervisorctl start arp_update'])
531-
532-
# stop processes in SWSS
533-
def stop_swss(self):
534-
self.runcmd(['sh', '-c', 'supervisorctl stop orchagent; supervisorctl stop portsyncd; supervisorctl stop intfsyncd; \
535-
supervisorctl stop neighsyncd; supervisorctl stop intfmgrd; supervisorctl stop vlanmgrd; \
536-
supervisorctl stop buffermgrd; supervisorctl stop arp_update'])
537-
538539
@pytest.yield_fixture(scope="module")
539540
def dvs(request):
540541
name = request.config.getoption("--dvsname")

tests/test_warm_reboot.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,6 @@
44
import time
55
import json
66

7-
# start processes in SWSS
8-
def start_swss(dvs):
9-
dvs.runcmd(['sh', '-c', 'supervisorctl start orchagent; supervisorctl start portsyncd; supervisorctl start intfsyncd; \
10-
supervisorctl start neighsyncd; supervisorctl start intfmgrd; supervisorctl start vlanmgrd; \
11-
supervisorctl start buffermgrd; supervisorctl start arp_update'])
12-
13-
# stop processes in SWSS
14-
def stop_swss(dvs):
15-
dvs.runcmd(['sh', '-c', 'supervisorctl stop orchagent; supervisorctl stop portsyncd; supervisorctl stop intfsyncd; \
16-
supervisorctl stop neighsyncd; supervisorctl stop intfmgrd; supervisorctl stop vlanmgrd; \
17-
supervisorctl stop buffermgrd; supervisorctl stop arp_update'])
18-
19-
207
# Get restore count of all processes supporting warm restart
218
def swss_get_RestoreCount(state_db):
229
restore_count = {}
@@ -718,8 +705,8 @@ def test_OrchagentWarmRestartReadyCheck(dvs):
718705
assert result == "RESTARTCHECK failed\n"
719706

720707
# recover for test cases after this one.
721-
stop_swss(dvs)
722-
start_swss(dvs)
708+
dvs.stop_swss()
709+
dvs.start_swss()
723710
time.sleep(5)
724711

725712
def test_swss_port_state_syncup(dvs):
@@ -764,7 +751,7 @@ def test_swss_port_state_syncup(dvs):
764751
else:
765752
assert oper_status == "down"
766753

767-
stop_swss(dvs)
754+
dvs.stop_swss()
768755
time.sleep(3)
769756

770757
# flap the port oper status for Ethernet0, Ethernet4 and Ethernet8
@@ -776,7 +763,7 @@ def test_swss_port_state_syncup(dvs):
776763
dvs.servers[1].runcmd("ip link set up dev eth0") == 0
777764

778765
time.sleep(5)
779-
start_swss(dvs)
766+
dvs.start_swss()
780767
time.sleep(10)
781768

782769
swss_check_RestoreCount(state_db, restore_count)

0 commit comments

Comments
 (0)