Skip to content

Commit f57900a

Browse files
SeanMooneydosaboy
authored andcommitted
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 84a84f7)
1 parent eada760 commit f57900a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

nova/tests/unit/compute/test_compute_mgr.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7615,6 +7615,24 @@ def test_validate_instance_group_policy_handles_hint_list(self, mock_get):
76157615
instance, hints)
76167616
mock_get.assert_called_once_with(self.context, uuids.group_hint)
76177617

7618+
@mock.patch('nova.objects.InstanceGroup.get_by_hint')
7619+
def test_validate_instance_group_policy_deleted_group(self, mock_get):
7620+
"""Tests that _validate_instance_group_policy handles the case
7621+
where the scheduler hint has a group but that group has been deleted.
7622+
This tests is a reproducer for bug: #1890244
7623+
"""
7624+
instance = objects.Instance(uuid=uuids.instance)
7625+
hints = {'group': [uuids.group_hint]}
7626+
mock_get.side_effect = exception.InstanceGroupNotFound(
7627+
group_uuid=uuids.group_hint
7628+
)
7629+
# FIXME(sean-k-mooney): this should not leak the exception
7630+
self.assertRaises(
7631+
exception.InstanceGroupNotFound,
7632+
self.compute._validate_instance_group_policy, self.context,
7633+
instance, hints)
7634+
mock_get.assert_called_once_with(self.context, uuids.group_hint)
7635+
76187636
@mock.patch('nova.objects.InstanceGroup.get_by_uuid')
76197637
@mock.patch('nova.objects.InstanceList.get_uuids_by_host')
76207638
@mock.patch('nova.objects.InstanceGroup.get_by_hint')

0 commit comments

Comments
 (0)