'Make sure it is possible to  run and terminate instance with volume
attached'

def test_run_terminate_with_vol_attached(self):

    instance = self._create_fake_instance_obj()
    self.compute.build_and_run_instance(self.context, instance, {}, {}, {}, block_device_mapping=[])
    instances = db.instance_get_all(self.context)
    LOG.info('Running    instances:    %s', instances)
    self.assertEqual(len(instances), 1)
    def fake_check_availability_zone(*args, **kwargs):
        pass
    def fake_reserve_volume(*args, **kwargs):
        pass
    def fake_volume_get(self, context, volume_id):
        return {'id': volume_id, 'attach_status': 'attached', 'attachments': {instance.uuid: {'attachment_id': 'abc123'}}}
    def fake_terminate_connection(self, context, volume_id, connector):
        pass
    def fake_detach(self, context, volume_id, instance_uuid):
        pass
    bdms = []
    def fake_rpc_reserve_block_device_name(self, context, instance, device, volume_id, **kwargs):
        bdm = objects.BlockDeviceMapping(**{'context': context, 'source_type': 'volume', 'destination_type': 'volume', 'volume_id': uuids.volume_id, 'instance_uuid': instance['uuid'], 'device_name': '/dev/vdc'})
        bdm.create()
        bdms.append(bdm)
        return bdm
    self.stub_out('nova.volume.cinder.API.get', fake_volume_get)
    self.stub_out('nova.volume.cinder.API.check_availability_zone', fake_check_availability_zone)
    self.stub_out('nova.volume.cinder.API.reserve_volume', fake_reserve_volume)
    self.stub_out('nova.volume.cinder.API.terminate_connection', fake_terminate_connection)
    self.stub_out('nova.volume.cinder.API.detach', fake_detach)
    self.stub_out('nova.compute.rpcapi.ComputeAPI.reserve_block_device_name', fake_rpc_reserve_block_device_name)
    self.compute_api.attach_volume(self.context, instance, 1, '/dev/vdc')
    self.compute.terminate_instance(self.context, instance, bdms, [])
    instances = db.instance_get_all(self.context)
    LOG.info('After    terminating    instances:    %s', instances)
    self.assertEqual(len(instances), 0)
    bdms = db.block_device_mapping_get_all_by_instance(self.context, instance['uuid'])
    self.assertEqual(len(bdms), 0)
