diff --git a/tests/conftest.py b/tests/conftest.py index 61fde99ebab3..57cf0efb53d8 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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() @@ -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 @@ -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) @@ -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") diff --git a/tests/test_warm_reboot.py b/tests/test_warm_reboot.py index 2a7d69422096..f83bfffb6707 100644 --- a/tests/test_warm_reboot.py +++ b/tests/test_warm_reboot.py @@ -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 = {} @@ -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): @@ -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 @@ -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)