diff options
author | Joffrey F <joffrey@docker.com> | 2017-11-02 14:06:05 -0700 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2017-11-06 19:21:03 -0800 |
commit | ac982fb3be93eec5d2d5afff72cc8225e40bce58 (patch) | |
tree | 392e1108b9acaa3aa3d63439960f5ac7bb6898d5 | |
parent | 277a8732977c6cdef84cd593d10676fc4518cfdf (diff) | |
download | docker-py-ac982fb3be93eec5d2d5afff72cc8225e40bce58.tar.gz |
Fix build tests to not rely on internet connectivity
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r-- | tests/integration/api_build_test.py | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/tests/integration/api_build_test.py b/tests/integration/api_build_test.py index 21464ff..f72c7e6 100644 --- a/tests/integration/api_build_test.py +++ b/tests/integration/api_build_test.py @@ -8,8 +8,8 @@ from docker import errors import pytest import six -from .base import BaseAPIIntegrationTest -from ..helpers import requires_api_version, requires_experimental +from .base import BaseAPIIntegrationTest, BUSYBOX +from ..helpers import random_name, requires_api_version, requires_experimental class BuildTest(BaseAPIIntegrationTest): @@ -214,21 +214,31 @@ class BuildTest(BaseAPIIntegrationTest): @requires_api_version('1.25') def test_build_with_network_mode(self): + # Set up pingable endpoint on custom network + network = self.client.create_network(random_name())['Id'] + self.tmp_networks.append(network) + container = self.client.create_container(BUSYBOX, 'top') + self.tmp_containers.append(container) + self.client.start(container) + self.client.connect_container_to_network( + container, network, aliases=['pingtarget.docker'] + ) + script = io.BytesIO('\n'.join([ 'FROM busybox', - 'RUN wget http://google.com' + 'RUN ping -c1 pingtarget.docker' ]).encode('ascii')) stream = self.client.build( - fileobj=script, network_mode='bridge', - tag='dockerpytest_bridgebuild' + fileobj=script, network_mode=network, + tag='dockerpytest_customnetbuild' ) - self.tmp_imgs.append('dockerpytest_bridgebuild') + self.tmp_imgs.append('dockerpytest_customnetbuild') for chunk in stream: - pass + print chunk - assert self.client.inspect_image('dockerpytest_bridgebuild') + assert self.client.inspect_image('dockerpytest_customnetbuild') script.seek(0) stream = self.client.build( @@ -260,7 +270,7 @@ class BuildTest(BaseAPIIntegrationTest): fileobj=script, tag=img_name, extra_hosts={ 'extrahost.local.test': '127.0.0.1', - 'hello.world.test': '8.8.8.8', + 'hello.world.test': '127.0.0.1', }, decode=True ) for chunk in stream: @@ -274,7 +284,7 @@ class BuildTest(BaseAPIIntegrationTest): if six.PY3: logs = logs.decode('utf-8') assert '127.0.0.1\textrahost.local.test' in logs - assert '8.8.8.8\thello.world.test' in logs + assert '127.0.0.1\thello.world.test' in logs @requires_experimental(until=None) @requires_api_version('1.25') |