Skip to content

Commit abaf346

Browse files
committed
Make running integration tests with dind possible
1 parent 2dfab76 commit abaf346

File tree

5 files changed

+33
-5
lines changed

5 files changed

+33
-5
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ tests/__pycache__
1414

1515
# Compiled Documentation
1616
site/
17+
Makefile

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ integration-test: build
2323

2424
integration-test-py3: build-py3
2525
docker run -v `$(HOST_TMPDIR)`:/tmp -v /var/run/docker.sock:/var/run/docker.sock docker-py3 py.test -rxs tests/integration_test.py
26+
27+
integration-ci:
28+
docker build -t dpy-tests -f ./tests/Dockerfile .
29+
docker run --privileged -t dpy-tests

tests/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM dockerswarm/dind:1.8.1
2+
MAINTAINER Joffrey F <[email protected]>
3+
4+
RUN mkdir /home/docker-py
5+
WORKDIR /home/docker-py
6+
7+
RUN apt-get update && apt-get install -y python python-setuptools && easy_install pip
8+
9+
ADD requirements.txt /home/docker-py/requirements.txt
10+
RUN pip install -r requirements.txt
11+
12+
ADD test-requirements.txt /home/docker-py/test-requirements.txt
13+
RUN pip install -r test-requirements.txt
14+
15+
ADD . /home/docker-py
16+
RUN pip install -U .
17+
18+
CMD ["bash", "-c", "docker daemon 2>/dev/null & py.test -rxs tests/integration_test.py"]

tests/integration_test.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ def runTest(self):
190190

191191

192192
class TestCreateContainerWithBinds(BaseTestCase):
193-
@pytest.mark.skipif(True, reason="Doesn't work inside a container - FIXME")
194193
def runTest(self):
195194
mount_dest = '/mnt'
196195
mount_origin = tempfile.mkdtemp()
@@ -233,7 +232,6 @@ def runTest(self):
233232

234233

235234
class TestCreateContainerWithRoBinds(BaseTestCase):
236-
@pytest.mark.skipif(True, reason="Doesn't work inside a container - FIXME")
237235
def runTest(self):
238236
mount_dest = '/mnt'
239237
mount_origin = tempfile.mkdtemp()
@@ -1461,8 +1459,11 @@ def runTest(self):
14611459
self.client.wait(c)
14621460
logs = self.client.logs(c)
14631461

1462+
if six.PY3:
1463+
logs = logs.decode('utf-8')
1464+
14641465
self.assertEqual(
1465-
filter(None, logs.split('\n')),
1466+
list(filter(None, logs.split('\n'))),
14661467
['not-ignored'],
14671468
)
14681469

tests/utils_test.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,18 @@ def test_ulimit_invalid_type(self):
234234

235235
def test_create_host_config_dict_logconfig(self):
236236
dct = {'type': LogConfig.types.SYSLOG, 'config': {'key1': 'val1'}}
237-
config = create_host_config(log_config=dct)
237+
config = create_host_config(
238+
version=DEFAULT_DOCKER_API_VERSION, log_config=dct
239+
)
238240
self.assertIn('LogConfig', config)
239241
self.assertTrue(isinstance(config['LogConfig'], LogConfig))
240242
self.assertEqual(dct['type'], config['LogConfig'].type)
241243

242244
def test_create_host_config_obj_logconfig(self):
243245
obj = LogConfig(type=LogConfig.types.SYSLOG, config={'key1': 'val1'})
244-
config = create_host_config(log_config=obj)
246+
config = create_host_config(
247+
version=DEFAULT_DOCKER_API_VERSION, log_config=obj
248+
)
245249
self.assertIn('LogConfig', config)
246250
self.assertTrue(isinstance(config['LogConfig'], LogConfig))
247251
self.assertEqual(obj, config['LogConfig'])

0 commit comments

Comments
 (0)