diff options
| author | Viktor Adam <rycus86@gmail.com> | 2017-11-15 08:17:16 +0000 |
|---|---|---|
| committer | Viktor Adam <rycus86@gmail.com> | 2017-11-15 08:17:16 +0000 |
| commit | c78e73bf7ac87feb8bef35921492a98e5727d9a5 (patch) | |
| tree | 259f3bc54828a35966627d9b44aec9785888a11d | |
| parent | b2d08e64bceb81b75df8de6b0ad1948488bb4b28 (diff) | |
| download | docker-py-c78e73bf7ac87feb8bef35921492a98e5727d9a5.tar.gz | |
Attempting to make service update tests less flaky
Signed-off-by: Viktor Adam <rycus86@gmail.com>
| -rw-r--r-- | tests/integration/api_service_test.py | 4 | ||||
| -rw-r--r-- | tests/integration/models_services_test.py | 10 |
2 files changed, 10 insertions, 4 deletions
diff --git a/tests/integration/api_service_test.py b/tests/integration/api_service_test.py index 60fdcf8..10ae180 100644 --- a/tests/integration/api_service_test.py +++ b/tests/integration/api_service_test.py @@ -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 diff --git a/tests/integration/models_services_test.py b/tests/integration/models_services_test.py index ee8a348..cb96ff1 100644 --- a/tests/integration/models_services_test.py +++ b/tests/integration/models_services_test.py @@ -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): |
