Implement ability to specify external volumes
External volumes are created and managed by the user. They are not namespaced. They are expected to exist at the beginning of the up phase. Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
05935b5e54
commit
9cb58b796e
6 changed files with 93 additions and 21 deletions
|
|
@ -18,9 +18,10 @@ class VolumeTest(DockerClientTestCase):
|
|||
except DockerException:
|
||||
pass
|
||||
|
||||
def create_volume(self, name, driver=None, opts=None):
|
||||
def create_volume(self, name, driver=None, opts=None, external=False):
|
||||
vol = Volume(
|
||||
self.client, 'composetest', name, driver=driver, driver_opts=opts
|
||||
self.client, 'composetest', name, driver=driver, driver_opts=opts,
|
||||
external=external
|
||||
)
|
||||
self.tmp_volumes.append(vol)
|
||||
return vol
|
||||
|
|
@ -55,12 +56,19 @@ class VolumeTest(DockerClientTestCase):
|
|||
volumes = self.client.volumes()['Volumes']
|
||||
assert len([v for v in volumes if v['Name'] == vol.full_name]) == 0
|
||||
|
||||
def test_is_user_created(self):
|
||||
vol = Volume(self.client, 'composetest', 'uservolume01')
|
||||
try:
|
||||
self.client.create_volume('uservolume01')
|
||||
assert vol.is_user_created is True
|
||||
finally:
|
||||
self.client.remove_volume('uservolume01')
|
||||
vol2 = Volume(self.client, 'composetest', 'volume01')
|
||||
assert vol2.is_user_created is False
|
||||
def test_external_volume(self):
|
||||
vol = self.create_volume('volume01', external=True)
|
||||
assert vol.external is True
|
||||
assert vol.full_name == vol.name
|
||||
vol.create()
|
||||
info = vol.inspect()
|
||||
assert info['Name'] == vol.name
|
||||
|
||||
def test_external_aliased_volume(self):
|
||||
alias_name = 'alias01'
|
||||
vol = self.create_volume('volume01', external={'name': alias_name})
|
||||
assert vol.external is True
|
||||
assert vol.full_name == alias_name
|
||||
vol.create()
|
||||
info = vol.inspect()
|
||||
assert info['Name'] == alias_name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue