From 05544ce2417336f11e61ffc734fb6014dc76a58d Mon Sep 17 00:00:00 2001 From: Aanand Prasad Date: Fri, 12 Dec 2014 17:53:02 -0800 Subject: [PATCH] Stronger integration tests for volume binds Signed-off-by: Aanand Prasad --- tests/integration/service_test.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/integration/service_test.py b/tests/integration/service_test.py index 3eae62ae6..864b30a9f 100644 --- a/tests/integration/service_test.py +++ b/tests/integration/service_test.py @@ -1,6 +1,7 @@ from __future__ import unicode_literals from __future__ import absolute_import import os +from os import path from fig import Service from fig.service import CannotBeScaledError @@ -95,10 +96,20 @@ class ServiceTest(DockerClientTestCase): self.assertIn('/var/db', container.inspect()['Volumes']) def test_create_container_with_specified_volume(self): - service = self.create_service('db', volumes=['/tmp:/host-tmp']) + host_path = '/tmp/host-path' + container_path = '/container-path' + + service = self.create_service('db', volumes=['%s:%s' % (host_path, container_path)]) container = service.create_container() service.start_container(container) - self.assertIn('/host-tmp', container.inspect()['Volumes']) + + volumes = container.inspect()['Volumes'] + self.assertIn(container_path, volumes) + + # Match the last component ("host-path"), because boot2docker symlinks /tmp + actual_host_path = volumes[container_path] + self.assertTrue(path.basename(actual_host_path) == path.basename(host_path), + msg=("Last component differs: %s, %s" % (actual_host_path, host_path))) def test_create_container_with_volumes_from(self): volume_service = self.create_service('data')