Esempio n. 1
0
def init(create_pool_disk_images):
    # Shorten the reconcile periods and cache period to speed up the tests.
    Deployer.start_with_args(
        [
            "-j",
            "-m=2",
            "-w=10s",
            "--reconcile-idle-period=500ms",
            "--reconcile-period=500ms",
            "--cache-period=1s",
        ]
    )

    # Create pools
    ApiClient.pools_api().put_node_pool(
        MAYASTOR_1,
        POOL1_UUID,
        CreatePoolBody(["aio:///host/tmp/{}".format(POOL_DISK1)]),
    )
    ApiClient.pools_api().put_node_pool(
        MAYASTOR_2,
        POOL2_UUID,
        CreatePoolBody(["aio:///host/tmp/{}".format(POOL_DISK2)]),
    )

    # Create and publish a volume on node 1
    request = CreateVolumeBody(VolumePolicy(False), NUM_VOLUME_REPLICAS, VOLUME_SIZE)
    ApiClient.volumes_api().put_volume(VOLUME_UUID, request)
    ApiClient.volumes_api().put_volume_target(VOLUME_UUID, MAYASTOR_1, Protocol("nvmf"))

    yield
    Deployer.stop()
def a_volume_object_representing_the_volume_should_be_returned(volume_ctx):
    """a volume object representing the volume should be returned."""
    expected_spec = VolumeSpec(
        1,
        VOLUME_SIZE,
        SpecStatus("Created"),
        VOLUME_UUID,
        VolumePolicy(False),
    )

    volume = volume_ctx[VOLUME_CTX_KEY]
    assert str(volume.spec) == str(expected_spec)

    # The key for the replica topology is the replica UUID. This is assigned at replica creation
    # time, so get the replica UUID from the returned volume object, and use this as the key of
    # the expected replica topology.
    expected_replica_toplogy = {}
    for key, value in volume.state.replica_topology.items():
        expected_replica_toplogy[key] = ReplicaTopology(ReplicaState("Online"),
                                                        node="mayastor-1",
                                                        pool=POOL_UUID)
    expected_state = VolumeState(
        VOLUME_SIZE,
        VolumeStatus("Online"),
        VOLUME_UUID,
        expected_replica_toplogy,
    )
    assert str(volume.state) == str(expected_state)
def volume_creation_should_succeed_with_a_returned_volume_object(
        create_request):
    """volume creation should succeed with a returned volume object."""
    expected_spec = VolumeSpec(
        1,
        VOLUME_SIZE,
        SpecStatus("Created"),
        VOLUME_UUID,
        VolumePolicy(False),
    )

    # Check the volume object returned is as expected
    request = create_request[CREATE_REQUEST_KEY]
    volume = ApiClient.volumes_api().put_volume(VOLUME_UUID, request)
    assert str(volume.spec) == str(expected_spec)

    # The key for the replica topology is the replica UUID. This is assigned at replica creation
    # time, so get the replica UUID from the returned volume object, and use this as the key of
    # the expected replica topology.
    expected_replica_toplogy = {}
    for key, value in volume.state.replica_topology.items():
        expected_replica_toplogy[key] = ReplicaTopology(ReplicaState("Online"),
                                                        node="mayastor-1",
                                                        pool=POOL_UUID)
    expected_state = VolumeState(
        VOLUME_SIZE,
        VolumeStatus("Online"),
        VOLUME_UUID,
        expected_replica_toplogy,
    )
    assert str(volume.state) == str(expected_state)
def init():
    Deployer.start(1)
    ApiClient.pools_api().put_node_pool(
        NODE_NAME, POOL_UUID, CreatePoolBody(["malloc:///disk?size_mb=50"]))
    ApiClient.volumes_api().put_volume(
        VOLUME_UUID, CreateVolumeBody(VolumePolicy(False), 1, VOLUME_SIZE))
    yield
    Deployer.stop()
def a_request_for_a_volume_without_pool_topology(create_request):
    """a request for a volume without pool topology."""
    request = CreateVolumeBody(
        VolumePolicy(False),
        NUM_VOLUME_REPLICAS,
        VOLUME_SIZE,
    )
    create_request[CREATE_REQUEST_KEY] = request
def a_request_for_a_volume_with_topology_different_from_pools(create_request):
    """a request for a volume with topology different from pools."""
    request = CreateVolumeBody(
        VolumePolicy(False),
        NUM_VOLUME_REPLICAS,
        VOLUME_SIZE,
        topology=Topology(pool_topology=PoolTopology(labelled=LabelledTopology(
            exclusion={}, inclusion={"fake-label-key": "fake-label-value"}))),
    )
    create_request[CREATE_REQUEST_KEY] = request
def a_request_for_a_volume_with_topology_same_as_pool_labels(create_request):
    """a request for a volume with topology same as pool labels."""
    request = CreateVolumeBody(
        VolumePolicy(False),
        NUM_VOLUME_REPLICAS,
        VOLUME_SIZE,
        topology=Topology(pool_topology=PoolTopology(labelled=LabelledTopology(
            exclusion={}, inclusion={"openebs.io/created-by": "msp-operator"
                                     }))),
    )
    create_request[CREATE_REQUEST_KEY] = request
def a_published_selfhealing_volume():
    """a published self-healing volume."""
    request = CreateVolumeBody(
        VolumePolicy(True),
        NUM_VOLUME_REPLICAS,
        VOLUME_SIZE,
        topology=Topology(pool_topology=PoolTopology(labelled=LabelledTopology(
            exclusion={}, inclusion={"node": MAYASTOR_2}))),
    )
    ApiClient.volumes_api().put_volume(VOLUME_UUID, request)
    ApiClient.volumes_api().put_volume_target(VOLUME_UUID, MAYASTOR_1,
                                              Protocol("nvmf"))
def an_existing_published_volume_without_pool_topology():
    """an existing published volume without pool topology"""
    ApiClient.volumes_api().put_volume(
        VOLUME_UUID,
        CreateVolumeBody(
            VolumePolicy(False),
            1,
            VOLUME_SIZE,
        ),
    )
    # Publish volume so that there is a nexus to add a replica to.
    ApiClient.volumes_api().put_volume_target(VOLUME_UUID, NODE_1_NAME,
                                              Protocol("nvmf"))
Esempio n. 10
0
def init():
    Deployer.start(2)
    ApiClient.pools_api().put_node_pool(
        NODE1_NAME, POOL1_UUID, CreatePoolBody(["malloc:///disk?size_mb=50"])
    )
    ApiClient.pools_api().put_node_pool(
        NODE2_NAME, POOL2_UUID, CreatePoolBody(["malloc:///disk?size_mb=50"])
    )
    ApiClient.volumes_api().put_volume(
        VOLUME_UUID, CreateVolumeBody(VolumePolicy(False), 2, 10485761)
    )
    yield
    Deployer.stop()
def volume_creation_should_succeed_with_a_returned_volume_object_without_pool_topology(
    create_request, ):
    """volume creation should succeed with a returned volume object without pool topology."""
    expected_spec = VolumeSpec(
        1,
        VOLUME_SIZE,
        SpecStatus("Created"),
        VOLUME_UUID,
        VolumePolicy(False),
    )

    # Check the volume object returned is as expected
    request = create_request[CREATE_REQUEST_KEY]
    volume = ApiClient.volumes_api().put_volume(VOLUME_UUID, request)
    assert str(volume.spec) == str(expected_spec)
    assert str(volume.state["status"]) == "Online"
def an_existing_published_volume_with_a_topology_not_matching_pool_labels():
    """an existing published volume with a topology not matching pool labels"""
    ApiClient.volumes_api().put_volume(
        VOLUME_UUID,
        CreateVolumeBody(
            VolumePolicy(False),
            1,
            VOLUME_SIZE,
            topology=Topology(pool_topology=PoolTopology(
                labelled=LabelledTopology(
                    exclusion={},
                    inclusion={"pool1-specific-key": "pool1-specific-value"},
                ))),
        ),
    )
    # Publish volume so that there is a nexus to add a replica to.
    ApiClient.volumes_api().put_volume_target(VOLUME_UUID, NODE_1_NAME,
                                              Protocol("nvmf"))
Esempio n. 13
0
def background():
    Deployer.start_with_args([
        "-j",
        "-m=3",
        "-w=10s",
        "--cache-period=1s",
        "--mayastor-env=NEXUS_NVMF_ANA_ENABLE=1,NEXUS_NVMF_RESV_ENABLE=1",
        "--agents-env=TEST_NEXUS_NVMF_ANA_ENABLE=1",
    ])
    ApiClient.pools_api().put_node_pool(
        POOL_NODE, POOL_UUID, CreatePoolBody(["malloc:///disk?size_mb=100"]))
    ApiClient.volumes_api().put_volume(
        VOLUME_UUID, CreateVolumeBody(VolumePolicy(False), 1, VOLUME_SIZE))
    volume = ApiClient.volumes_api().put_volume_target(VOLUME_UUID,
                                                       TARGET_NODE_1,
                                                       Protocol("nvmf"))
    yield volume
    Deployer.stop()
def volume_creation_should_succeed_with_a_returned_volume_object_with_topology(
    create_request, ):
    """volume creation should succeed with a returned volume object with topology."""
    expected_spec = VolumeSpec(
        1,
        VOLUME_SIZE,
        SpecStatus("Created"),
        VOLUME_UUID,
        VolumePolicy(False),
        topology=Topology(pool_topology=PoolTopology(labelled=LabelledTopology(
            exclusion={}, inclusion={"openebs.io/created-by": "msp-operator"
                                     }))),
    )

    # Check the volume object returned is as expected
    request = create_request[CREATE_REQUEST_KEY]
    volume = ApiClient.volumes_api().put_volume(VOLUME_UUID, request)
    assert str(volume.spec) == str(expected_spec)
    assert str(volume.state["status"]) == "Online"
def init_resources():
    ApiClient.pools_api().put_node_pool(
        NODE_1_NAME, POOL_1_UUID,
        CreatePoolBody(["malloc:///disk?size_mb=50"]))
    ApiClient.pools_api().put_node_pool(
        NODE_2_NAME, POOL_2_UUID,
        CreatePoolBody(["malloc:///disk?size_mb=50"]))
    ApiClient.volumes_api().put_volume(
        VOLUME_UUID,
        CreateVolumeBody(VolumePolicy(True), NUM_VOLUME_REPLICAS, VOLUME_SIZE),
    )
    ApiClient.pools_api().put_node_pool(
        NODE_3_NAME, POOL_3_UUID,
        CreatePoolBody(["malloc:///disk?size_mb=50"]))
    # Publish volume so that there is a nexus to add a replica to.
    volume = ApiClient.volumes_api().put_volume_target(VOLUME_UUID,
                                                       NODE_1_NAME,
                                                       Protocol("nvmf"))
    assert hasattr(volume.spec, "target")
    assert str(volume.spec.target.protocol) == str(Protocol("nvmf"))
def a_request_for_a_volume(create_request):
    """a request for a volume."""
    request = CreateVolumeBody(VolumePolicy(False), NUM_VOLUME_REPLICAS,
                               VOLUME_SIZE)
    create_request[CREATE_REQUEST_KEY] = request