Merge "Fix an error in CG object"
This commit is contained in:
commit
7213086164
@ -60,7 +60,7 @@ class ConsistencyGroup(base.CinderPersistentObject, base.CinderObject,
|
||||
|
||||
if 'cgsnapshots' in expected_attrs:
|
||||
cgsnapshots = base.obj_make_list(
|
||||
context, objects.CGSnapshotsList(context),
|
||||
context, objects.CGSnapshotList(context),
|
||||
objects.CGSnapshot,
|
||||
db_consistencygroup['cgsnapshots'])
|
||||
consistencygroup.cgsnapshots = cgsnapshots
|
||||
@ -70,7 +70,7 @@ class ConsistencyGroup(base.CinderPersistentObject, base.CinderObject,
|
||||
context, objects.VolumeList(context),
|
||||
objects.Volume,
|
||||
db_consistencygroup['volumes'])
|
||||
consistencygroup.cgsnapshots = volumes
|
||||
consistencygroup.volumes = volumes
|
||||
|
||||
consistencygroup._context = context
|
||||
consistencygroup.obj_reset_changes()
|
||||
|
@ -19,6 +19,7 @@ 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_volume
|
||||
from cinder.tests.unit import objects as test_objects
|
||||
|
||||
fake_consistencygroup = {
|
||||
@ -184,6 +185,21 @@ class TestConsistencyGroup(test_objects.BaseObjectsTestCase):
|
||||
self.context,
|
||||
fake.CONSISTENCY_GROUP_ID)])
|
||||
|
||||
def test_from_db_object_with_all_expected_attributes(self):
|
||||
expected_attrs = ['volumes', 'cgsnapshots']
|
||||
db_volumes = [fake_volume.fake_db_volume(admin_metadata={},
|
||||
volume_metadata={})]
|
||||
db_cgsnaps = [fake_cgsnapshot.copy()]
|
||||
db_cg = fake_consistencygroup.copy()
|
||||
db_cg['volumes'] = db_volumes
|
||||
db_cg['cgsnapshots'] = db_cgsnaps
|
||||
cg = objects.ConsistencyGroup._from_db_object(
|
||||
self.context, objects.ConsistencyGroup(), db_cg, expected_attrs)
|
||||
self.assertEqual(len(db_volumes), len(cg.volumes))
|
||||
self._compare(self, db_volumes[0], cg.volumes[0])
|
||||
self.assertEqual(len(db_cgsnaps), len(cg.cgsnapshots))
|
||||
self._compare(self, db_cgsnaps[0], cg.cgsnapshots[0])
|
||||
|
||||
|
||||
class TestConsistencyGroupList(test_objects.BaseObjectsTestCase):
|
||||
@mock.patch('cinder.db.consistencygroup_get_all',
|
||||
|
Loading…
x
Reference in New Issue
Block a user