From 1fb2db49515b580367a5e4c2e62d369787190774 Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Wed, 9 Sep 2015 16:22:23 -0700 Subject: [PATCH 1/2] Make integration tests more CI-friendly. Signed-off-by: Joffrey F --- Makefile | 1 - tests/integration_test.py | 26 ++++++++++---------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 0bda527a31..54f7c87ea4 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,6 @@ 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-dind: build build-py3 - docker build -t dpy-tests -f ./tests/Dockerfile . docker run -d --name dpy-dind -v /tmp --privileged dockerswarm/dind:1.8.1 docker -d -H tcp://0.0.0.0:2375 docker run --volumes-from dpy-dind --env="DOCKER_HOST=tcp://docker:2375" --link=dpy-dind:docker docker-py py.test -rxs tests/integration_test.py docker run --volumes-from dpy-dind --env="DOCKER_HOST=tcp://docker:2375" --link=dpy-dind:docker docker-py3 py.test -rxs tests/integration_test.py diff --git a/tests/integration_test.py b/tests/integration_test.py index e63504bbd8..3581b04593 100644 --- a/tests/integration_test.py +++ b/tests/integration_test.py @@ -82,7 +82,7 @@ def setUp(self): if six.PY2: self.assertRegex = self.assertRegexpMatches self.assertCountEqual = self.assertItemsEqual - self.client = docker_client(timeout=5) + self.client = docker_client(timeout=60) self.tmp_imgs = [] self.tmp_containers = [] self.tmp_folders = [] @@ -1115,38 +1115,34 @@ def runTest(self): class TestPull(BaseTestCase): def runTest(self): - self.client.close() - self.client = docker_client(timeout=10) try: - self.client.remove_image('busybox') + self.client.remove_image('hello-world') except docker.errors.APIError: pass - res = self.client.pull('busybox') + res = self.client.pull('hello-world') self.assertEqual(type(res), six.text_type) self.assertGreaterEqual( - len(self.client.images('busybox')), 1 + len(self.client.images('hello-world')), 1 ) - img_info = self.client.inspect_image('busybox') + img_info = self.client.inspect_image('hello-world') self.assertIn('Id', img_info) class TestPullStream(BaseTestCase): def runTest(self): - self.client.close() - self.client = docker_client(timeout=10) try: - self.client.remove_image('busybox') + self.client.remove_image('hello-world') except docker.errors.APIError: pass - stream = self.client.pull('busybox', stream=True) + stream = self.client.pull('hello-world', stream=True) for chunk in stream: if six.PY3: chunk = chunk.decode('utf-8') json.loads(chunk) # ensure chunk is a single, valid JSON blob self.assertGreaterEqual( - len(self.client.images('busybox')), 1 + len(self.client.images('hello-world')), 1 ) - img_info = self.client.inspect_image('busybox') + img_info = self.client.inspect_image('hello-world') self.assertIn('Id', img_info) @@ -1195,9 +1191,7 @@ def runTest(self): class ImportTestCase(BaseTestCase): '''Base class for `docker import` test cases.''' - # Use a large file size to increase the chance of triggering any - # MemoryError exceptions we might hit. - TAR_SIZE = 512 * 1024 * 1024 + TAR_SIZE = 512 * 1024 def write_dummy_tar_content(self, n_bytes, tar_fd): def extend_file(f, n_bytes): From b1c2475698c94345219b4d5e830c9136be7cabbc Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Wed, 9 Sep 2015 17:09:29 -0700 Subject: [PATCH 2/2] Add hello-world to temp images in pull tests Signed-off-by: Joffrey F --- tests/integration_test.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration_test.py b/tests/integration_test.py index 3581b04593..0cf1250189 100644 --- a/tests/integration_test.py +++ b/tests/integration_test.py @@ -1120,6 +1120,7 @@ def runTest(self): except docker.errors.APIError: pass res = self.client.pull('hello-world') + self.tmp_imgs.append('hello-world') self.assertEqual(type(res), six.text_type) self.assertGreaterEqual( len(self.client.images('hello-world')), 1 @@ -1135,6 +1136,7 @@ def runTest(self): except docker.errors.APIError: pass stream = self.client.pull('hello-world', stream=True) + self.tmp_imgs.append('hello-world') for chunk in stream: if six.PY3: chunk = chunk.decode('utf-8')