def test_refresh(self, snapshot_get): db_snapshot1 = fake_snapshot.fake_db_snapshot() db_snapshot2 = db_snapshot1.copy() db_snapshot2['display_name'] = 'foobar' # On the second snapshot_get, return the snapshot with an updated # display_name snapshot_get.side_effect = [db_snapshot1, db_snapshot2] snapshot = objects.Snapshot.get_by_id(self.context, fake.SNAPSHOT_ID) self._compare(self, db_snapshot1, snapshot) # display_name was updated, so a snapshot refresh should have a new # value for that field snapshot.refresh() self._compare(self, db_snapshot2, snapshot) if six.PY3: call_bool = mock.call.__bool__() else: call_bool = mock.call.__nonzero__() snapshot_get.assert_has_calls([ mock.call(self.context, fake.SNAPSHOT_ID), call_bool, mock.call(self.context, fake.SNAPSHOT_ID)])
def test_refresh(self, snapshot_get): db_snapshot1 = fake_snapshot.fake_db_snapshot() db_snapshot2 = db_snapshot1.copy() db_snapshot2['display_name'] = 'foobar' # On the second snapshot_get, return the snapshot with an updated # display_name snapshot_get.side_effect = [db_snapshot1, db_snapshot2] snapshot = objects.Snapshot.get_by_id(self.context, fake.SNAPSHOT_ID) self._compare(self, db_snapshot1, snapshot) # display_name was updated, so a snapshot refresh should have a new # value for that field snapshot.refresh() self._compare(self, db_snapshot2, snapshot) if six.PY3: call_bool = mock.call.__bool__() else: call_bool = mock.call.__nonzero__() snapshot_get.assert_has_calls([ mock.call(self.context, fake.SNAPSHOT_ID), call_bool, mock.call(self.context, fake.SNAPSHOT_ID)])
def test_obj_load_attr_group_not_exist(self, group_snapshot_get_by_id): fake_non_cg_db_snapshot = fake_snapshot.fake_db_snapshot( group_snapshot_id=None) snapshot = objects.Snapshot._from_db_object( self.context, objects.Snapshot(), fake_non_cg_db_snapshot) self.assertIsNone(snapshot.group_snapshot) group_snapshot_get_by_id.assert_not_called()
def test_refresh(self, snapshot_get, snapshot_metadata_get): db_snapshot = fake_snapshot.fake_db_snapshot() snapshot_get.return_value = db_snapshot snapshot = objects.Snapshot.get_by_id(self.context, '1') snapshot.refresh() snapshot_get.assert_has_calls([mock.call(self.context, '1'), mock.call(self.context, '1')])
def test_from_db_object_with_all_expected_attributes(self): expected_attrs = ['metadata', 'admin_metadata', 'glance_metadata', 'volume_type', 'volume_attachment', 'consistencygroup'] db_metadata = [{'key': 'foo', 'value': 'bar'}] db_admin_metadata = [{'key': 'admin_foo', 'value': 'admin_bar'}] db_glance_metadata = [{'key': 'glance_foo', 'value': 'glance_bar'}] db_volume_type = fake_volume.fake_db_volume_type() db_volume_attachments = fake_volume.fake_db_volume_attachment() db_consistencygroup = fake_consistencygroup.fake_db_consistencygroup() db_snapshots = fake_snapshot.fake_db_snapshot() db_volume = fake_volume.fake_db_volume( volume_metadata=db_metadata, volume_admin_metadata=db_admin_metadata, volume_glance_metadata=db_glance_metadata, volume_type=db_volume_type, volume_attachment=[db_volume_attachments], consistencygroup=db_consistencygroup, snapshots=[db_snapshots], ) volume = objects.Volume._from_db_object(self.context, objects.Volume(), db_volume, expected_attrs) self.assertEqual({'foo': 'bar'}, volume.metadata) self.assertEqual({'admin_foo': 'admin_bar'}, volume.admin_metadata) self.assertEqual({'glance_foo': 'glance_bar'}, volume.glance_metadata) self._compare(self, db_volume_type, volume.volume_type) self._compare(self, db_volume_attachments, volume.volume_attachment) self._compare(self, db_consistencygroup, volume.consistencygroup) self._compare(self, db_snapshots, volume.snapshots)
def test_obj_load_attr_group_not_exist(self, group_snapshot_get_by_id): fake_non_cg_db_snapshot = fake_snapshot.fake_db_snapshot( group_snapshot_id=None) snapshot = objects.Snapshot._from_db_object( self.context, objects.Snapshot(), fake_non_cg_db_snapshot) self.assertIsNone(snapshot.group_snapshot) group_snapshot_get_by_id.assert_not_called()
def test_from_db_object_with_all_expected_attributes(self): expected_attrs = [ 'metadata', 'admin_metadata', 'glance_metadata', 'volume_type', 'volume_attachment', 'consistencygroup' ] db_metadata = [{'key': 'foo', 'value': 'bar'}] db_admin_metadata = [{'key': 'admin_foo', 'value': 'admin_bar'}] db_glance_metadata = [{'key': 'glance_foo', 'value': 'glance_bar'}] db_volume_type = fake_volume.fake_db_volume_type() db_volume_attachments = fake_volume.fake_db_volume_attachment() db_consistencygroup = fake_consistencygroup.fake_db_consistencygroup() db_snapshots = fake_snapshot.fake_db_snapshot() db_volume = fake_volume.fake_db_volume( volume_metadata=db_metadata, volume_admin_metadata=db_admin_metadata, volume_glance_metadata=db_glance_metadata, volume_type=db_volume_type, volume_attachment=[db_volume_attachments], consistencygroup=db_consistencygroup, snapshots=[db_snapshots], ) volume = objects.Volume._from_db_object(self.context, objects.Volume(), db_volume, expected_attrs) self.assertEqual({'foo': 'bar'}, volume.metadata) self.assertEqual({'admin_foo': 'admin_bar'}, volume.admin_metadata) self.assertEqual({'glance_foo': 'glance_bar'}, volume.glance_metadata) self._compare(self, db_volume_type, volume.volume_type) self._compare(self, db_volume_attachments, volume.volume_attachment) self._compare(self, db_consistencygroup, volume.consistencygroup) self._compare(self, db_snapshots, volume.snapshots)
def test_create_volume_from_snapshot_error_on_non_existing_snapshot(self): """Test create_volume_from_snapshot is error on non existing snapshot. """ volume2 = fake_volume.fake_db_volume(**self._VOLUME2) snapshot = fake_snapshot.fake_db_snapshot(**self._TEST_SNAPSHOT) snapshot['provider_location'] = '1' self.assertRaises(exception.VolumeBackendAPIException, self.driver.create_volume_from_snapshot, volume2, snapshot)
def test_create_volume_from_snapshot_error_on_non_existing_snapshot(self): """Test create_volume_from_snapshot is error on non existing snapshot. """ volume2 = fake_volume.fake_db_volume(**self._VOLUME2) snapshot = fake_snapshot.fake_db_snapshot(**self._TEST_SNAPSHOT) snapshot['provider_location'] = '1' self.assertRaises(exception.VolumeBackendAPIException, self.driver.create_volume_from_snapshot, volume2, snapshot)
def test_delete_snapshot_isbusy_flag(self): """Test snapshot deletion throws exception if snapshot is busy.""" # get a mock snapshot object snapshot = fake_snapshot.fake_db_snapshot() # set the force in metadata of snapshot snapshot['metadata'] = {"is_busy": "is_busy"} # call the delete volume to check if it raises Busy Exception self.assertRaises(exception.SnapshotIsBusy, self.driver.delete_snapshot, snapshot)
def test_delete_snapshot_isbusy_flag(self): """Test snapshot deletion throws exception if snapshot is busy.""" # get a mock snapshot object snapshot = fake_snapshot.fake_db_snapshot() # set the force in metadata of snapshot snapshot['metadata'] = {"is_busy": "is_busy"} # call the delete volume to check if it raises Busy Exception self.assertRaises(exception.SnapshotIsBusy, self.driver.delete_snapshot, snapshot)
def test_create_snapshot(self): """Test create_snapshot.""" volume = fake_volume.fake_db_volume(**self._VOLUME) self.driver.create_volume(volume) snapshot = fake_snapshot.fake_db_snapshot(**self._TEST_SNAPSHOT) rc = self.driver.create_snapshot(snapshot) snapshot['provider_location'] = rc['provider_location'] has_volume = self.driver.common.volume_exists(snapshot) self.assertTrue(has_volume)
def test_create_snapshot(self): """Test create_snapshot.""" volume = fake_volume.fake_db_volume(**self._VOLUME) self.driver.create_volume(volume) snapshot = fake_snapshot.fake_db_snapshot(**self._TEST_SNAPSHOT) rc = self.driver.create_snapshot(snapshot) snapshot['provider_location'] = rc['provider_location'] has_volume = self.driver.common.volume_exists(snapshot) self.assertTrue(has_volume)
def test_delete_snapshot_error_on_busy_snapshot(self): """Test delete_snapshot is error on busy snapshot.""" volume = fake_volume.fake_db_volume(**self._VOLUME) self.driver.create_volume(volume) snapshot = fake_snapshot.fake_db_snapshot(**self._TEST_SNAPSHOT) rc = self.driver.create_snapshot(snapshot) self.driver.common.volumes[rc['provider_location']]['is_busy'] = True snapshot['provider_location'] = rc['provider_location'] self.assertRaises(exception.SnapshotIsBusy, self.driver.delete_snapshot, snapshot)
def test_delete_snapshot_error_on_busy_snapshot(self): """Test delete_snapshot is error on busy snapshot.""" volume = fake_volume.fake_db_volume(**self._VOLUME) self.driver.create_volume(volume) snapshot = fake_snapshot.fake_db_snapshot(**self._TEST_SNAPSHOT) rc = self.driver.create_snapshot(snapshot) self.driver.common.volumes[rc['provider_location']]['is_busy'] = True snapshot['provider_location'] = rc['provider_location'] self.assertRaises(exception.SnapshotIsBusy, self.driver.delete_snapshot, snapshot)
def test_create_volume_from_snapshot_error_on_diff_size(self): """Test create_volume_from_snapshot is error on different size.""" volume = fake_volume.fake_db_volume(**self._VOLUME) self.driver.create_volume(volume) snapshot = fake_snapshot.fake_db_snapshot(**self._TEST_SNAPSHOT) rc_snap = self.driver.create_snapshot(snapshot) snapshot['provider_location'] = rc_snap['provider_location'] volume3 = fake_volume.fake_db_volume(**self._VOLUME3) self.assertRaises(exception.VolumeBackendAPIException, self.driver.create_volume_from_snapshot, volume3, snapshot)
def db_snapshot_get_all_for_volume(context, volume_id): """Replacement for cinder.db.snapshot_get_all_for_volume. We stub the cinder.db.snapshot_get_all_for_volume method because when we go to unmanage a volume, the code checks for snapshots and won't unmanage volumes with snapshots. For these tests, only the snapshot_vol_id reports any snapshots. The delete code just checks for array length, doesn't inspect the contents. """ if volume_id == snapshot_vol_id: db_snapshot = {'volume_id': volume_id} snapshot = fake_snapshot.fake_db_snapshot(**db_snapshot) return [snapshot] return []
def test_delete_snapshot_force_flag(self, mock_ggwcb): """Test snapshot deletion does not happen if force flag is set.""" # get a mock snapshot object snapshot = fake_snapshot.fake_db_snapshot() # set the force in metadata of snapshot snapshot['metadata'] = {"force": "force"} # call the delete volume self.driver.delete_snapshot(snapshot) # if snapshot has force set in metadata then # get_guid_with_curly_brackets() will not be called because we # return as soon as we see force mock_ggwcb.assert_not_called()
def test_delete_snapshot_force_flag(self, mock_ggwcb): """Test snapshot deletion does not happen if force flag is set.""" # get a mock snapshot object snapshot = fake_snapshot.fake_db_snapshot() # set the force in metadata of snapshot snapshot['metadata'] = {"force": "force"} # call the delete volume self.driver.delete_snapshot(snapshot) # if snapshot has force set in metadata then # get_guid_with_curly_brackets() will not be called because we # return as soon as we see force mock_ggwcb.assert_not_called()
def db_snapshot_get_all_for_volume(context, volume_id): """Replacement for cinder.db.snapshot_get_all_for_volume. We stub the cinder.db.snapshot_get_all_for_volume method because when we go to unmanage a volume, the code checks for snapshots and won't unmanage volumes with snapshots. For these tests, only the snapshot_vol_id reports any snapshots. The delete code just checks for array length, doesn't inspect the contents. """ if volume_id == snapshot_vol_id: db_snapshot = {'volume_id': volume_id} snapshot = fake_snapshot.fake_db_snapshot(**db_snapshot) return [snapshot] return []
def test_create_volume_from_snapshot_error_on_diff_size(self): """Test create_volume_from_snapshot is error on different size.""" volume = fake_volume.fake_db_volume(**self._VOLUME) self.driver.create_volume(volume) snapshot = fake_snapshot.fake_db_snapshot(**self._TEST_SNAPSHOT) rc_snap = self.driver.create_snapshot(snapshot) snapshot['provider_location'] = rc_snap['provider_location'] volume3 = fake_volume.fake_db_volume(**self._VOLUME3) self.assertRaises(exception.VolumeBackendAPIException, self.driver.create_volume_from_snapshot, volume3, snapshot)
def test_from_db_object_with_all_expected_attributes(self): expected_attrs = [ "metadata", "admin_metadata", "glance_metadata", "volume_type", "volume_attachment", "consistencygroup", ] db_metadata = [{"key": "foo", "value": "bar"}] db_admin_metadata = [{"key": "admin_foo", "value": "admin_bar"}] db_glance_metadata = [{"key": "glance_foo", "value": "glance_bar"}] db_volume_type = fake_volume.fake_db_volume_type() db_volume_attachments = fake_volume.fake_db_volume_attachment() db_consistencygroup = fake_consistencygroup.fake_db_consistencygroup() db_snapshots = fake_snapshot.fake_db_snapshot() db_volume = fake_volume.fake_db_volume( volume_metadata=db_metadata, volume_admin_metadata=db_admin_metadata, volume_glance_metadata=db_glance_metadata, volume_type=db_volume_type, volume_attachment=[db_volume_attachments], consistencygroup=db_consistencygroup, snapshots=[db_snapshots], ) volume = objects.Volume._from_db_object(self.context, objects.Volume(), db_volume, expected_attrs) self.assertEqual({"foo": "bar"}, volume.metadata) self.assertEqual({"admin_foo": "admin_bar"}, volume.admin_metadata) self.assertEqual({"glance_foo": "glance_bar"}, volume.glance_metadata) self._compare(self, db_volume_type, volume.volume_type) self._compare(self, db_volume_attachments, volume.volume_attachment) self._compare(self, db_consistencygroup, volume.consistencygroup) self._compare(self, db_snapshots, volume.snapshots)
'temp_volume_id': None, 'temp_snapshot_id': None, 'snapshot_id': None, 'data_timestamp': None, 'restore_volume_id': None, 'backup_metadata': {}, } vol_props = {'status': 'available', 'size': 1} fake_vol = fake_volume.fake_db_volume(**vol_props) snap_props = { 'status': fields.BackupStatus.AVAILABLE, 'volume_id': fake_vol['id'], 'expected_attrs': ['metadata'] } fake_snap = fake_snapshot.fake_db_snapshot(**snap_props) class TestBackup(test_objects.BaseObjectsTestCase): @mock.patch('cinder.db.get_by_id', return_value=fake_backup) def test_get_by_id(self, backup_get): backup = objects.Backup.get_by_id(self.context, fake.USER_ID) self._compare(self, fake_backup, backup) backup_get.assert_called_once_with(self.context, models.Backup, fake.USER_ID) @mock.patch('cinder.db.sqlalchemy.api.model_query') def test_get_by_id_no_existing_id(self, model_query): query = mock.Mock() filter_by = mock.Mock() query_options = mock.Mock()
def _stub_snapshot(*args, **kwargs): updates = {'volume': _stub_volume(), 'name': 'vrts'} return fake_snapshot.fake_db_snapshot(**updates)
import mock from oslo_utils import timeutils import pytz import six from cinder.db.sqlalchemy import models from cinder import exception from cinder import objects from cinder.objects import fields from cinder.tests.unit import fake_constants as fake from cinder.tests.unit import fake_snapshot from cinder.tests.unit import fake_volume from cinder.tests.unit import objects as test_objects fake_db_snapshot = fake_snapshot.fake_db_snapshot( cgsnapshot_id=fake.CGSNAPSHOT_ID) del fake_db_snapshot['metadata'] del fake_db_snapshot['volume'] # NOTE(andrey-mp): make Snapshot object here to check object algorithms fake_snapshot_obj = { 'id': fake.SNAPSHOT_ID, 'volume_id': fake.VOLUME_ID, 'status': fields.SnapshotStatus.CREATING, 'progress': '0%', 'volume_size': 1, 'display_name': 'fake_name', 'display_description': 'fake_description', 'metadata': {}, }
def test_delete_snapshot_on_non_existing_snapshot(self): """Test delete_snapshot on non existing snapshot.""" snapshot = fake_snapshot.fake_db_snapshot(**self._TEST_SNAPSHOT) snapshot['provider_location'] = '1' self.driver.delete_snapshot(snapshot)
def test_create_snapshot_error_on_non_src_ref(self): """Test create_snapshot is error on non source reference.""" snapshot = fake_snapshot.fake_db_snapshot(**self._TEST_SNAPSHOT) self.assertRaises(exception.VolumeBackendAPIException, self.driver.create_snapshot, snapshot)
'user_id': fake.USER_ID, 'project_id': fake.PROJECT_ID, 'temp_volume_id': None, 'temp_snapshot_id': None, 'snapshot_id': None, 'data_timestamp': None, 'restore_volume_id': None, 'backup_metadata': {}, } vol_props = {'status': 'available', 'size': 1} fake_vol = fake_volume.fake_db_volume(**vol_props) snap_props = {'status': fields.BackupStatus.AVAILABLE, 'volume_id': fake_vol['id'], 'expected_attrs': ['metadata']} fake_snap = fake_snapshot.fake_db_snapshot(**snap_props) class TestBackup(test_objects.BaseObjectsTestCase): @mock.patch('cinder.db.get_by_id', return_value=fake_backup) def test_get_by_id(self, backup_get): backup = objects.Backup.get_by_id(self.context, fake.USER_ID) self._compare(self, fake_backup, backup) backup_get.assert_called_once_with(self.context, models.Backup, fake.USER_ID) @mock.patch('cinder.db.sqlalchemy.api.model_query') def test_get_by_id_no_existing_id(self, model_query): query = mock.Mock() filter_by = mock.Mock()
import mock from oslo_utils import timeutils import pytz import six from cinder.db.sqlalchemy import models from cinder import exception from cinder import objects from cinder.objects import fields from cinder.tests.unit import fake_constants as fake from cinder.tests.unit import fake_snapshot from cinder.tests.unit import fake_volume from cinder.tests.unit import objects as test_objects fake_db_snapshot = fake_snapshot.fake_db_snapshot( cgsnapshot_id=fake.CGSNAPSHOT_ID) del fake_db_snapshot['metadata'] del fake_db_snapshot['volume'] # NOTE(andrey-mp): make Snapshot object here to check object algorithms fake_snapshot_obj = { 'id': fake.SNAPSHOT_ID, 'volume_id': fake.VOLUME_ID, 'status': fields.SnapshotStatus.CREATING, 'progress': '0%', 'volume_size': 1, 'display_name': 'fake_name', 'display_description': 'fake_description', 'metadata': {}, }
def test_refresh(self, snapshot_get, snapshot_metadata_get): db_snapshot = fake_snapshot.fake_db_snapshot() snapshot_get.return_value = db_snapshot snapshot = objects.Snapshot.get_by_id(self.context, "1") snapshot.refresh() snapshot_get.assert_has_calls([mock.call(self.context, "1"), mock.call(self.context, "1")])
from oslo_log import log as logging from cinder.db.sqlalchemy import models from cinder import exception from cinder import objects from cinder.tests.unit import fake_constants as fake from cinder.tests.unit import fake_snapshot from cinder.tests.unit import fake_volume from cinder.tests.unit import objects as test_objects LOG = logging.getLogger(__name__) fake_db_snapshot = fake_snapshot.fake_db_snapshot(cgsnapshot_id=fake.cgsnapshot_id) del fake_db_snapshot["metadata"] del fake_db_snapshot["volume"] # NOTE(andrey-mp): make Snapshot object here to check object algorithms fake_snapshot_obj = { "id": fake.snapshot_id, "volume_id": fake.volume_id, "status": "creating", "progress": "0%", "volume_size": 1, "display_name": "fake_name", "display_description": "fake_description", "metadata": {}, }
"""Return predefined volume info.""" return TEST_VOLUME[int(volume_id.replace("-", ""))] TEST_SNAPSHOT = [] snapshot = {} snapshot['id'] = '10000000-0000-0000-0000-{0:012d}'.format(0) snapshot['name'] = 'TEST_SNAPSHOT{0:d}'.format(0) snapshot['provider_location'] = '{0:d}'.format(1) snapshot['status'] = 'available' snapshot['volume_id'] = '00000000-0000-0000-0000-{0:012d}'.format(0) snapshot['volume'] = _volume_get(None, snapshot['volume_id']) snapshot['volume_name'] = 'test-volume{0:d}'.format(0) snapshot['volume_size'] = 128 snapshot = obj_snap.Snapshot._from_db_object( CTXT, obj_snap.Snapshot(), fake_snapshot.fake_db_snapshot(**snapshot)) TEST_SNAPSHOT.append(snapshot) # Dummy response for REST API POST_SESSIONS_RESULT = { "token": "b74777a3-f9f0-4ea8-bd8f-09847fac48d3", "sessionId": 0, } GET_PORTS_RESULT = { "data": [ { "portId": CONFIG_MAP['port_id'], "portType": "FIBRE", "portAttributes": ["TAR", "MCU", "RCU", "ELUN"], "fabricMode": True,
# under the License. import copy import mock from oslo_log import log as logging from cinder import exception from cinder import objects from cinder.tests.unit import fake_snapshot from cinder.tests.unit import fake_volume from cinder.tests.unit import objects as test_objects LOG = logging.getLogger(__name__) fake_db_snapshot = fake_snapshot.fake_db_snapshot( cgsnapshot_id='fake_cgsnap_id') del fake_db_snapshot['metadata'] del fake_db_snapshot['volume'] # NOTE(andrey-mp): make Snapshot object here to check object algorithms fake_snapshot_obj = { 'id': '1', 'volume_id': 'fake_id', 'status': "creating", 'progress': '0%', 'volume_size': 1, 'display_name': 'fake_name', 'display_description': 'fake_description', 'metadata': {}, }
# under the License. import copy import mock from oslo_log import log as logging from cinder import exception from cinder import objects from cinder.tests.unit import fake_snapshot from cinder.tests.unit import fake_volume from cinder.tests.unit import objects as test_objects LOG = logging.getLogger(__name__) fake_db_snapshot = fake_snapshot.fake_db_snapshot() del fake_db_snapshot['metadata'] del fake_db_snapshot['volume'] # NOTE(andrey-mp): make Snapshot object here to check object algorithms fake_snapshot_obj = { 'id': '1', 'volume_id': 'fake_id', 'status': "creating", 'progress': '0%', 'volume_size': 1, 'display_name': 'fake_name', 'display_description': 'fake_description', 'metadata': {}, }
from oslo_log import log as logging from cinder.db.sqlalchemy import models from cinder import exception from cinder import objects from cinder.tests.unit import fake_constants as fake from cinder.tests.unit import fake_snapshot from cinder.tests.unit import fake_volume from cinder.tests.unit import objects as test_objects LOG = logging.getLogger(__name__) fake_db_snapshot = fake_snapshot.fake_db_snapshot( cgsnapshot_id=fake.cgsnapshot_id) del fake_db_snapshot['metadata'] del fake_db_snapshot['volume'] # NOTE(andrey-mp): make Snapshot object here to check object algorithms fake_snapshot_obj = { 'id': fake.snapshot_id, 'volume_id': fake.volume_id, 'status': "creating", 'progress': '0%', 'volume_size': 1, 'display_name': 'fake_name', 'display_description': 'fake_description', 'metadata': {}, }
def test_delete_snapshot_on_non_existing_snapshot(self): """Test delete_snapshot on non existing snapshot.""" snapshot = fake_snapshot.fake_db_snapshot(**self._TEST_SNAPSHOT) snapshot['provider_location'] = '1' self.driver.delete_snapshot(snapshot)
def test_create_snapshot_error_on_non_src_ref(self): """Test create_snapshot is error on non source reference.""" snapshot = fake_snapshot.fake_db_snapshot(**self._TEST_SNAPSHOT) self.assertRaises(exception.VolumeBackendAPIException, self.driver.create_snapshot, snapshot)
import copy import mock from oslo_log import log as logging from cinder import exception from cinder import objects from cinder.tests.unit import fake_snapshot from cinder.tests.unit import fake_volume from cinder.tests.unit import objects as test_objects LOG = logging.getLogger(__name__) fake_db_snapshot = fake_snapshot.fake_db_snapshot() del fake_db_snapshot['metadata'] del fake_db_snapshot['volume'] # NOTE(andrey-mp): make Snapshot object here to check object algorithms fake_snapshot_obj = { 'id': '1', 'volume_id': 'fake_id', 'status': "creating", 'progress': '0%', 'volume_size': 1, 'display_name': 'fake_name', 'display_description': 'fake_description', 'metadata': {}, }
def _stub_snapshot(*args, **kwargs): updates = {'volume': _stub_volume(), 'name': 'vrts'} return fake_snapshot.fake_db_snapshot(**updates)
import copy import mock from oslo_log import log as logging from cinder import exception from cinder import objects from cinder.tests.unit import fake_snapshot from cinder.tests.unit import fake_volume from cinder.tests.unit import objects as test_objects LOG = logging.getLogger(__name__) fake_db_snapshot = fake_snapshot.fake_db_snapshot( cgsnapshot_id='fake_cgsnap_id') del fake_db_snapshot['metadata'] del fake_db_snapshot['volume'] # NOTE(andrey-mp): make Snapshot object here to check object algorithms fake_snapshot_obj = { 'id': '1', 'volume_id': 'fake_id', 'status': "creating", 'progress': '0%', 'volume_size': 1, 'display_name': 'fake_name', 'display_description': 'fake_description', 'metadata': {}, }