Move test from test_glusterfs and test_quobyte to test_remotefs
Move unit test for create_cloned_volume from test_glusterfs and test_quobyte to test_remotefs, because it checks only code, located in remotefs.py file. This patch is needed to simplify moving to versionedobjects. Change-Id: I661ef85755e9c75aaedb4f157165d2514de3e9ec
This commit is contained in:
parent
50a886ec3a
commit
ec51a682db
@ -583,38 +583,6 @@ class GlusterFsDriverTestCase(test.TestCase):
|
||||
self.assertTrue(mock_ensure_shares_mounted.called)
|
||||
self.assertTrue(mock_do_create_volume.called)
|
||||
|
||||
def test_create_cloned_volume(self):
|
||||
drv = self._driver
|
||||
|
||||
with mock.patch.object(drv, '_create_snapshot') as \
|
||||
mock_create_snapshot,\
|
||||
mock.patch.object(drv, '_delete_snapshot') as \
|
||||
mock_delete_snapshot,\
|
||||
mock.patch.object(drv, '_copy_volume_from_snapshot') as \
|
||||
mock_copy_volume_from_snapshot:
|
||||
volume = self._simple_volume()
|
||||
src_vref = self._simple_volume()
|
||||
src_vref['id'] = '375e32b2-804a-49f2-b282-85d1d5a5b9e1'
|
||||
src_vref['name'] = 'volume-%s' % src_vref['id']
|
||||
volume_ref = {'id': volume['id'],
|
||||
'name': volume['name'],
|
||||
'status': volume['status'],
|
||||
'provider_location': volume['provider_location'],
|
||||
'size': volume['size']}
|
||||
snap_ref = {'volume_name': src_vref['name'],
|
||||
'name': 'clone-snap-%s' % src_vref['id'],
|
||||
'size': src_vref['size'],
|
||||
'volume_size': src_vref['size'],
|
||||
'volume_id': src_vref['id'],
|
||||
'id': 'tmp-snap-%s' % src_vref['id'],
|
||||
'volume': src_vref}
|
||||
drv.create_cloned_volume(volume, src_vref)
|
||||
|
||||
mock_create_snapshot.assert_called_once_with(snap_ref)
|
||||
mock_copy_volume_from_snapshot.\
|
||||
assert_called_once_with(snap_ref, volume_ref, volume['size'])
|
||||
self.assertTrue(mock_delete_snapshot.called)
|
||||
|
||||
@mock.patch('oslo_utils.fileutils.delete_if_exists')
|
||||
def test_delete_volume(self, mock_delete_if_exists):
|
||||
volume = self._simple_volume()
|
||||
|
@ -530,39 +530,6 @@ class QuobyteDriverTestCase(test.TestCase):
|
||||
drv._ensure_shares_mounted.assert_called_once_with()
|
||||
drv._find_share.assert_called_once_with(self.TEST_SIZE_IN_GB)
|
||||
|
||||
def test_create_cloned_volume(self):
|
||||
drv = self._driver
|
||||
|
||||
drv._create_snapshot = mock.Mock()
|
||||
drv._copy_volume_from_snapshot = mock.Mock()
|
||||
drv._delete_snapshot = mock.Mock()
|
||||
|
||||
volume = self._simple_volume()
|
||||
src_vref = self._simple_volume()
|
||||
src_vref['id'] = '375e32b2-804a-49f2-b282-85d1d5a5b9e1'
|
||||
src_vref['name'] = 'volume-%s' % src_vref['id']
|
||||
volume_ref = {'id': volume['id'],
|
||||
'name': volume['name'],
|
||||
'status': volume['status'],
|
||||
'provider_location': volume['provider_location'],
|
||||
'size': volume['size']}
|
||||
|
||||
snap_ref = {'volume_name': src_vref['name'],
|
||||
'name': 'clone-snap-%s' % src_vref['id'],
|
||||
'size': src_vref['size'],
|
||||
'volume_size': src_vref['size'],
|
||||
'volume_id': src_vref['id'],
|
||||
'id': 'tmp-snap-%s' % src_vref['id'],
|
||||
'volume': src_vref}
|
||||
|
||||
drv.create_cloned_volume(volume, src_vref)
|
||||
|
||||
drv._create_snapshot.assert_called_once_with(snap_ref)
|
||||
drv._copy_volume_from_snapshot.assert_called_once_with(snap_ref,
|
||||
volume_ref,
|
||||
volume['size'])
|
||||
drv._delete_snapshot.assert_called_once_with(mock.ANY)
|
||||
|
||||
@mock.patch('oslo_utils.fileutils.delete_if_exists')
|
||||
def test_delete_volume(self, mock_delete_if_exists):
|
||||
volume = self._simple_volume()
|
||||
|
@ -421,3 +421,36 @@ class RemoteFsSnapDriverTestCase(test.TestCase):
|
||||
self._test_qemu_img_info(backing_file=backing_file,
|
||||
basedir=basedir,
|
||||
valid_backing_file=False)
|
||||
|
||||
def test_create_cloned_volume(self):
|
||||
drv = self._driver
|
||||
|
||||
with mock.patch.object(drv, '_create_snapshot') as \
|
||||
mock_create_snapshot,\
|
||||
mock.patch.object(drv, '_delete_snapshot') as \
|
||||
mock_delete_snapshot,\
|
||||
mock.patch.object(drv, '_copy_volume_from_snapshot') as \
|
||||
mock_copy_volume_from_snapshot:
|
||||
|
||||
volume = self._FAKE_VOLUME.copy()
|
||||
src_vref = self._FAKE_VOLUME.copy()
|
||||
src_vref['id'] = '375e32b2-804a-49f2-b282-85d1d5a5b9e1'
|
||||
src_vref['name'] = 'volume-%s' % src_vref['id']
|
||||
volume_ref = {'id': volume['id'],
|
||||
'name': volume['name'],
|
||||
'status': volume['status'],
|
||||
'provider_location': volume['provider_location'],
|
||||
'size': volume['size']}
|
||||
snap_ref = {'volume_name': volume['name'],
|
||||
'name': 'clone-snap-%s' % src_vref['id'],
|
||||
'size': src_vref['size'],
|
||||
'volume_size': src_vref['size'],
|
||||
'volume_id': src_vref['id'],
|
||||
'id': 'tmp-snap-%s' % src_vref['id'],
|
||||
'volume': src_vref}
|
||||
drv.create_cloned_volume(volume, src_vref)
|
||||
|
||||
mock_create_snapshot.assert_called_once_with(snap_ref)
|
||||
mock_copy_volume_from_snapshot.assert_called_once_with(
|
||||
snap_ref, volume_ref, volume['size'])
|
||||
self.assertTrue(mock_delete_snapshot.called)
|
||||
|
Loading…
Reference in New Issue
Block a user