add repoducer test for bug 1890244

This change adds a test to simulate validating
a instnace group policy where the group has been
deleted but is still referenced in the scheduler hint.

Change-Id: I803e6286a773d9e53639ab0cd449fc72bb3be613
Related-Bug: #1890244
(cherry picked from commit 84a84f7f2f)
This commit is contained in:
Sean Mooney 2022-06-21 12:04:20 +01:00 committed by Edward Hope-Morley
parent eada760a21
commit f57900ad20
1 changed files with 18 additions and 0 deletions

View File

@ -7615,6 +7615,24 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
instance, hints)
mock_get.assert_called_once_with(self.context, uuids.group_hint)
@mock.patch('nova.objects.InstanceGroup.get_by_hint')
def test_validate_instance_group_policy_deleted_group(self, mock_get):
"""Tests that _validate_instance_group_policy handles the case
where the scheduler hint has a group but that group has been deleted.
This tests is a reproducer for bug: #1890244
"""
instance = objects.Instance(uuid=uuids.instance)
hints = {'group': [uuids.group_hint]}
mock_get.side_effect = exception.InstanceGroupNotFound(
group_uuid=uuids.group_hint
)
# FIXME(sean-k-mooney): this should not leak the exception
self.assertRaises(
exception.InstanceGroupNotFound,
self.compute._validate_instance_group_policy, self.context,
instance, hints)
mock_get.assert_called_once_with(self.context, uuids.group_hint)
@mock.patch('nova.objects.InstanceGroup.get_by_uuid')
@mock.patch('nova.objects.InstanceList.get_uuids_by_host')
@mock.patch('nova.objects.InstanceGroup.get_by_hint')