@@ -1629,6 +1629,34 @@ def test_delete_instance_from_cell0(self, destroy_mock, notify_mock):
16291629 self .compute_api .notifier , self .context , instance )
16301630 destroy_mock .assert_called_once_with ()
16311631
1632+ def test_delete_instance_while_booting_host_changes_lookup_fails (self ):
1633+ """Tests the case where the instance become scheduled while being
1634+ destroyed but then the final lookup fails.
1635+ """
1636+ instance = self ._create_instance_obj ({'host' : None })
1637+
1638+ with test .nested (
1639+ mock .patch .object (
1640+ self .compute_api , '_delete_while_booting' ,
1641+ side_effect = exception .ObjectActionError (
1642+ action = "delete" , reason = "reason" )),
1643+ mock .patch .object (
1644+ self .compute_api , '_lookup_instance' ,
1645+ return_value = (None , None )),
1646+ mock .patch .object (self .compute_api , '_local_delete_cleanup' )
1647+ ) as (
1648+ _delete_while_booting , _lookup_instance , _local_delete_cleanup
1649+ ):
1650+ self .compute_api ._delete (
1651+ self .context , instance , 'delete' , mock .NonCallableMock ())
1652+
1653+ _delete_while_booting .assert_called_once_with (
1654+ self .context , instance )
1655+ _lookup_instance .assert_called_once_with (
1656+ self .context , instance .uuid )
1657+ _local_delete_cleanup .assert_called_once_with (
1658+ self .context , instance .uuid )
1659+
16321660 @mock .patch .object (context , 'target_cell' )
16331661 @mock .patch .object (objects .InstanceMapping , 'get_by_instance_uuid' ,
16341662 side_effect = exception .InstanceMappingNotFound (
0 commit comments