@@ -1620,6 +1620,34 @@ def test_delete_instance_from_cell0(self, destroy_mock, notify_mock):
16201620 self .compute_api .notifier , self .context , instance )
16211621 destroy_mock .assert_called_once_with ()
16221622
1623+ def test_delete_instance_while_booting_host_changes_lookup_fails (self ):
1624+ """Tests the case where the instance become scheduled while being
1625+ destroyed but then the final lookup fails.
1626+ """
1627+ instance = self ._create_instance_obj ({'host' : None })
1628+
1629+ with test .nested (
1630+ mock .patch .object (
1631+ self .compute_api , '_delete_while_booting' ,
1632+ side_effect = exception .ObjectActionError (
1633+ action = "delete" , reason = "reason" )),
1634+ mock .patch .object (
1635+ self .compute_api , '_lookup_instance' ,
1636+ return_value = (None , None )),
1637+ mock .patch .object (self .compute_api , '_local_delete_cleanup' )
1638+ ) as (
1639+ _delete_while_booting , _lookup_instance , _local_delete_cleanup
1640+ ):
1641+ self .compute_api ._delete (
1642+ self .context , instance , 'delete' , mock .NonCallableMock ())
1643+
1644+ _delete_while_booting .assert_called_once_with (
1645+ self .context , instance )
1646+ _lookup_instance .assert_called_once_with (
1647+ self .context , instance .uuid )
1648+ _local_delete_cleanup .assert_called_once_with (
1649+ self .context , instance .uuid )
1650+
16231651 @mock .patch .object (context , 'target_cell' )
16241652 @mock .patch .object (objects .InstanceMapping , 'get_by_instance_uuid' ,
16251653 side_effect = exception .InstanceMappingNotFound (
0 commit comments