Make running integration tests with dind possible

This commit is contained in:
Joffrey F 2015-09-08 17:43:57 -07:00
parent 2dfab76224
commit abaf346b49
5 changed files with 33 additions and 5 deletions

View File

@ -14,3 +14,4 @@ tests/__pycache__
# Compiled Documentation
site/
Makefile

View File

@ -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

18
tests/Dockerfile Normal file
View File

@ -0,0 +1,18 @@
FROM dockerswarm/dind:1.8.1
MAINTAINER Joffrey F <joffrey@docker.com>
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"]

View File

@ -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'],
)

View File

@ -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'])