summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/helpers.py24
-rw-r--r--tests/integration/api_service_test.py22
2 files changed, 33 insertions, 13 deletions
diff --git a/tests/helpers.py b/tests/helpers.py
index 1d86619..124ae2d 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -54,13 +54,23 @@ def requires_api_version(version):
)
-def requires_experimental(f):
- @functools.wraps(f)
- def wrapped(self, *args, **kwargs):
- if not self.client.info()['ExperimentalBuild']:
- pytest.skip('Feature requires Docker Engine experimental mode')
- return f(self, *args, **kwargs)
- return wrapped
+def requires_experimental(until=None):
+ test_version = os.environ.get(
+ 'DOCKER_TEST_API_VERSION', docker.constants.DEFAULT_DOCKER_API_VERSION
+ )
+
+ def req_exp(f):
+ @functools.wraps(f)
+ def wrapped(self, *args, **kwargs):
+ if not self.client.info()['ExperimentalBuild']:
+ pytest.skip('Feature requires Docker Engine experimental mode')
+ return f(self, *args, **kwargs)
+
+ if until and docker.utils.version_gte(test_version, until):
+ return f
+ return wrapped
+
+ return req_exp
def wait_on_condition(condition, delay=0.1, timeout=40):
diff --git a/tests/integration/api_service_test.py b/tests/integration/api_service_test.py
index 6858ad0..914e516 100644
--- a/tests/integration/api_service_test.py
+++ b/tests/integration/api_service_test.py
@@ -103,18 +103,28 @@ class ServiceTest(BaseAPIIntegrationTest):
assert services[0]['ID'] == svc_id['ID']
@requires_api_version('1.25')
- @requires_experimental
+ @requires_experimental(until='1.29')
def test_service_logs(self):
name, svc_id = self.create_simple_service()
assert self.get_service_container(name, include_stopped=True)
- logs = self.client.service_logs(svc_id, stdout=True, is_tty=False)
- log_line = next(logs)
+ attempts = 20
+ while True:
+ if attempts == 0:
+ self.fail('No service logs produced by endpoint')
+ return
+ logs = self.client.service_logs(svc_id, stdout=True, is_tty=False)
+ try:
+ log_line = next(logs)
+ except StopIteration:
+ attempts -= 1
+ time.sleep(0.1)
+ continue
+ else:
+ break
+
if six.PY3:
log_line = log_line.decode('utf-8')
assert 'hello\n' in log_line
- assert 'com.docker.swarm.service.id={}'.format(
- svc_id['ID']
- ) in log_line
def test_create_service_custom_log_driver(self):
container_spec = docker.types.ContainerSpec(