From 6449d734c788b5e30b5f11d9911b4b729d31b28d Mon Sep 17 00:00:00 2001 From: whoami-rajat Date: Mon, 15 Oct 2018 16:27:15 +0530 Subject: [PATCH] Adding regression test for update_group Initially the issue was fixed here If74d23b9413209ee8db3c58fc71d215abeb580b2, but due to code changes, the same issue was repeated and fixed here, Ia43a6f2df7fd4066a0ed26450b26a1456d4cecfa. Addressing the comment on the latest fix, adding test case. Change-Id: I03d6214abf050e5f9a2cc5fa0772150bbbf8520e Related-Bug: #1645207 --- cinder/tests/unit/group/test_groups_manager.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cinder/tests/unit/group/test_groups_manager.py b/cinder/tests/unit/group/test_groups_manager.py index 96a21470000..7252556c4f2 100644 --- a/cinder/tests/unit/group/test_groups_manager.py +++ b/cinder/tests/unit/group/test_groups_manager.py @@ -382,6 +382,22 @@ class GroupManagerTestCase(test.TestCase): self.volume.db.volume_get.reset_mock() self.volume.db.volume_get = volume_get_orig + def test_update_group_vol_not_found(self): + """Test add non existent volume to group""" + group = tests_utils.create_group( + self.context, + availability_zone=CONF.storage_availability_zone, + volume_type_ids=[fake.VOLUME_TYPE_ID], + group_type_id=fake.GROUP_TYPE_ID, + host=CONF.host) + self.volume.create_group(self.context, group) + + self.assertRaises(exception.VolumeNotFound, + self.volume.update_group, + self.context, group, + add_volumes=fake.VOLUME_ID, + remove_volumes=fake.VOLUME2_ID) + @mock.patch('cinder.db.sqlalchemy.api.' 'volume_glance_metadata_copy_to_volume') @mock.patch('cinder.db.sqlalchemy.api.'