Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions tests/common/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def is_service_fully_started(self, service):
except:
return False

def is_container_present(self, service):
def is_container_running(self, service):
"""
Checks where a container exits.

Expand All @@ -400,16 +400,15 @@ def is_container_present(self, service):
True or False
"""
status = self.command(
"docker ps -f name={}".format(service),
module_ignore_errors=True
"docker ps -f name={}".format(service), module_ignore_errors=True
)

if len(status["stdout_lines"]) > 1:
logging.info("container {} status: {}".format(
service, status["stdout"])
)
else:
logging.info("container {} does not exist".format(service))
logging.info("container {} is not running".format(service))

return len(status["stdout_lines"]) > 1

Expand Down Expand Up @@ -1291,8 +1290,9 @@ def stop_service(self, service_name, docker_name):
logging.debug("Stopped {}".format(service_name))

def delete_container(self, service):
if self.is_container_present(service):
self.command("docker rm {}".format(service))
self.command(
"docker rm {}".format(service), module_ignore_errors=True
)

def is_bgp_state_idle(self):
bgp_summary = self.command("show ip bgp summary")["stdout_lines"]
Expand Down Expand Up @@ -1924,12 +1924,12 @@ def delete_container(self, service):
)
return self.sonichost.delete_container(service)

def is_container_present(self, service):
def is_container_running(self, service):
if self.sonichost.is_multi_asic:
service = self._MULTI_ASIC_DOCKER_NAME.format(
service, self.asic_index
)
return self.sonichost.is_container_present(service)
return self.sonichost.is_container_running(service)

def is_service_running(self, service_name, docker_name):
if self.sonichost.is_multi_asic:
Expand Down Expand Up @@ -2129,12 +2129,12 @@ def delete_container(self, service):
for asic in self.asics:
asic.delete_container(service)

def is_container_present(self, service):
def is_container_running(self, service):
if service in self._DEFAULT_SERVICES:
return self.sonichost.is_container_present(service)
return self.sonichost.is_container_running(service)

for asic in self.asics:
if asic.is_container_present(service):
if asic.is_container_running(service):
return True

return False
Expand Down
4 changes: 2 additions & 2 deletions tests/common/system_utils/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ def restore_default_syncd(duthost, creds):
def _perform_swap_syncd_shutdown_check(duthost):
def ready_for_swap():
if any([
duthost.is_container_present("syncd"),
duthost.is_container_present("swss"),
duthost.is_container_running("syncd"),
duthost.is_container_running("swss"),
not duthost.is_bgp_state_idle()
]):
return False
Expand Down