summaryrefslogtreecommitdiff
path: root/tests/integration/api_service_test.py
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2018-01-31 12:29:26 -0800
committerJoffrey F <joffrey@docker.com>2018-01-31 12:42:11 -0800
commit5347c168d022836bd19f63c5527c59169ae22f53 (patch)
treea89da7f120f21332ab645995d97de70fc594d056 /tests/integration/api_service_test.py
parent0750337f6a77bdfb46579184ac4950a212e5d048 (diff)
downloaddocker-py-1878-publishmode.tar.gz
Add support for publish mode for endpointspec ports1878-publishmode
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'tests/integration/api_service_test.py')
-rw-r--r--tests/integration/api_service_test.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/integration/api_service_test.py b/tests/integration/api_service_test.py
index 7620cb4..5cc3fc1 100644
--- a/tests/integration/api_service_test.py
+++ b/tests/integration/api_service_test.py
@@ -353,7 +353,6 @@ class ServiceTest(BaseAPIIntegrationTest):
task_tmpl, name=name, endpoint_spec=endpoint_spec
)
svc_info = self.client.inspect_service(svc_id)
- print(svc_info)
ports = svc_info['Spec']['EndpointSpec']['Ports']
for port in ports:
if port['PublishedPort'] == 12562:
@@ -370,6 +369,26 @@ class ServiceTest(BaseAPIIntegrationTest):
assert len(ports) == 3
+ @requires_api_version('1.32')
+ def test_create_service_with_endpoint_spec_host_publish_mode(self):
+ container_spec = docker.types.ContainerSpec(BUSYBOX, ['true'])
+ task_tmpl = docker.types.TaskTemplate(container_spec)
+ name = self.get_service_name()
+ endpoint_spec = docker.types.EndpointSpec(ports={
+ 12357: (1990, None, 'host'),
+ })
+ svc_id = self.client.create_service(
+ task_tmpl, name=name, endpoint_spec=endpoint_spec
+ )
+ svc_info = self.client.inspect_service(svc_id)
+ ports = svc_info['Spec']['EndpointSpec']['Ports']
+ assert len(ports) == 1
+ port = ports[0]
+ assert port['PublishedPort'] == 12357
+ assert port['TargetPort'] == 1990
+ assert port['Protocol'] == 'tcp'
+ assert port['PublishMode'] == 'host'
+
def test_create_service_with_env(self):
container_spec = docker.types.ContainerSpec(
BUSYBOX, ['true'], env={'DOCKER_PY_TEST': 1}