X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/bcad695db9a1c3aac5807faa153086e653107f51..f11933fe893204fc0378d83b25167eb14ba4a265:/sdk/cwl/tests/test_copy_deps.py diff --git a/sdk/cwl/tests/test_copy_deps.py b/sdk/cwl/tests/test_copy_deps.py index 853a7d3609..8ad735fddc 100644 --- a/sdk/cwl/tests/test_copy_deps.py +++ b/sdk/cwl/tests/test_copy_deps.py @@ -3,14 +3,46 @@ # SPDX-License-Identifier: Apache-2.0 import arvados +import arvados.collection import subprocess api = arvados.api() +workflow_content = """# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: Apache-2.0 + +cwlVersion: v1.2 +class: CommandLineTool +baseCommand: echo +inputs: + message: + type: File + inputBinding: + position: 1 + default: + class: File + location: keep:d7514270f356df848477718d58308cc4+94/b + +outputs: [] +""" + +expect_file = "19070-copy-deps.cwl" + +def check_workflow_content(uuid): + c = arvados.collection.Collection(uuid) + try: + with c.open(expect_file) as f: + content = f.read() + match = (content == workflow_content) + return match + except: + return False + def check_contents(group, wf_uuid): contents = api.groups().contents(uuid=group["uuid"]).execute() - if len(contents["items"]) != 3: - raise Exception("Expected 3 items in "+group["uuid"]+" was "+len(contents["items"])) + if len(contents["items"]) != 4: + raise Exception("Expected 4 items in "+group["uuid"]+" was "+str(len(contents["items"]))) found = False for c in contents["items"]: @@ -33,8 +65,15 @@ def check_contents(group, wf_uuid): if not found: raise Exception("Couldn't find jobs image dependency") + found = False + for c in contents["items"]: + if c["kind"] == "arvados#collection" and check_workflow_content(c["portable_data_hash"]): + found = True + if not found: + raise Exception("Couldn't find collection containing expected "+expect_file) + -def test_create(): +def check_create(): group = api.groups().create(body={"group": {"name": "test-19070-project-1", "group_class": "project"}}, ensure_unique_name=True).execute() try: contents = api.groups().contents(uuid=group["uuid"]).execute() @@ -42,7 +81,7 @@ def test_create(): raise Exception("Expected 0 items") # Create workflow, by default should also copy dependencies - cmd = ["arvados-cwl-runner", "--create-workflow", "--project-uuid", group["uuid"], "19070-copy-deps.cwl"] + cmd = ["arvados-cwl-runner", "--disable-git", "--create-workflow", "--project-uuid", group["uuid"], "19070-copy-deps.cwl"] print(" ".join(cmd)) wf_uuid = subprocess.check_output(cmd) wf_uuid = wf_uuid.decode("utf-8").strip() @@ -51,7 +90,7 @@ def test_create(): api.groups().delete(uuid=group["uuid"]).execute() -def test_update(): +def check_update(): group = api.groups().create(body={"group": {"name": "test-19070-project-2", "group_class": "project"}}, ensure_unique_name=True).execute() try: contents = api.groups().contents(uuid=group["uuid"]).execute() @@ -59,14 +98,14 @@ def test_update(): raise Exception("Expected 0 items") # Create workflow, but with --no-copy-deps it shouldn't copy anything - cmd = ["arvados-cwl-runner", "--no-copy-deps", "--create-workflow", "--project-uuid", group["uuid"], "19070-copy-deps.cwl"] + cmd = ["arvados-cwl-runner", "--disable-git", "--no-copy-deps", "--create-workflow", "--project-uuid", group["uuid"], "19070-copy-deps.cwl"] print(" ".join(cmd)) wf_uuid = subprocess.check_output(cmd) wf_uuid = wf_uuid.decode("utf-8").strip() contents = api.groups().contents(uuid=group["uuid"]).execute() - if len(contents["items"]) != 1: - raise Exception("Expected 1 items") + if len(contents["items"]) != 2: + raise Exception("Expected 2 items") found = False for c in contents["items"]: @@ -75,8 +114,15 @@ def test_update(): if not found: raise Exception("Couldn't find workflow") + found = False + for c in contents["items"]: + if c["kind"] == "arvados#collection" and check_workflow_content(c["portable_data_hash"]): + found = True + if not found: + raise Exception("Couldn't find collection containing expected "+expect_file) + # Updating by default will copy missing items - cmd = ["arvados-cwl-runner", "--update-workflow", wf_uuid, "19070-copy-deps.cwl"] + cmd = ["arvados-cwl-runner", "--disable-git", "--update-workflow", wf_uuid, "19070-copy-deps.cwl"] print(" ".join(cmd)) wf_uuid = subprocess.check_output(cmd) wf_uuid = wf_uuid.decode("utf-8").strip() @@ -86,7 +132,7 @@ def test_update(): api.groups().delete(uuid=group["uuid"]).execute() -def test_execute(): +def check_execute(): group = api.groups().create(body={"group": {"name": "test-19070-project-3", "group_class": "project"}}, ensure_unique_name=True).execute() try: contents = api.groups().contents(uuid=group["uuid"]).execute() @@ -94,7 +140,7 @@ def test_execute(): raise Exception("Expected 0 items") # Execute workflow, shouldn't copy anything. - cmd = ["arvados-cwl-runner", "--project-uuid", group["uuid"], "19070-copy-deps.cwl"] + cmd = ["arvados-cwl-runner", "--disable-git", "--project-uuid", group["uuid"], "19070-copy-deps.cwl"] print(" ".join(cmd)) wf_uuid = subprocess.check_output(cmd) wf_uuid = wf_uuid.decode("utf-8").strip() @@ -123,7 +169,7 @@ def test_execute(): raise Exception("Didn't expect to find jobs image dependency") # Execute workflow with --copy-deps - cmd = ["arvados-cwl-runner", "--project-uuid", group["uuid"], "--copy-deps", "19070-copy-deps.cwl"] + cmd = ["arvados-cwl-runner", "--disable-git", "--project-uuid", group["uuid"], "--copy-deps", "19070-copy-deps.cwl"] print(" ".join(cmd)) wf_uuid = subprocess.check_output(cmd) wf_uuid = wf_uuid.decode("utf-8").strip() @@ -147,6 +193,6 @@ def test_execute(): api.groups().delete(uuid=group["uuid"]).execute() if __name__ == '__main__': - test_create() - test_update() - test_execute() + check_create() + check_update() + check_execute()