mirror of
https://github.com/docker/compose.git
synced 2025-07-25 14:44:29 +02:00
Fix flaky log test by using container status, instead of boolean state.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
3f7e5bf768
commit
8d9adc0902
@ -78,21 +78,20 @@ class ContainerCountCondition(object):
|
|||||||
|
|
||||||
class ContainerStateCondition(object):
|
class ContainerStateCondition(object):
|
||||||
|
|
||||||
def __init__(self, client, name, running):
|
def __init__(self, client, name, status):
|
||||||
self.client = client
|
self.client = client
|
||||||
self.name = name
|
self.name = name
|
||||||
self.running = running
|
self.status = status
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
try:
|
try:
|
||||||
container = self.client.inspect_container(self.name)
|
container = self.client.inspect_container(self.name)
|
||||||
return container['State']['Running'] == self.running
|
return container['State']['Status'] == self.status
|
||||||
except errors.APIError:
|
except errors.APIError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
state = 'running' if self.running else 'stopped'
|
return "waiting for container to be %s" % self.status
|
||||||
return "waiting for container to be %s" % state
|
|
||||||
|
|
||||||
|
|
||||||
class CLITestCase(DockerClientTestCase):
|
class CLITestCase(DockerClientTestCase):
|
||||||
@ -1073,26 +1072,26 @@ class CLITestCase(DockerClientTestCase):
|
|||||||
wait_on_condition(ContainerStateCondition(
|
wait_on_condition(ContainerStateCondition(
|
||||||
self.project.client,
|
self.project.client,
|
||||||
'simplecomposefile_simple_run_1',
|
'simplecomposefile_simple_run_1',
|
||||||
running=True))
|
'running'))
|
||||||
|
|
||||||
os.kill(proc.pid, signal.SIGINT)
|
os.kill(proc.pid, signal.SIGINT)
|
||||||
wait_on_condition(ContainerStateCondition(
|
wait_on_condition(ContainerStateCondition(
|
||||||
self.project.client,
|
self.project.client,
|
||||||
'simplecomposefile_simple_run_1',
|
'simplecomposefile_simple_run_1',
|
||||||
running=False))
|
'exited'))
|
||||||
|
|
||||||
def test_run_handles_sigterm(self):
|
def test_run_handles_sigterm(self):
|
||||||
proc = start_process(self.base_dir, ['run', '-T', 'simple', 'top'])
|
proc = start_process(self.base_dir, ['run', '-T', 'simple', 'top'])
|
||||||
wait_on_condition(ContainerStateCondition(
|
wait_on_condition(ContainerStateCondition(
|
||||||
self.project.client,
|
self.project.client,
|
||||||
'simplecomposefile_simple_run_1',
|
'simplecomposefile_simple_run_1',
|
||||||
running=True))
|
'running'))
|
||||||
|
|
||||||
os.kill(proc.pid, signal.SIGTERM)
|
os.kill(proc.pid, signal.SIGTERM)
|
||||||
wait_on_condition(ContainerStateCondition(
|
wait_on_condition(ContainerStateCondition(
|
||||||
self.project.client,
|
self.project.client,
|
||||||
'simplecomposefile_simple_run_1',
|
'simplecomposefile_simple_run_1',
|
||||||
running=False))
|
'exited'))
|
||||||
|
|
||||||
def test_rm(self):
|
def test_rm(self):
|
||||||
service = self.project.get_service('simple')
|
service = self.project.get_service('simple')
|
||||||
@ -1207,7 +1206,7 @@ class CLITestCase(DockerClientTestCase):
|
|||||||
wait_on_condition(ContainerStateCondition(
|
wait_on_condition(ContainerStateCondition(
|
||||||
self.project.client,
|
self.project.client,
|
||||||
'logscomposefile_another_1',
|
'logscomposefile_another_1',
|
||||||
running=False))
|
'exited'))
|
||||||
|
|
||||||
os.kill(proc.pid, signal.SIGINT)
|
os.kill(proc.pid, signal.SIGINT)
|
||||||
result = wait_on_process(proc, returncode=1)
|
result = wait_on_process(proc, returncode=1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user