Check only running containers on assert_containers_running

Change-Id: Ie7d1bb88ea0003ac42b80581c7807503458d57e9
This commit is contained in:
Eduardo Olivares 2020-10-14 12:45:29 +02:00 committed by Federico Ressi
parent dc45906ff7
commit 5b44cff2e7
1 changed files with 13 additions and 6 deletions

View File

@ -138,14 +138,21 @@ def assert_containers_running(group, expected_containers, full_name=True):
format(container, node.name))
# if container exists, check it is running
else:
container_state = \
container_attrs.container_state.values.item()
if not container_state == 'running':
# only one running container is expected
container_running_attrs = container_attrs.query(
'container_state=="running"')
if container_running_attrs.empty:
failures.append(
'expected container {} is not running on node {} , '
'its state is {}! : \n\n'.format(container,
node.name,
container_state))
'its state is {}! : \n\n'.format(
container, node.name,
container_attrs.container_state.values.item()))
elif len(container_running_attrs) > 1:
failures.append(
'only one running container {} was expected on '
'node {}, but got {}! : \n\n'.format(
container, node.name,
len(container_running_attrs)))
if failures:
tobiko.fail('container states mismatched:\n{!s}', '\n'.join(failures))