Skip to content

Commit

Permalink
simplify start_swss/stop_swss
Browse files Browse the repository at this point in the history
Signed-off-by: Guohan Lu <gulv@microsoft.com>
  • Loading branch information
lguohan committed Oct 22, 2018
1 parent d76a560 commit a2d9be4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 45 deletions.
57 changes: 29 additions & 28 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,20 @@ def runcmd_async(self, cmd):

class DockerVirtualSwitch(object):
def __init__(self, name=None):
self.pnames = ['fpmsyncd',
'intfmgrd',
'intfsyncd',
'neighsyncd',
'orchagent',
'portsyncd',
'redis-server',
'rsyslogd',
'syncd',
'teamsyncd',
'vlanmgrd',
'vrfmgrd',
'teammgrd',
'portmgrd',
'zebra']
self.basicd = ['redis-server',
'rsyslogd']
self.swssd = ['orchagent',
'intfmgrd',
'intfsyncd',
'neighsyncd',
'portsyncd',
'vlanmgrd',
'vrfmgrd',
'portmgrd']
self.syncd = ['syncd']
self.rtd = ['fpmsyncd', 'zebra']
self.teamd = ['teamsyncd', 'teammgrd']
self.alld = self.basicd + self.swssd + self.syncd + self.rtd + self.teamd
self.mount = "/var/run/redis-vs"
self.redis_sock = self.mount + '/' + "redis.sock"
self.client = docker.from_env()
Expand Down Expand Up @@ -236,7 +235,7 @@ def check_ready(self, timeout=30):

# check if all processes are running
ready = True
for pname in self.pnames:
for pname in self.alld:
try:
if process_status[pname] != "RUNNING":
ready = False
Expand All @@ -259,6 +258,20 @@ def check_ready(self, timeout=30):
def restart(self):
self.ctn.restart()

# start processes in SWSS
def start_swss(self):
cmd = ""
for pname in self.swssd:
cmd += "supervisorctl start {}; ".format(pname)
self.runcmd(['sh', '-c', cmd])

# stop processes in SWSS
def stop_swss(self):
cmd = ""
for pname in self.swssd:
cmd += "supervisorctl stop {}; ".format(pname)
self.runcmd(['sh', '-c', cmd])

def init_asicdb_validator(self):
self.asicdb = AsicDbValidator(self)

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

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

# start processes in SWSS
def start_swss(self):
self.runcmd(['sh', '-c', 'supervisorctl start orchagent; supervisorctl start portsyncd; supervisorctl start intfsyncd; \
supervisorctl start neighsyncd; supervisorctl start intfmgrd; supervisorctl start vlanmgrd; \
supervisorctl start buffermgrd; supervisorctl start arp_update'])

# stop processes in SWSS
def stop_swss(self):
self.runcmd(['sh', '-c', 'supervisorctl stop orchagent; supervisorctl stop portsyncd; supervisorctl stop intfsyncd; \
supervisorctl stop neighsyncd; supervisorctl stop intfmgrd; supervisorctl stop vlanmgrd; \
supervisorctl stop buffermgrd; supervisorctl stop arp_update'])

@pytest.yield_fixture(scope="module")
def dvs(request):
name = request.config.getoption("--dvsname")
Expand Down
21 changes: 4 additions & 17 deletions tests/test_warm_reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,6 @@
import time
import json

# start processes in SWSS
def start_swss(dvs):
dvs.runcmd(['sh', '-c', 'supervisorctl start orchagent; supervisorctl start portsyncd; supervisorctl start intfsyncd; \
supervisorctl start neighsyncd; supervisorctl start intfmgrd; supervisorctl start vlanmgrd; \
supervisorctl start buffermgrd; supervisorctl start arp_update'])

# stop processes in SWSS
def stop_swss(dvs):
dvs.runcmd(['sh', '-c', 'supervisorctl stop orchagent; supervisorctl stop portsyncd; supervisorctl stop intfsyncd; \
supervisorctl stop neighsyncd; supervisorctl stop intfmgrd; supervisorctl stop vlanmgrd; \
supervisorctl stop buffermgrd; supervisorctl stop arp_update'])


# Get restore count of all processes supporting warm restart
def swss_get_RestoreCount(state_db):
restore_count = {}
Expand Down Expand Up @@ -718,8 +705,8 @@ def test_OrchagentWarmRestartReadyCheck(dvs):
assert result == "RESTARTCHECK failed\n"

# recover for test cases after this one.
stop_swss(dvs)
start_swss(dvs)
dvs.stop_swss()
dvs.start_swss()
time.sleep(5)

def test_swss_port_state_syncup(dvs):
Expand Down Expand Up @@ -764,7 +751,7 @@ def test_swss_port_state_syncup(dvs):
else:
assert oper_status == "down"

stop_swss(dvs)
dvs.stop_swss()
time.sleep(3)

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

time.sleep(5)
start_swss(dvs)
dvs.start_swss()
time.sleep(10)

swss_check_RestoreCount(state_db, restore_count)
Expand Down

0 comments on commit a2d9be4

Please sign in to comment.