mirror of https://github.com/docker/compose.git
Don't raise ConfigurationError for volume driver mismatch
when driver is unspecified Add testcase Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
698998c410
commit
d2b065e615
|
@ -107,7 +107,7 @@ class ProjectVolumes(object):
|
|||
volume.create()
|
||||
else:
|
||||
driver = volume.inspect()['Driver']
|
||||
if driver != volume.driver:
|
||||
if volume.driver is not None and driver != volume.driver:
|
||||
raise ConfigurationError(
|
||||
'Configuration for volume {0} specifies driver '
|
||||
'{1}, but a volume with the same name uses a '
|
||||
|
|
|
@ -839,6 +839,44 @@ class ProjectTest(DockerClientTestCase):
|
|||
vol_name
|
||||
) in str(e.exception)
|
||||
|
||||
@v2_only()
|
||||
def test_initialize_volumes_updated_blank_driver(self):
|
||||
vol_name = '{0:x}'.format(random.getrandbits(32))
|
||||
full_vol_name = 'composetest_{0}'.format(vol_name)
|
||||
|
||||
config_data = config.Config(
|
||||
version=V2_0,
|
||||
services=[{
|
||||
'name': 'web',
|
||||
'image': 'busybox:latest',
|
||||
'command': 'top'
|
||||
}],
|
||||
volumes={vol_name: {'driver': 'local'}},
|
||||
networks={},
|
||||
)
|
||||
project = Project.from_config(
|
||||
name='composetest',
|
||||
config_data=config_data, client=self.client
|
||||
)
|
||||
project.volumes.initialize()
|
||||
|
||||
volume_data = self.client.inspect_volume(full_vol_name)
|
||||
self.assertEqual(volume_data['Name'], full_vol_name)
|
||||
self.assertEqual(volume_data['Driver'], 'local')
|
||||
|
||||
config_data = config_data._replace(
|
||||
volumes={vol_name: {}}
|
||||
)
|
||||
project = Project.from_config(
|
||||
name='composetest',
|
||||
config_data=config_data,
|
||||
client=self.client
|
||||
)
|
||||
project.volumes.initialize()
|
||||
volume_data = self.client.inspect_volume(full_vol_name)
|
||||
self.assertEqual(volume_data['Name'], full_vol_name)
|
||||
self.assertEqual(volume_data['Driver'], 'local')
|
||||
|
||||
@v2_only()
|
||||
def test_initialize_volumes_external_volumes(self):
|
||||
# Use composetest_ prefix so it gets garbage-collected in tearDown()
|
||||
|
|
Loading…
Reference in New Issue