'spawn failure test.
Make sure that when there is a spawning problem,
the instance goes to ERROR state, cleaning the task state.'

def test_run_instance_spawn_fail(self):

    def fake(*args, **kwargs):
        raise test.TestingException()
    self.stub_out('nova.virt.fake.FakeDriver.spawn', fake)
    instance = self._create_fake_instance_obj()
    self.compute.build_and_run_instance(self.context, instance=instance, request_spec={}, filter_properties={}, requested_networks=[], injected_files=None, admin_password=None, block_device_mapping=[], image={}, node=None)
    self._assert_state({'vm_state': vm_states.ERROR, 'task_state': None})
    self.compute.periodic_tasks(context.get_admin_context())
    self._assert_state({'vm_state': vm_states.ERROR, 'task_state': None})
