Match named volumes in service definitions with declared volumes
Raise ConfigurationError for undeclared named volumes Test new behavior Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
883227c4d8
commit
a66bf72199
4 changed files with 118 additions and 12 deletions
|
|
@ -813,3 +813,39 @@ class ProjectTest(DockerClientTestCase):
|
|||
assert 'Volume {0} declared as external'.format(
|
||||
vol_name
|
||||
) in str(e.exception)
|
||||
|
||||
@v2_only()
|
||||
def test_project_up_named_volumes_in_binds(self):
|
||||
vol_name = '{0:x}'.format(random.getrandbits(32))
|
||||
full_vol_name = 'composetest_{0}'.format(vol_name)
|
||||
|
||||
base_file = config.ConfigFile(
|
||||
'base.yml',
|
||||
{
|
||||
'version': 2,
|
||||
'services': {
|
||||
'simple': {
|
||||
'image': 'busybox:latest',
|
||||
'command': 'top',
|
||||
'volumes': ['{0}:/data'.format(vol_name)]
|
||||
},
|
||||
},
|
||||
'volumes': {
|
||||
vol_name: {'driver': 'local'}
|
||||
}
|
||||
|
||||
})
|
||||
config_details = config.ConfigDetails('.', [base_file])
|
||||
config_data = config.load(config_details)
|
||||
project = Project.from_config(
|
||||
name='composetest', config_data=config_data, client=self.client
|
||||
)
|
||||
service = project.services[0]
|
||||
self.assertEqual(service.name, 'simple')
|
||||
volumes = service.options.get('volumes')
|
||||
self.assertEqual(len(volumes), 1)
|
||||
self.assertEqual(volumes[0].external, full_vol_name)
|
||||
project.up()
|
||||
engine_volumes = self.client.volumes()
|
||||
self.assertIsNone(next(v for v in engine_volumes if v['Name'] == vol_name))
|
||||
self.assertIsNotNone(next(v for v in engine_volumes if v['Name'] == full_vol_name))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue