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

def test_run_instance_setup_block_device_mapping_fail(self):

    def fake(*args, **kwargs):
        raise exception.InvalidBDM()
    self.stub_out('nova.compute.manager.ComputeManager._prep_block_device', fake)
    instance = self._create_fake_instance_obj()
    self.compute.build_and_run_instance(self.context, instance=instance, image={}, request_spec={}, block_device_mapping=[], filter_properties={}, requested_networks=[], injected_files=None, admin_password=None, 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})
