From abaf346b49277004399bf7308de28e2ee012739c Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Tue, 8 Sep 2015 17:43:57 -0700 Subject: [PATCH] Make running integration tests with dind possible --- .dockerignore | 1 + Makefile | 4 ++++ tests/Dockerfile | 18 ++++++++++++++++++ tests/integration_test.py | 7 ++++--- tests/utils_test.py | 8 ++++++-- 5 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 tests/Dockerfile diff --git a/.dockerignore b/.dockerignore index c767879b..a1e09dfa 100644 --- a/.dockerignore +++ b/.dockerignore @@ -14,3 +14,4 @@ tests/__pycache__ # Compiled Documentation site/ +Makefile diff --git a/Makefile b/Makefile index 43d120af..2d853fd5 100644 --- a/Makefile +++ b/Makefile @@ -23,3 +23,7 @@ integration-test: build integration-test-py3: build-py3 docker run -v `$(HOST_TMPDIR)`:/tmp -v /var/run/docker.sock:/var/run/docker.sock docker-py3 py.test -rxs tests/integration_test.py + +integration-ci: + docker build -t dpy-tests -f ./tests/Dockerfile . + docker run --privileged -t dpy-tests diff --git a/tests/Dockerfile b/tests/Dockerfile new file mode 100644 index 00000000..576af4a6 --- /dev/null +++ b/tests/Dockerfile @@ -0,0 +1,18 @@ +FROM dockerswarm/dind:1.8.1 +MAINTAINER Joffrey F + +RUN mkdir /home/docker-py +WORKDIR /home/docker-py + +RUN apt-get update && apt-get install -y python python-setuptools && easy_install pip + +ADD requirements.txt /home/docker-py/requirements.txt +RUN pip install -r requirements.txt + +ADD test-requirements.txt /home/docker-py/test-requirements.txt +RUN pip install -r test-requirements.txt + +ADD . /home/docker-py +RUN pip install -U . + +CMD ["bash", "-c", "docker daemon 2>/dev/null & py.test -rxs tests/integration_test.py"] \ No newline at end of file diff --git a/tests/integration_test.py b/tests/integration_test.py index fd4ff2d0..e63504bb 100644 --- a/tests/integration_test.py +++ b/tests/integration_test.py @@ -190,7 +190,6 @@ class TestCreateContainer(BaseTestCase): class TestCreateContainerWithBinds(BaseTestCase): - @pytest.mark.skipif(True, reason="Doesn't work inside a container - FIXME") def runTest(self): mount_dest = '/mnt' mount_origin = tempfile.mkdtemp() @@ -233,7 +232,6 @@ class TestCreateContainerWithBinds(BaseTestCase): class TestCreateContainerWithRoBinds(BaseTestCase): - @pytest.mark.skipif(True, reason="Doesn't work inside a container - FIXME") def runTest(self): mount_dest = '/mnt' mount_origin = tempfile.mkdtemp() @@ -1461,8 +1459,11 @@ class TestBuildWithDockerignore(Cleanup, BaseTestCase): self.client.wait(c) logs = self.client.logs(c) + if six.PY3: + logs = logs.decode('utf-8') + self.assertEqual( - filter(None, logs.split('\n')), + list(filter(None, logs.split('\n'))), ['not-ignored'], ) diff --git a/tests/utils_test.py b/tests/utils_test.py index 7ce888b5..b67ac4ec 100644 --- a/tests/utils_test.py +++ b/tests/utils_test.py @@ -234,14 +234,18 @@ class UtilsTest(base.BaseTestCase): def test_create_host_config_dict_logconfig(self): dct = {'type': LogConfig.types.SYSLOG, 'config': {'key1': 'val1'}} - config = create_host_config(log_config=dct) + config = create_host_config( + version=DEFAULT_DOCKER_API_VERSION, log_config=dct + ) self.assertIn('LogConfig', config) self.assertTrue(isinstance(config['LogConfig'], LogConfig)) self.assertEqual(dct['type'], config['LogConfig'].type) def test_create_host_config_obj_logconfig(self): obj = LogConfig(type=LogConfig.types.SYSLOG, config={'key1': 'val1'}) - config = create_host_config(log_config=obj) + config = create_host_config( + version=DEFAULT_DOCKER_API_VERSION, log_config=obj + ) self.assertIn('LogConfig', config) self.assertTrue(isinstance(config['LogConfig'], LogConfig)) self.assertEqual(obj, config['LogConfig'])