'If an extra volume is created for a dataset, that volume isn\'t used.
.. note:
This test will be flaky if flocker doesn\'t correctly ignore extra
volumes that claim to belong to a dataset, since the dataset picked
will be random.'

@skip_backend(unsupported={backends.GCE}, reason='The    GCE    backend    does    not    let    you    create    two    volumes    with    the    same    dataset    id.    When    this    test    is    run    with    GCE    the    test    fails    to    create    the    extra    volume,    and    we    do    not    test    the    functionality    this    test    was    designed    to    test.')
@require_cluster(2)
def test_extra_volume(self, cluster):

    api = get_backend_api(cluster.cluster_uuid)
    wait_for_dataset = create_dataset(self, cluster)
    created_volume = []
    def create_extra(dataset):
        volume = api.create_volume(dataset.dataset_id, size=get_default_volume_size())
        created_volume.append(volume)
        return dataset
    wait_for_extra_volume = wait_for_dataset.addCallback(create_extra)
    def move_dataset(dataset):
        dataset_moving = cluster.client.move_dataset(UUID(cluster.nodes[1].uuid), dataset.dataset_id)
        moved_dataset = dataset.set(primary=UUID(cluster.nodes[1].uuid))
        dataset_moving.addCallback((lambda dataset: cluster.wait_for_dataset(moved_dataset)))
        return dataset_moving
    wait_for_move = wait_for_extra_volume.addCallback(move_dataset)
    def check_attached(dataset):
        blockdevice_id = created_volume[0].blockdevice_id
        [volume] = [volume for volume in api.list_volumes() if (volume.blockdevice_id == blockdevice_id)]
        self.assertEqual(volume.attached_to, None)
    return wait_for_move.addCallback(check_attached)
    return wait_for_dataset
