def migration_rollback_test(clients, volume_name, base_image=""):  # NOQA
    client = get_random_client(clients)
    hosts = clients.keys()
    host1 = hosts[0]
    host2 = hosts[1]

    volume = client.create_volume(name=volume_name,
                                  size=SIZE,
                                  numberOfReplicas=REPLICA_COUNT,
                                  baseImage=base_image)
    volume = common.wait_for_volume_detached(client, volume_name)

    volume.attach(hostId=host1)
    volume = common.wait_for_volume_healthy(client, volume_name)

    volume = volume.migrationStart(nodeId=host2)
    attached_nodes = get_volume_attached_nodes(volume)
    assert host1 in attached_nodes
    assert volume["migrationNodeID"] == host2

    volume = common.wait_for_volume_migration_ready(client, volume_name)
    volume = volume.migrationRollback()
    volume = common.wait_for_volume_migration_node(client, volume_name, host1)
    assert volume["migrationNodeID"] == ""

    volume = volume.detach()
    volume = common.wait_for_volume_detached(client, volume_name)
    client.delete(volume)

    wait_for_volume_delete(client, volume_name)
def migration_confirm_test(clients, volume_name, base_image=""):  # NOQA
    client = get_random_client(clients)
    hosts = clients.keys()
    host1 = hosts[0]
    host2 = hosts[1]

    volume = client.create_volume(name=volume_name,
                                  size=SIZE,
                                  numberOfReplicas=REPLICA_COUNT,
                                  baseImage=base_image)
    volume = common.wait_for_volume_detached(client, volume_name)

    volume.attach(hostId=host1)
    volume = common.wait_for_volume_healthy(client, volume_name)

    volume = volume.migrationStart(nodeId=host2)
    attached_nodes = get_volume_attached_nodes(volume)
    assert host1 in attached_nodes
    assert volume["migrationNodeID"] == host2
    with pytest.raises(Exception) as e:
        volume.migrationConfirm()
    assert "migration is not ready" in str(e.value)

    volume = common.wait_for_volume_migration_ready(client, volume_name)
    volume = volume.migrationConfirm()
    volume = common.wait_for_volume_migration_node(client, volume_name, host2)
    assert volume["migrationNodeID"] == ""

    volume = volume.detach()
    volume = common.wait_for_volume_detached(client, volume_name)
    client.delete(volume)

    wait_for_volume_delete(client, volume_name)
def test_volume_multinode(clients):  # NOQA
    hosts = clients.keys()

    volume = clients[hosts[0]].create_volume(name=VOLUME_NAME,
                                             size=SIZE,
                                             numberOfReplicas=2)
    volume = wait_for_volume_state(clients[hosts[0]], VOLUME_NAME, "detached")

    for host_id in hosts:
        volume = volume.attach(hostId=host_id)
        volume = wait_for_volume_state(clients[hosts[1]], VOLUME_NAME,
                                       "healthy")
        assert volume["state"] == "healthy"
        assert volume["controller"]["hostId"] == host_id
        volume = volume.detach()
        volume = wait_for_volume_state(clients[hosts[2]], VOLUME_NAME,
                                       "detached")

    volume = volume.attach(hostId=hosts[0])
    volume = wait_for_volume_state(clients[hosts[1]], VOLUME_NAME, "healthy")
    assert volume["state"] == "healthy"
    assert volume["controller"]["hostId"] == hosts[0]

    snapshot_test(clients[hosts[1]])
    backup_test(clients[hosts[2]], hosts[2])

    clients[hosts[0]].delete(volume)
    wait_for_volume_delete(clients[hosts[1]], VOLUME_NAME)

    volumes = clients[hosts[2]].list_volume()
    assert len(volumes) == 0
def migration_rollback_test(clients, volume_name, base_image=""):  # NOQA
    client = get_random_client(clients)
    hosts = clients.keys()
    host1 = hosts[0]
    host2 = hosts[1]

    volume = client.create_volume(name=volume_name, size=SIZE,
                                  numberOfReplicas=REPLICA_COUNT,
                                  baseImage=base_image)
    volume = common.wait_for_volume_detached(client, volume_name)

    volume.attach(hostId=host1)
    volume = common.wait_for_volume_healthy(client, volume_name)

    volume = volume.migrationStart(nodeId=host2)
    attached_nodes = get_volume_attached_nodes(volume)
    assert host1 in attached_nodes
    assert volume["migrationNodeID"] == host2

    volume = common.wait_for_volume_migration_ready(client, volume_name)
    volume = volume.migrationRollback()
    volume = common.wait_for_volume_migration_node(client, volume_name, host1)
    assert volume["migrationNodeID"] == ""

    volume = volume.detach()
    volume = common.wait_for_volume_detached(client, volume_name)
    client.delete(volume)

    wait_for_volume_delete(client, volume_name)
def migration_confirm_test(clients, volume_name, base_image=""):  # NOQA
    client = get_random_client(clients)
    hosts = clients.keys()
    host1 = hosts[0]
    host2 = hosts[1]

    volume = client.create_volume(name=volume_name, size=SIZE,
                                  numberOfReplicas=REPLICA_COUNT,
                                  baseImage=base_image)
    volume = common.wait_for_volume_detached(client, volume_name)

    volume.attach(hostId=host1)
    volume = common.wait_for_volume_healthy(client, volume_name)

    volume = volume.migrationStart(nodeId=host2)
    attached_nodes = get_volume_attached_nodes(volume)
    assert host1 in attached_nodes
    assert volume["migrationNodeID"] == host2
    with pytest.raises(Exception) as e:
        volume.migrationConfirm()
    assert "migration is not ready" in str(e.value)

    volume = common.wait_for_volume_migration_ready(client, volume_name)
    volume = volume.migrationConfirm()
    volume = common.wait_for_volume_migration_node(client,
                                                   volume_name,
                                                   host2)
    assert volume["migrationNodeID"] == ""

    volume = volume.detach()
    volume = common.wait_for_volume_detached(client, volume_name)
    client.delete(volume)

    wait_for_volume_delete(client, volume_name)
Beispiel #6
0
def test_volume_multinode(clients, volume_name):  # NOQA
    hosts = clients.keys()

    volume = get_random_client(clients).create_volume(name=volume_name,
                                                      size=SIZE,
                                                      numberOfReplicas=2)
    volume = common.wait_for_volume_detached(get_random_client(clients),
                                             volume_name)

    for host_id in hosts:
        volume = volume.attach(hostId=host_id)
        volume = common.wait_for_volume_healthy(get_random_client(clients),
                                                volume_name)
        assert volume["controller"]["hostId"] == host_id
        volume = volume.detach()
        volume = common.wait_for_volume_detached(get_random_client(clients),
                                                 volume_name)

    get_random_client(clients).delete(volume)
    wait_for_volume_delete(get_random_client(clients), volume_name)

    volumes = get_random_client(clients).list_volume()
    assert len(volumes) == 0