From f0e24ff8ea831841c9385aecd1a4a0c2ced5396e Mon Sep 17 00:00:00 2001 From: Daniel Tadrzak Date: Fri, 31 Jul 2015 14:31:14 +0200 Subject: [PATCH] Cleanup for cinder tests with CGSnapshot Switch cinder tests to use CGSnapshot objects instead of direct calls to db. Additionally, the patch switches from dict to object notation. Drivers tests need to be fixed in other patch. Co-Authored-By: Szymon Wroblewski Partial-Implements: blueprint cinder-objects Change-Id: I40161592c887a386aa7a323381d71f0111d584fa --- .../unit/api/contrib/test_cgsnapshots.py | 246 ++++++++---------- .../api/contrib/test_consistencygroups.py | 41 ++- cinder/tests/unit/test_storwize_svc.py | 6 +- 3 files changed, 134 insertions(+), 159 deletions(-) diff --git a/cinder/tests/unit/api/contrib/test_cgsnapshots.py b/cinder/tests/unit/api/contrib/test_cgsnapshots.py index 2eab1e441..7ba5bcb9f 100644 --- a/cinder/tests/unit/api/contrib/test_cgsnapshots.py +++ b/cinder/tests/unit/api/contrib/test_cgsnapshots.py @@ -27,6 +27,7 @@ from cinder.consistencygroup import api as consistencygroupAPI from cinder import context from cinder import db from cinder import exception +from cinder import objects from cinder import test from cinder.tests.unit.api import fakes from cinder.tests.unit import utils @@ -43,37 +44,15 @@ class CgsnapshotsAPITestCase(test.TestCase): self.context.project_id = 'fake' self.context.user_id = 'fake' - @staticmethod - def _create_cgsnapshot( - name='test_cgsnapshot', - description='this is a test cgsnapshot', - consistencygroup_id='1', - status='creating'): - """Create a cgsnapshot object.""" - cgsnapshot = {} - cgsnapshot['user_id'] = 'fake' - cgsnapshot['project_id'] = 'fake' - cgsnapshot['consistencygroup_id'] = consistencygroup_id - cgsnapshot['name'] = name - cgsnapshot['description'] = description - cgsnapshot['status'] = status - return db.cgsnapshot_create(context.get_admin_context(), - cgsnapshot)['id'] - - @staticmethod - def _get_cgsnapshot_attrib(cgsnapshot_id, attrib_name): - return db.cgsnapshot_get(context.get_admin_context(), - cgsnapshot_id)[attrib_name] - def test_show_cgsnapshot(self): consistencygroup = utils.create_consistencygroup(self.context) volume_id = utils.create_volume(self.context, consistencygroup_id= consistencygroup.id)['id'] - cgsnapshot_id = self._create_cgsnapshot( - consistencygroup_id=consistencygroup.id) + cgsnapshot = utils.create_cgsnapshot( + self.context, consistencygroup_id=consistencygroup.id) req = webob.Request.blank('/v2/fake/cgsnapshots/%s' % - cgsnapshot_id) + cgsnapshot.id) req.method = 'GET' req.headers['Content-Type'] = 'application/json' res = req.get_response(fakes.wsgi_app()) @@ -87,8 +66,7 @@ class CgsnapshotsAPITestCase(test.TestCase): res_dict['cgsnapshot']['name']) self.assertEqual('creating', res_dict['cgsnapshot']['status']) - db.cgsnapshot_destroy(context.get_admin_context(), - cgsnapshot_id) + cgsnapshot.destroy() db.volume_destroy(context.get_admin_context(), volume_id) consistencygroup.destroy() @@ -98,21 +76,21 @@ class CgsnapshotsAPITestCase(test.TestCase): volume_id = utils.create_volume(self.context, consistencygroup_id= consistencygroup.id)['id'] - cgsnapshot_id = self._create_cgsnapshot( - consistencygroup_id=consistencygroup.id) + cgsnapshot = utils.create_cgsnapshot( + self.context, consistencygroup_id=consistencygroup.id) req = webob.Request.blank('/v2/fake/cgsnapshots/%s' % - cgsnapshot_id) + cgsnapshot.id) req.method = 'GET' req.headers['Content-Type'] = 'application/xml' req.headers['Accept'] = 'application/xml' res = req.get_response(fakes.wsgi_app()) self.assertEqual(200, res.status_int) dom = minidom.parseString(res.body) - cgsnapshot = dom.getElementsByTagName('cgsnapshot') - name = cgsnapshot.item(0).getAttribute('name') - self.assertEqual('test_cgsnapshot', name.strip()) - db.cgsnapshot_destroy(context.get_admin_context(), - cgsnapshot_id) + + cgsnapshots = dom.getElementsByTagName('cgsnapshot') + name = cgsnapshots.item(0).getAttribute('name') + self.assertEqual("test_cgsnapshot", name.strip()) + cgsnapshot.destroy() db.volume_destroy(context.get_admin_context(), volume_id) consistencygroup.destroy() @@ -134,12 +112,12 @@ class CgsnapshotsAPITestCase(test.TestCase): volume_id = utils.create_volume(self.context, consistencygroup_id= consistencygroup.id)['id'] - cgsnapshot_id1 = self._create_cgsnapshot( - consistencygroup_id=consistencygroup.id) - cgsnapshot_id2 = self._create_cgsnapshot( - consistencygroup_id=consistencygroup.id) - cgsnapshot_id3 = self._create_cgsnapshot( - consistencygroup_id=consistencygroup.id) + cgsnapshot1 = utils.create_cgsnapshot( + self.context, consistencygroup_id=consistencygroup.id) + cgsnapshot2 = utils.create_cgsnapshot( + self.context, consistencygroup_id=consistencygroup.id) + cgsnapshot3 = utils.create_cgsnapshot( + self.context, consistencygroup_id=consistencygroup.id) req = webob.Request.blank('/v2/fake/cgsnapshots') req.method = 'GET' @@ -148,25 +126,22 @@ class CgsnapshotsAPITestCase(test.TestCase): res_dict = json.loads(res.body) self.assertEqual(200, res.status_int) - self.assertEqual(cgsnapshot_id1, + self.assertEqual(cgsnapshot1.id, res_dict['cgsnapshots'][0]['id']) self.assertEqual('test_cgsnapshot', res_dict['cgsnapshots'][0]['name']) - self.assertEqual(cgsnapshot_id2, + self.assertEqual(cgsnapshot2.id, res_dict['cgsnapshots'][1]['id']) self.assertEqual('test_cgsnapshot', res_dict['cgsnapshots'][1]['name']) - self.assertEqual(cgsnapshot_id3, + self.assertEqual(cgsnapshot3.id, res_dict['cgsnapshots'][2]['id']) self.assertEqual('test_cgsnapshot', res_dict['cgsnapshots'][2]['name']) - db.cgsnapshot_destroy(context.get_admin_context(), - cgsnapshot_id3) - db.cgsnapshot_destroy(context.get_admin_context(), - cgsnapshot_id2) - db.cgsnapshot_destroy(context.get_admin_context(), - cgsnapshot_id1) + cgsnapshot3.destroy() + cgsnapshot2.destroy() + cgsnapshot1.destroy() db.volume_destroy(context.get_admin_context(), volume_id) consistencygroup.destroy() @@ -176,12 +151,12 @@ class CgsnapshotsAPITestCase(test.TestCase): volume_id = utils.create_volume(self.context, consistencygroup_id= consistencygroup.id)['id'] - cgsnapshot_id1 = self._create_cgsnapshot(consistencygroup_id= - consistencygroup.id) - cgsnapshot_id2 = self._create_cgsnapshot(consistencygroup_id= - consistencygroup.id) - cgsnapshot_id3 = self._create_cgsnapshot(consistencygroup_id= - consistencygroup.id) + cgsnapshot1 = utils.create_cgsnapshot( + self.context, consistencygroup_id=consistencygroup.id) + cgsnapshot2 = utils.create_cgsnapshot( + self.context, consistencygroup_id=consistencygroup.id) + cgsnapshot3 = utils.create_cgsnapshot( + self.context, consistencygroup_id=consistencygroup.id) req = webob.Request.blank('/v2/fake/cgsnapshots') req.method = 'GET' @@ -193,19 +168,16 @@ class CgsnapshotsAPITestCase(test.TestCase): dom = minidom.parseString(res.body) cgsnapshot_list = dom.getElementsByTagName('cgsnapshot') - self.assertEqual(cgsnapshot_id1, + self.assertEqual(cgsnapshot1.id, cgsnapshot_list.item(0).getAttribute('id')) - self.assertEqual(cgsnapshot_id2, + self.assertEqual(cgsnapshot2.id, cgsnapshot_list.item(1).getAttribute('id')) - self.assertEqual(cgsnapshot_id3, + self.assertEqual(cgsnapshot3.id, cgsnapshot_list.item(2).getAttribute('id')) - db.cgsnapshot_destroy(context.get_admin_context(), - cgsnapshot_id3) - db.cgsnapshot_destroy(context.get_admin_context(), - cgsnapshot_id2) - db.cgsnapshot_destroy(context.get_admin_context(), - cgsnapshot_id1) + cgsnapshot3.destroy() + cgsnapshot2.destroy() + cgsnapshot1.destroy() db.volume_destroy(context.get_admin_context(), volume_id) consistencygroup.destroy() @@ -215,12 +187,12 @@ class CgsnapshotsAPITestCase(test.TestCase): volume_id = utils.create_volume(self.context, consistencygroup_id= consistencygroup.id)['id'] - cgsnapshot_id1 = self._create_cgsnapshot(consistencygroup_id= - consistencygroup.id) - cgsnapshot_id2 = self._create_cgsnapshot(consistencygroup_id= - consistencygroup.id) - cgsnapshot_id3 = self._create_cgsnapshot(consistencygroup_id= - consistencygroup.id) + cgsnapshot1 = utils.create_cgsnapshot( + self.context, consistencygroup_id=consistencygroup.id) + cgsnapshot2 = utils.create_cgsnapshot( + self.context, consistencygroup_id=consistencygroup.id) + cgsnapshot3 = utils.create_cgsnapshot( + self.context, consistencygroup_id=consistencygroup.id) req = webob.Request.blank('/v2/fake/cgsnapshots/detail') req.method = 'GET' @@ -234,7 +206,7 @@ class CgsnapshotsAPITestCase(test.TestCase): res_dict['cgsnapshots'][0]['description']) self.assertEqual('test_cgsnapshot', res_dict['cgsnapshots'][0]['name']) - self.assertEqual(cgsnapshot_id1, + self.assertEqual(cgsnapshot1.id, res_dict['cgsnapshots'][0]['id']) self.assertEqual('creating', res_dict['cgsnapshots'][0]['status']) @@ -243,7 +215,7 @@ class CgsnapshotsAPITestCase(test.TestCase): res_dict['cgsnapshots'][1]['description']) self.assertEqual('test_cgsnapshot', res_dict['cgsnapshots'][1]['name']) - self.assertEqual(cgsnapshot_id2, + self.assertEqual(cgsnapshot2.id, res_dict['cgsnapshots'][1]['id']) self.assertEqual('creating', res_dict['cgsnapshots'][1]['status']) @@ -252,16 +224,14 @@ class CgsnapshotsAPITestCase(test.TestCase): res_dict['cgsnapshots'][2]['description']) self.assertEqual('test_cgsnapshot', res_dict['cgsnapshots'][2]['name']) - self.assertEqual(cgsnapshot_id3, + self.assertEqual(cgsnapshot3.id, res_dict['cgsnapshots'][2]['id']) self.assertEqual('creating', res_dict['cgsnapshots'][2]['status']) - db.cgsnapshot_destroy(context.get_admin_context(), - cgsnapshot_id3) - db.cgsnapshot_destroy(context.get_admin_context(), - cgsnapshot_id2) - db.cgsnapshot_destroy(context.get_admin_context(), - cgsnapshot_id1) + + cgsnapshot3.destroy() + cgsnapshot2.destroy() + cgsnapshot1.destroy() db.volume_destroy(context.get_admin_context(), volume_id) consistencygroup.destroy() @@ -271,12 +241,12 @@ class CgsnapshotsAPITestCase(test.TestCase): volume_id = utils.create_volume(self.context, consistencygroup_id= consistencygroup.id)['id'] - cgsnapshot_id1 = self._create_cgsnapshot(consistencygroup_id= - consistencygroup.id) - cgsnapshot_id2 = self._create_cgsnapshot(consistencygroup_id= - consistencygroup.id) - cgsnapshot_id3 = self._create_cgsnapshot(consistencygroup_id= - consistencygroup.id) + cgsnapshot1 = utils.create_cgsnapshot( + self.context, consistencygroup_id=consistencygroup.id) + cgsnapshot2 = utils.create_cgsnapshot( + self.context, consistencygroup_id=consistencygroup.id) + cgsnapshot3 = utils.create_cgsnapshot( + self.context, consistencygroup_id=consistencygroup.id) req = webob.Request.blank('/v2/fake/cgsnapshots/detail') req.method = 'GET' @@ -288,39 +258,45 @@ class CgsnapshotsAPITestCase(test.TestCase): dom = minidom.parseString(res.body) cgsnapshot_detail = dom.getElementsByTagName('cgsnapshot') - self.assertEqual('this is a test cgsnapshot', - cgsnapshot_detail.item(0).getAttribute('description')) - self.assertEqual('test_cgsnapshot', - cgsnapshot_detail.item(0).getAttribute('name')) - self.assertEqual(cgsnapshot_id1, - cgsnapshot_detail.item(0).getAttribute('id')) - self.assertEqual('creating', - cgsnapshot_detail.item(0).getAttribute('status')) - - self.assertEqual('this is a test cgsnapshot', - cgsnapshot_detail.item(1).getAttribute('description')) - self.assertEqual('test_cgsnapshot', - cgsnapshot_detail.item(1).getAttribute('name')) - self.assertEqual(cgsnapshot_id2, - cgsnapshot_detail.item(1).getAttribute('id')) - self.assertEqual('creating', - cgsnapshot_detail.item(1).getAttribute('status')) - - self.assertEqual('this is a test cgsnapshot', - cgsnapshot_detail.item(2).getAttribute('description')) - self.assertEqual('test_cgsnapshot', - cgsnapshot_detail.item(2).getAttribute('name')) - self.assertEqual(cgsnapshot_id3, - cgsnapshot_detail.item(2).getAttribute('id')) - self.assertEqual('creating', - cgsnapshot_detail.item(2).getAttribute('status')) - - db.cgsnapshot_destroy(context.get_admin_context(), - cgsnapshot_id3) - db.cgsnapshot_destroy(context.get_admin_context(), - cgsnapshot_id2) - db.cgsnapshot_destroy(context.get_admin_context(), - cgsnapshot_id1) + self.assertEqual( + 'this is a test cgsnapshot', + cgsnapshot_detail.item(0).getAttribute('description')) + self.assertEqual( + 'test_cgsnapshot', + cgsnapshot_detail.item(0).getAttribute('name')) + self.assertEqual( + cgsnapshot1.id, + cgsnapshot_detail.item(0).getAttribute('id')) + self.assertEqual( + 'creating', cgsnapshot_detail.item(0).getAttribute('status')) + + self.assertEqual( + 'this is a test cgsnapshot', + cgsnapshot_detail.item(1).getAttribute('description')) + self.assertEqual( + 'test_cgsnapshot', + cgsnapshot_detail.item(1).getAttribute('name')) + self.assertEqual( + cgsnapshot2.id, + cgsnapshot_detail.item(1).getAttribute('id')) + self.assertEqual( + 'creating', cgsnapshot_detail.item(1).getAttribute('status')) + + self.assertEqual( + 'this is a test cgsnapshot', + cgsnapshot_detail.item(2).getAttribute('description')) + self.assertEqual( + 'test_cgsnapshot', + cgsnapshot_detail.item(2).getAttribute('name')) + self.assertEqual( + cgsnapshot3.id, + cgsnapshot_detail.item(2).getAttribute('id')) + self.assertEqual( + 'creating', cgsnapshot_detail.item(2).getAttribute('status')) + + cgsnapshot3.destroy() + cgsnapshot2.destroy() + cgsnapshot1.destroy() db.volume_destroy(context.get_admin_context(), volume_id) consistencygroup.destroy() @@ -328,8 +304,6 @@ class CgsnapshotsAPITestCase(test.TestCase): @mock.patch( 'cinder.api.openstack.wsgi.Controller.validate_name_and_description') def test_create_cgsnapshot_json(self, mock_validate): - cgsnapshot_id = "1" - consistencygroup = utils.create_consistencygroup(self.context) utils.create_volume( self.context, consistencygroup_id=consistencygroup.id) @@ -350,8 +324,10 @@ class CgsnapshotsAPITestCase(test.TestCase): self.assertIn('id', res_dict['cgsnapshot']) self.assertTrue(mock_validate.called) - db.cgsnapshot_destroy(context.get_admin_context(), cgsnapshot_id) consistencygroup.destroy() + cgsnapshot = objects.CGSnapshot.get_by_id( + context.get_admin_context(), res_dict['cgsnapshot']['id']) + cgsnapshot.destroy() def test_create_cgsnapshot_with_no_body(self): # omit body from the request @@ -425,21 +401,21 @@ class CgsnapshotsAPITestCase(test.TestCase): volume_id = utils.create_volume( self.context, consistencygroup_id=consistencygroup.id)['id'] - cgsnapshot_id = self._create_cgsnapshot( + cgsnapshot = utils.create_cgsnapshot( + self.context, consistencygroup_id=consistencygroup.id, status='available') req = webob.Request.blank('/v2/fake/cgsnapshots/%s' % - cgsnapshot_id) + cgsnapshot.id) req.method = 'DELETE' req.headers['Content-Type'] = 'application/json' res = req.get_response(fakes.wsgi_app()) + cgsnapshot = objects.CGSnapshot.get_by_id(self.context, cgsnapshot.id) self.assertEqual(202, res.status_int) - self.assertEqual('deleting', self._get_cgsnapshot_attrib(cgsnapshot_id, - 'status')) + self.assertEqual('deleting', cgsnapshot.status) - db.cgsnapshot_destroy(context.get_admin_context(), - cgsnapshot_id) + cgsnapshot.destroy() db.volume_destroy(context.get_admin_context(), volume_id) consistencygroup.destroy() @@ -459,11 +435,14 @@ class CgsnapshotsAPITestCase(test.TestCase): def test_delete_cgsnapshot_with_Invalidcgsnapshot(self): consistencygroup = utils.create_consistencygroup(self.context) volume_id = utils.create_volume( - self.context, consistencygroup_id=consistencygroup.id)['id'] - cgsnapshot_id = self._create_cgsnapshot( - consistencygroup_id=consistencygroup.id, status='invalid') + self.context, + consistencygroup_id=consistencygroup.id)['id'] + cgsnapshot = utils.create_cgsnapshot( + self.context, + consistencygroup_id=consistencygroup.id, + status='invalid') req = webob.Request.blank('/v2/fake/cgsnapshots/%s' % - cgsnapshot_id) + cgsnapshot.id) req.method = 'DELETE' req.headers['Content-Type'] = 'application/json' res = req.get_response(fakes.wsgi_app()) @@ -474,8 +453,7 @@ class CgsnapshotsAPITestCase(test.TestCase): self.assertEqual('Invalid cgsnapshot', res_dict['badRequest']['message']) - db.cgsnapshot_destroy(context.get_admin_context(), - cgsnapshot_id) + cgsnapshot.destroy() db.volume_destroy(context.get_admin_context(), volume_id) consistencygroup.destroy() diff --git a/cinder/tests/unit/api/contrib/test_consistencygroups.py b/cinder/tests/unit/api/contrib/test_consistencygroups.py index 5a0e846b5..2bb047f2e 100644 --- a/cinder/tests/unit/api/contrib/test_consistencygroups.py +++ b/cinder/tests/unit/api/contrib/test_consistencygroups.py @@ -731,20 +731,19 @@ class ConsistencyGroupsAPITestCase(test.TestCase): volume_id = utils.create_volume( self.ctxt, consistencygroup_id=consistencygroup.id)['id'] - cgsnapshot_id = utils.create_cgsnapshot( - self.ctxt, - consistencygroup_id=consistencygroup.id)['id'] + cgsnapshot = utils.create_cgsnapshot( + self.ctxt, consistencygroup_id=consistencygroup.id) snapshot = utils.create_snapshot( self.ctxt, volume_id, - cgsnapshot_id=cgsnapshot_id, + cgsnapshot_id=cgsnapshot.id, status='available') test_cg_name = 'test cg' body = {"consistencygroup-from-src": {"name": test_cg_name, "description": "Consistency Group 1", - "cgsnapshot_id": cgsnapshot_id}} + "cgsnapshot_id": cgsnapshot.id}} req = webob.Request.blank('/v2/fake/consistencygroups/create_from_src') req.method = 'POST' req.headers['Content-Type'] = 'application/json' @@ -762,9 +761,9 @@ class ConsistencyGroupsAPITestCase(test.TestCase): cg_ref.destroy() snapshot.destroy() - db.cgsnapshot_destroy(self.ctxt.elevated(), cgsnapshot_id) db.volume_destroy(self.ctxt.elevated(), volume_id) consistencygroup.destroy() + cgsnapshot.destroy() def test_create_consistencygroup_from_src_cg(self): self.mock_object(volume_api.API, "create", stubs.stub_volume_create) @@ -873,20 +872,19 @@ class ConsistencyGroupsAPITestCase(test.TestCase): volume_id = utils.create_volume( self.ctxt, consistencygroup_id=consistencygroup.id)['id'] - cgsnapshot_id = utils.create_cgsnapshot( - self.ctxt, - consistencygroup_id=consistencygroup.id)['id'] + cgsnapshot = utils.create_cgsnapshot( + self.ctxt, consistencygroup_id=consistencygroup.id) snapshot = utils.create_snapshot( self.ctxt, volume_id, - cgsnapshot_id=cgsnapshot_id, + cgsnapshot_id=cgsnapshot.id, status='available') test_cg_name = 'test cg' body = {"consistencygroup-from-src": {"name": test_cg_name, "description": "Consistency Group 1", - "cgsnapshot_id": cgsnapshot_id}} + "cgsnapshot_id": cgsnapshot.id}} req = webob.Request.blank('/v2/fake/consistencygroups/create_from_src') req.method = 'POST' req.headers['Content-Type'] = 'application/json' @@ -901,24 +899,24 @@ class ConsistencyGroupsAPITestCase(test.TestCase): self.assertIn(msg, res_dict['badRequest']['message']) snapshot.destroy() - db.cgsnapshot_destroy(self.ctxt.elevated(), cgsnapshot_id) db.volume_destroy(self.ctxt.elevated(), volume_id) consistencygroup.destroy() + cgsnapshot.destroy() def test_create_consistencygroup_from_src_cgsnapshot_empty(self): consistencygroup = utils.create_consistencygroup(self.ctxt) volume_id = utils.create_volume( self.ctxt, consistencygroup_id=consistencygroup.id)['id'] - cgsnapshot_id = utils.create_cgsnapshot( + cgsnapshot = utils.create_cgsnapshot( self.ctxt, - consistencygroup_id=consistencygroup.id)['id'] + consistencygroup_id=consistencygroup.id) test_cg_name = 'test cg' body = {"consistencygroup-from-src": {"name": test_cg_name, "description": "Consistency Group 1", - "cgsnapshot_id": cgsnapshot_id}} + "cgsnapshot_id": cgsnapshot.id}} req = webob.Request.blank('/v2/fake/consistencygroups/create_from_src') req.method = 'POST' req.headers['Content-Type'] = 'application/json' @@ -930,9 +928,9 @@ class ConsistencyGroupsAPITestCase(test.TestCase): self.assertEqual(400, res_dict['badRequest']['code']) self.assertIsNotNone(res_dict['badRequest']['message']) - db.cgsnapshot_destroy(self.ctxt.elevated(), cgsnapshot_id) db.volume_destroy(self.ctxt.elevated(), volume_id) consistencygroup.destroy() + cgsnapshot.destroy() def test_create_consistencygroup_from_src_source_cg_empty(self): source_cg = utils.create_consistencygroup(self.ctxt) @@ -1006,20 +1004,19 @@ class ConsistencyGroupsAPITestCase(test.TestCase): volume_id = utils.create_volume( self.ctxt, consistencygroup_id=consistencygroup.id)['id'] - cgsnapshot_id = utils.create_cgsnapshot( - self.ctxt, - consistencygroup_id=consistencygroup.id)['id'] + cgsnapshot = utils.create_cgsnapshot( + self.ctxt, consistencygroup_id=consistencygroup.id) snapshot = utils.create_snapshot( self.ctxt, volume_id, - cgsnapshot_id=cgsnapshot_id, + cgsnapshot_id=cgsnapshot.id, status='available') test_cg_name = 'test cg' body = {"consistencygroup-from-src": {"name": test_cg_name, "description": "Consistency Group 1", - "cgsnapshot_id": cgsnapshot_id}} + "cgsnapshot_id": cgsnapshot.id}} req = webob.Request.blank('/v2/fake/consistencygroups/create_from_src') req.method = 'POST' req.headers['Content-Type'] = 'application/json' @@ -1033,9 +1030,9 @@ class ConsistencyGroupsAPITestCase(test.TestCase): self.assertEqual(msg, res_dict['badRequest']['message']) snapshot.destroy() - db.cgsnapshot_destroy(self.ctxt.elevated(), cgsnapshot_id) db.volume_destroy(self.ctxt.elevated(), volume_id) consistencygroup.destroy() + cgsnapshot.destroy() @mock.patch.object(volume_api.API, 'create', side_effect=exception.CinderException( diff --git a/cinder/tests/unit/test_storwize_svc.py b/cinder/tests/unit/test_storwize_svc.py index 596f8912f..c2098e6c8 100644 --- a/cinder/tests/unit/test_storwize_svc.py +++ b/cinder/tests/unit/test_storwize_svc.py @@ -1917,9 +1917,9 @@ class StorwizeSVCDriverTestCase(test.TestCase): for volume in volumes: testutils.create_snapshot(self.ctxt, volume['id'], - cg_snapshot['id'], - cg_snapshot['name'], - cg_snapshot['id'], + cg_snapshot.id, + cg_snapshot.name, + cg_snapshot.id, "creating") return cg_snapshot -- 2.45.2