Skip to content

Commit 00452a4

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Reproducer unit test for bug 1934094"
2 parents fb08313 + 78e10f5 commit 00452a4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

nova/tests/unit/compute/test_shelve.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,30 @@ def test_unshelve_with_resource_request_update_raises(
677677
self.context, self.compute.reportclient, [],
678678
{uuids.port_1: [uuids.rp1]})
679679

680+
def test_unshelve_spawn_fails_cleanup_instance_image_ref(self):
681+
"""Tests error handling when a instance fails to unshelve and makes
682+
sure to revert instance.image_ref to the initial value instead of
683+
keeping the one of shelved image
684+
https://bugs.launchpad.net/nova/+bug/1934094
685+
"""
686+
instance = self._create_fake_instance_obj()
687+
# TODO(pslestang) to uncomment when bug 1934094 is fixed
688+
# initial_image_ref = instance.image_ref
689+
690+
fake_spec = objects.RequestSpec()
691+
shelved_image = {'id': uuids.image_id}
692+
693+
with mock.patch.object(self.compute.driver, 'spawn',
694+
side_effect=test.TestingException('Spawn Failed')):
695+
self.assertRaises(test.TestingException,
696+
self.compute.unshelve_instance, self.context, instance,
697+
image=shelved_image, filter_properties={},
698+
node='fake-node', request_spec=fake_spec, accel_uuids=[])
699+
# FIXME(pslestang) Until bug 1934094 is fixed
700+
# The instance.image_ref is set to shelved_image.id but should be
701+
# equal to initial_image_ref
702+
self.assertEqual(instance.image_ref, shelved_image['id'])
703+
680704
@mock.patch.object(objects.InstanceList, 'get_by_filters')
681705
def test_shelved_poll_none_offloaded(self, mock_get_by_filters):
682706
# Test instances are not offloaded when shelved_offload_time is -1

0 commit comments

Comments
 (0)