Skip to content

Commit 84a84f7

Browse files
committed
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
1 parent ebe0883 commit 84a84f7

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
@@ -7590,6 +7590,24 @@ def test_validate_instance_group_policy_handles_hint_list(self, mock_get):
75907590
instance, hints)
75917591
mock_get.assert_called_once_with(self.context, uuids.group_hint)
75927592

7593+
@mock.patch('nova.objects.InstanceGroup.get_by_hint')
7594+
def test_validate_instance_group_policy_deleted_group(self, mock_get):
7595+
"""Tests that _validate_instance_group_policy handles the case
7596+
where the scheduler hint has a group but that group has been deleted.
7597+
This tests is a reproducer for bug: #1890244
7598+
"""
7599+
instance = objects.Instance(uuid=uuids.instance)
7600+
hints = {'group': [uuids.group_hint]}
7601+
mock_get.side_effect = exception.InstanceGroupNotFound(
7602+
group_uuid=uuids.group_hint
7603+
)
7604+
# FIXME(sean-k-mooney): this should not leak the exception
7605+
self.assertRaises(
7606+
exception.InstanceGroupNotFound,
7607+
self.compute._validate_instance_group_policy, self.context,
7608+
instance, hints)
7609+
mock_get.assert_called_once_with(self.context, uuids.group_hint)
7610+
75937611
@mock.patch('nova.objects.InstanceGroup.get_by_uuid')
75947612
@mock.patch('nova.objects.InstanceList.get_uuids_by_host')
75957613
@mock.patch('nova.objects.InstanceGroup.get_by_hint')

0 commit comments

Comments
 (0)