Attempting to make service update tests less flaky

Signed-off-by: Viktor Adam <rycus86@gmail.com>
This commit is contained in:
Viktor Adam 2017-11-15 08:17:16 +00:00
parent b2d08e64bc
commit c78e73bf7a
2 changed files with 10 additions and 4 deletions

View File

@ -1150,7 +1150,7 @@ class ServiceTest(BaseAPIIntegrationTest):
try:
self.client.update_service(*args, **kwargs)
except docker.errors.APIError as e:
if e.explanation == "update out of sequence":
if e.explanation.endswith("update out of sequence"):
svc_info = self.client.inspect_service(svc_id)
version_index = svc_info['Version']['Index']
@ -1160,3 +1160,5 @@ class ServiceTest(BaseAPIIntegrationTest):
kwargs['version'] = version_index
self.client.update_service(*args, **kwargs)
else:
raise

View File

@ -188,7 +188,10 @@ class ServiceTest(unittest.TestCase):
image="alpine",
command="sleep 300"
)
assert len(service.tasks()) == 1
tasks = []
while len(tasks) == 0:
tasks = service.tasks()
assert len(tasks) == 1
service.update(
# create argument
name=service.name,
@ -196,8 +199,9 @@ class ServiceTest(unittest.TestCase):
# ContainerSpec argument
command="sleep 600"
)
service.reload()
assert len(service.tasks()) >= 2
while len(tasks) == 1:
tasks = service.tasks()
assert len(tasks) >= 2
@helpers.requires_api_version('1.25')
def test_restart_service(self):