Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add e2e test on neuro run --volume=ALL with shared resources #22

Closed
atemate opened this issue Aug 22, 2019 · 1 comment
Closed

Add e2e test on neuro run --volume=ALL with shared resources #22

atemate opened this issue Aug 22, 2019 · 1 comment

Comments

@atemate
Copy link
Contributor

atemate commented Aug 22, 2019

Once "Automount: neuro run --volume=ALL" is merged, we need to add a e2e test which checks that all storage resources shared with the user (including files) were mounted to /var/storage.

How to use two helpers set up to 2 different users:
https://github.com/neuromation/platform-e2e/blob/648020935980e91ac8a9aa6f56d51350666ebb26/tests/test_network.py#L82

Draft for the test:


@pytest.mark.e2e
def test_job_run_volume_all(helper: Helper, another_helper: Helper, data: Tuple[str, str], request: Any) -> None:
    helper_1 = helper
    helper_2 = another_helper

    path_1 = f"{uuid4()}/"  # read
    path_2 = f"{path_1}/{uuid4()}.txt"  # write
    path_3 = f"path/to/{uuid4()}/"  # manage

    request.addfinalizer(lambda: remove_storage_obj(helper_1, path_1, recursive=True))
    request.addfinalizer(lambda: remove_storage_obj(helper_1, path_3))

    local_temp_file, checksum = data
    helper_1.run_cli(["storage", "mkdir", f"storage:{path_1}"])
    helper_1.run_cli(["storage", "cp", local_temp_file, f"storage:{path_1}"])
    helper_1.run_cli(["storage", "mkdir", "-p", f"storage:{path_3}"])

    shared = [
        (f"storage://{helper_1.username}/{path_1}", "read"),
        (f"storage://{helper_1.username}/{path_2}", "write"),
        (f"storage://{helper_1.username}/{path_3}", "manage"),
    ]
    for uri, action in shared:
        request.addfinalizer(lambda: revoke(helper_1, uri, helper_2.username))
        helper_1.run_cli(["acl", "grant", uri, helper_2.username, action])

    received = helper_2.run_cli(["acl", "list"])
    assert all(f"{uri} {action}" in received for uri, action in shared)

    cmd = " && ".join([
        f"[ -d /var/storage/{path_1} ]",
        f"[ -d /var/storage/{path_2} ]",
        f"[ -d /var/storage/{path_3} ]",
        "[ -d /var/storage/home ]",
        "[ $NP_STORAGE_ROOT_MOUNTPOINT == /var/storage ]",
    ])
    command = f"bash -c '{cmd}'"

    # first, run without --volume=HOME
    helper_2.run_job_and_wait_state(
        image=UBUNTU_IMAGE_NAME, command=command, wait_state=JobStatus.FAILED
    )

    # then, run with --volume=HOME
    helper_2.run_job_and_wait_state(
        image=UBUNTU_IMAGE_NAME,
        command=command,
        params=("--volume", "ALL"),
        wait_state=JobStatus.SUCCEEDED,
    )


def remove_storage_obj(helper: Helper, path_uri: str, recursive: bool = False) -> None:
    try:
        args = recursive and ["--recursive"] or []
        helper.run_cli(["storage", "rm", path_uri] + args)
    except subprocess.CalledProcessError:  # let's ignore any possible errors
        pass

@github-actions
Copy link

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 14 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants