Add support for declaring named volumes in compose files
* Bump default API version to 1.21 (required for named volume management) * Introduce new, versioned compose file format while maintaining support for current (legacy) format * Test updates to reflect changes made to the internal API Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
4bf2f8c4f9
commit
b4be7b870f
14 changed files with 262 additions and 81 deletions
|
|
@ -69,9 +69,9 @@ class ProjectTest(DockerClientTestCase):
|
|||
'volumes_from': ['data'],
|
||||
},
|
||||
})
|
||||
project = Project.from_dicts(
|
||||
project = Project.from_config(
|
||||
name='composetest',
|
||||
service_dicts=service_dicts,
|
||||
config_data=service_dicts,
|
||||
client=self.client,
|
||||
)
|
||||
db = project.get_service('db')
|
||||
|
|
@ -86,9 +86,9 @@ class ProjectTest(DockerClientTestCase):
|
|||
name='composetest_data_container',
|
||||
labels={LABEL_PROJECT: 'composetest'},
|
||||
)
|
||||
project = Project.from_dicts(
|
||||
project = Project.from_config(
|
||||
name='composetest',
|
||||
service_dicts=build_service_dicts({
|
||||
config_data=build_service_dicts({
|
||||
'db': {
|
||||
'image': 'busybox:latest',
|
||||
'volumes_from': ['composetest_data_container'],
|
||||
|
|
@ -117,9 +117,9 @@ class ProjectTest(DockerClientTestCase):
|
|||
assert project.get_network()['Name'] == network_name
|
||||
|
||||
def test_net_from_service(self):
|
||||
project = Project.from_dicts(
|
||||
project = Project.from_config(
|
||||
name='composetest',
|
||||
service_dicts=build_service_dicts({
|
||||
config_data=build_service_dicts({
|
||||
'net': {
|
||||
'image': 'busybox:latest',
|
||||
'command': ["top"]
|
||||
|
|
@ -149,9 +149,9 @@ class ProjectTest(DockerClientTestCase):
|
|||
)
|
||||
net_container.start()
|
||||
|
||||
project = Project.from_dicts(
|
||||
project = Project.from_config(
|
||||
name='composetest',
|
||||
service_dicts=build_service_dicts({
|
||||
config_data=build_service_dicts({
|
||||
'web': {
|
||||
'image': 'busybox:latest',
|
||||
'net': 'container:composetest_net_container'
|
||||
|
|
@ -331,7 +331,6 @@ class ProjectTest(DockerClientTestCase):
|
|||
project.up(['db'])
|
||||
self.assertEqual(len(project.containers()), 1)
|
||||
old_db_id = project.containers()[0].id
|
||||
|
||||
container, = project.containers()
|
||||
db_volume_path = container.get_mount('/var/db')['Source']
|
||||
|
||||
|
|
@ -401,9 +400,9 @@ class ProjectTest(DockerClientTestCase):
|
|||
self.assertEqual(len(console.containers()), 0)
|
||||
|
||||
def test_project_up_starts_depends(self):
|
||||
project = Project.from_dicts(
|
||||
project = Project.from_config(
|
||||
name='composetest',
|
||||
service_dicts=build_service_dicts({
|
||||
config_data=build_service_dicts({
|
||||
'console': {
|
||||
'image': 'busybox:latest',
|
||||
'command': ["top"],
|
||||
|
|
@ -436,9 +435,9 @@ class ProjectTest(DockerClientTestCase):
|
|||
self.assertEqual(len(project.get_service('console').containers()), 0)
|
||||
|
||||
def test_project_up_with_no_deps(self):
|
||||
project = Project.from_dicts(
|
||||
project = Project.from_config(
|
||||
name='composetest',
|
||||
service_dicts=build_service_dicts({
|
||||
config_data=build_service_dicts({
|
||||
'console': {
|
||||
'image': 'busybox:latest',
|
||||
'command': ["top"],
|
||||
|
|
|
|||
|
|
@ -163,6 +163,7 @@ class ServiceTest(DockerClientTestCase):
|
|||
|
||||
# Match the last component ("host-path"), because boot2docker symlinks /tmp
|
||||
actual_host_path = container.get_mount(container_path)['Source']
|
||||
|
||||
self.assertTrue(path.basename(actual_host_path) == path.basename(host_path),
|
||||
msg=("Last component differs: %s, %s" % (actual_host_path, host_path)))
|
||||
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ class ProjectTestCase(DockerClientTestCase):
|
|||
details = config.ConfigDetails(
|
||||
'working_dir',
|
||||
[config.ConfigFile(None, cfg)])
|
||||
return Project.from_dicts(
|
||||
return Project.from_config(
|
||||
name='composetest',
|
||||
client=self.client,
|
||||
service_dicts=config.load(details))
|
||||
config_data=config.load(details))
|
||||
|
||||
|
||||
class BasicProjectTest(ProjectTestCase):
|
||||
|
|
|
|||
|
|
@ -39,6 +39,10 @@ class DockerClientTestCase(unittest.TestCase):
|
|||
for i in self.client.images(
|
||||
filters={'label': 'com.docker.compose.test_image'}):
|
||||
self.client.remove_image(i)
|
||||
volumes = self.client.volumes().get('Volumes') or []
|
||||
for v in volumes:
|
||||
if 'composetests_' in v['Name']:
|
||||
self.client.remove_volume(v['Name'])
|
||||
|
||||
def create_service(self, name, **kwargs):
|
||||
if 'image' not in kwargs and 'build' not in kwargs:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue