Exemple #1
0
def image_file():
    name = "/tmp/ms0-disk0.img"
    run_cmd(f"rm -f '{name}'", True)
    run_cmd(f"truncate -s 64M '{name}'", True)
    yield name
    run_cmd(f"rm -f '{name}'", True)
def start_io(get_nvme_client):
    devs = get_nvme_client
    job = Fio("job1", "randwrite", devs[0]).build()
    run_cmd(job)
Exemple #3
0
def create_temp_files(containers):
    "Create temp files for each run so we start out clean."
    for name in containers.keys():
        run_cmd(f"rm -f /tmp/{name}.img", True)
    for name in containers.keys():
        run_cmd(f"truncate -s 1G /tmp/{name}.img", True)
Exemple #4
0
def create_temp_file(pool_file):
    run_cmd("rm -f {}".format(pool_file))
    run_cmd("truncate -s 3G {}".format(pool_file), True)
    yield
    run_cmd("rm -f {}".format(pool_file))
Exemple #5
0
def test_nexus_preempt_key(
    create_nexus_v2,
    create_nexus_2_v2,
    nexus_name,
    nexus_uuid,
    mayastors,
    resv_key_2,
):
    """Create a nexus on ms3 and ms0, with the latter preempting the NVMe
    reservation key registered by ms3, verify that ms3 is no longer registered.
    Verify that writes succeed via the nexus on ms0 but not ms3."""

    NEXUS_UUID, _ = nexus_uuid

    list = mayastors.get("ms3").nexus_list_v2()
    nexus = next(n for n in list if n.name == nexus_name)
    assert nexus.uuid == NEXUS_UUID
    child_uri = nexus.children[0].uri
    assert nexus.state == pb.NEXUS_ONLINE
    assert nexus.children[0].state == pb.CHILD_ONLINE
    assert nexus.children[1].state == pb.CHILD_ONLINE

    dev = nvme_connect(child_uri)
    try:
        report = nvme_resv_report(dev)
        print(report)

        assert (report["rtype"] == 5
                ), "should have write exclusive, all registrants reservation"
        assert report["regctl"] == 1, "should have 1 registered controller"
        assert report[
            "ptpls"] == 0, "should have Persist Through Power Loss State of 0"
        assert (report["regctlext"][0]["cntlid"] == 0xFFFF
                ), "should have dynamic controller ID"

        # reservation status reserved
        assert (report["regctlext"][0]["rcsts"] & 0x1) == 1
        assert report["regctlext"][0]["rkey"] == resv_key_2

    finally:
        nvme_disconnect(child_uri)

    # verify write with nexus on ms0
    uri = create_nexus_2_v2
    dev = nvme_connect(uri)
    job = "sudo dd if=/dev/urandom of={0} bs=512 count=1".format(dev)

    try:
        run_cmd(job)

    finally:
        nvme_disconnect(uri)

    list = mayastors.get("ms0").nexus_list_v2()
    nexus = next(n for n in list if n.name == nexus_name)
    assert nexus.state == pb.NEXUS_ONLINE
    assert nexus.children[0].state == pb.CHILD_ONLINE
    assert nexus.children[1].state == pb.CHILD_ONLINE

    # verify write error with nexus on ms3
    uri = create_nexus_v2
    dev = nvme_connect(uri)
    job = "sudo dd if=/dev/urandom of={0} bs=512 count=1".format(dev)

    try:
        run_cmd(job)

    finally:
        nvme_disconnect(uri)

    list = mayastors.get("ms3").nexus_list_v2()
    nexus = next(n for n in list if n.name == nexus_name)
    assert nexus.state == pb.NEXUS_FAULTED
    assert nexus.children[0].state == pb.CHILD_FAULTED
    assert nexus.children[1].state == pb.CHILD_FAULTED