X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/9828e9218084856240fdeafa2d388d8bf322e655..09cbdc3074b3f1e69c9c537875146f6da0a6ed8f:/sdk/cwl/tests/test_submit.py diff --git a/sdk/cwl/tests/test_submit.py b/sdk/cwl/tests/test_submit.py index b44f6feb5d..dcbee726b6 100644 --- a/sdk/cwl/tests/test_submit.py +++ b/sdk/cwl/tests/test_submit.py @@ -290,13 +290,13 @@ def stubs(wfdetails=('submit_wf.cwl', None)): gitinfo_workflow["$graph"][0]["id"] = "file://%s/tests/wf/%s" % (cwd, wfpath) mocktool = mock.NonCallableMock(tool=gitinfo_workflow["$graph"][0], metadata=gitinfo_workflow) - git_info = arvados_cwl.executor.ArvCwlExecutor.get_git_info(mocktool) - expect_packed_workflow.update(git_info) + stubs.git_info = arvados_cwl.executor.ArvCwlExecutor.get_git_info(mocktool) + expect_packed_workflow.update(stubs.git_info) - git_props = {"arv:"+k.split("#", 1)[1]: v for k,v in git_info.items()} + stubs.git_props = {"arv:"+k.split("#", 1)[1]: v for k,v in stubs.git_info.items()} if wfname == wfpath: - container_name = "%s (%s)" % (wfpath, git_props["arv:gitDescribe"]) + container_name = "%s (%s)" % (wfpath, stubs.git_props["arv:gitDescribe"]) else: container_name = wfname @@ -359,7 +359,7 @@ def stubs(wfdetails=('submit_wf.cwl', None)): 'ram': (1024+256)*1024*1024 }, 'use_existing': False, - 'properties': git_props, + 'properties': stubs.git_props, 'secret_mounts': {} } @@ -393,7 +393,7 @@ class TestSubmit(unittest.TestCase): root_logger.handlers = handlers @mock.patch("time.sleep") - @stubs + @stubs() def test_submit_invalid_runner_ram(self, stubs, tm): exited = arvados_cwl.main( ["--submit", "--no-wait", "--debug", "--submit-runner-ram=-2048", @@ -402,7 +402,7 @@ class TestSubmit(unittest.TestCase): self.assertEqual(exited, 1) - @stubs + @stubs() def test_submit_container(self, stubs): exited = arvados_cwl.main( ["--submit", "--no-wait", "--api=containers", "--debug", @@ -414,7 +414,7 @@ class TestSubmit(unittest.TestCase): 'manifest_text': '. 979af1245a12a1fed634d4222473bfdc+16 0:16:blorp.txt\n', 'replication_desired': None, - 'name': 'submit_wf.cwl input (169f39d466a5438ac4a90e779bf750c7+53)', + 'name': 'submit_wf.cwl ('+ stubs.git_props["arv:gitDescribe"] +') input (169f39d466a5438ac4a90e779bf750c7+53)', }), ensure_unique_name=False), mock.call(body=JsonDiffMatcher({ 'manifest_text': @@ -432,7 +432,7 @@ class TestSubmit(unittest.TestCase): self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_container_tool(self, stubs): # test for issue #16139 exited = arvados_cwl.main( @@ -444,7 +444,7 @@ class TestSubmit(unittest.TestCase): stubs.expect_container_request_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_container_no_reuse(self, stubs): exited = arvados_cwl.main( ["--submit", "--no-wait", "--api=containers", "--debug", "--disable-reuse", @@ -457,7 +457,7 @@ class TestSubmit(unittest.TestCase): '--no-log-timestamps', '--disable-validate', '--disable-color', '--eval-timeout=20', '--thread-count=0', '--disable-reuse', "--collection-cache-size=256", - "--output-name=Output from workflow submit_wf.cwl", + '--output-name=Output from workflow submit_wf.cwl (%s)' % stubs.git_props["arv:gitDescribe"], '--debug', '--on-error=continue', '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json'] expect_container["use_existing"] = False @@ -496,7 +496,7 @@ class TestSubmit(unittest.TestCase): stubs.expect_container_request_uuid + '\n') - @stubs + @stubs() def test_submit_container_on_error(self, stubs): exited = arvados_cwl.main( ["--submit", "--no-wait", "--api=containers", "--debug", "--on-error=stop", @@ -508,7 +508,7 @@ class TestSubmit(unittest.TestCase): '--no-log-timestamps', '--disable-validate', '--disable-color', '--eval-timeout=20', '--thread-count=0', '--enable-reuse', "--collection-cache-size=256", - "--output-name=Output from workflow submit_wf.cwl", + '--output-name=Output from workflow submit_wf.cwl (%s)' % stubs.git_props["arv:gitDescribe"], '--debug', '--on-error=stop', '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json'] @@ -518,7 +518,7 @@ class TestSubmit(unittest.TestCase): stubs.expect_container_request_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_container_output_name(self, stubs): output_name = "test_output_name" @@ -542,7 +542,7 @@ class TestSubmit(unittest.TestCase): stubs.expect_container_request_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_storage_classes(self, stubs): exited = arvados_cwl.main( ["--debug", "--submit", "--no-wait", "--api=containers", "--storage-classes=foo", @@ -554,7 +554,7 @@ class TestSubmit(unittest.TestCase): '--no-log-timestamps', '--disable-validate', '--disable-color', '--eval-timeout=20', '--thread-count=0', '--enable-reuse', "--collection-cache-size=256", - '--output-name=Output from workflow submit_wf.cwl', + '--output-name=Output from workflow submit_wf.cwl (%s)' % stubs.git_props["arv:gitDescribe"], "--debug", "--storage-classes=foo", '--on-error=continue', '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json'] @@ -565,7 +565,7 @@ class TestSubmit(unittest.TestCase): stubs.expect_container_request_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_multiple_storage_classes(self, stubs): exited = arvados_cwl.main( ["--debug", "--submit", "--no-wait", "--api=containers", "--storage-classes=foo,bar", "--intermediate-storage-classes=baz", @@ -577,7 +577,7 @@ class TestSubmit(unittest.TestCase): '--no-log-timestamps', '--disable-validate', '--disable-color', '--eval-timeout=20', '--thread-count=0', '--enable-reuse', "--collection-cache-size=256", - "--output-name=Output from workflow submit_wf.cwl", + '--output-name=Output from workflow submit_wf.cwl (%s)' % stubs.git_props["arv:gitDescribe"], "--debug", "--storage-classes=foo,bar", "--intermediate-storage-classes=baz", '--on-error=continue', '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json'] @@ -591,7 +591,7 @@ class TestSubmit(unittest.TestCase): @mock.patch("cwltool.task_queue.TaskQueue") @mock.patch("arvados_cwl.arvworkflow.ArvadosWorkflow.job") @mock.patch("arvados_cwl.executor.ArvCwlExecutor.make_output_collection") - @stubs + @stubs() def test_storage_classes_correctly_propagate_to_make_output_collection(self, stubs, make_output, job, tq): final_output_c = arvados.collection.Collection() make_output.return_value = ({},final_output_c) @@ -602,17 +602,17 @@ class TestSubmit(unittest.TestCase): job.side_effect = set_final_output exited = arvados_cwl.main( - ["--debug", "--local", "--storage-classes=foo", + ["--debug", "--local", "--storage-classes=foo", "--disable-git", "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"], stubs.capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client) - make_output.assert_called_with(u'Output of submit_wf.cwl', ['foo'], '', {}, {"out": "zzzzz"}) + make_output.assert_called_with(u'Output from workflow submit_wf.cwl', ['foo'], '', {}, {"out": "zzzzz"}) self.assertEqual(exited, 0) @mock.patch("cwltool.task_queue.TaskQueue") @mock.patch("arvados_cwl.arvworkflow.ArvadosWorkflow.job") @mock.patch("arvados_cwl.executor.ArvCwlExecutor.make_output_collection") - @stubs + @stubs() def test_default_storage_classes_correctly_propagate_to_make_output_collection(self, stubs, make_output, job, tq): final_output_c = arvados.collection.Collection() make_output.return_value = ({},final_output_c) @@ -624,17 +624,17 @@ class TestSubmit(unittest.TestCase): job.side_effect = set_final_output exited = arvados_cwl.main( - ["--debug", "--local", + ["--debug", "--local", "--disable-git", "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"], stubs.capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client) - make_output.assert_called_with(u'Output of submit_wf.cwl', ['default'], '', {}, {"out": "zzzzz"}) + make_output.assert_called_with(u'Output from workflow submit_wf.cwl', ['default'], '', {}, {"out": "zzzzz"}) self.assertEqual(exited, 0) @mock.patch("cwltool.task_queue.TaskQueue") @mock.patch("arvados_cwl.arvworkflow.ArvadosWorkflow.job") @mock.patch("arvados_cwl.executor.ArvCwlExecutor.make_output_collection") - @stubs + @stubs() def test_storage_class_hint_to_make_output_collection(self, stubs, make_output, job, tq): final_output_c = arvados.collection.Collection() make_output.return_value = ({},final_output_c) @@ -645,14 +645,14 @@ class TestSubmit(unittest.TestCase): job.side_effect = set_final_output exited = arvados_cwl.main( - ["--debug", "--local", + ["--debug", "--local", "--disable-git", "tests/wf/submit_storage_class_wf.cwl", "tests/submit_test_job.json"], stubs.capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client) - make_output.assert_called_with(u'Output of submit_storage_class_wf.cwl', ['foo', 'bar'], '', {}, {"out": "zzzzz"}) + make_output.assert_called_with(u'Output from workflow submit_storage_class_wf.cwl', ['foo', 'bar'], '', {}, {"out": "zzzzz"}) self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_container_output_ttl(self, stubs): exited = arvados_cwl.main( ["--submit", "--no-wait", "--api=containers", "--debug", "--intermediate-output-ttl", "3600", @@ -664,7 +664,8 @@ class TestSubmit(unittest.TestCase): '--no-log-timestamps', '--disable-validate', '--disable-color', '--eval-timeout=20', '--thread-count=0', '--enable-reuse', "--collection-cache-size=256", - "--output-name=Output from workflow submit_wf.cwl", '--debug', + '--output-name=Output from workflow submit_wf.cwl (%s)' % stubs.git_props["arv:gitDescribe"], + '--debug', '--on-error=continue', "--intermediate-output-ttl=3600", '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json'] @@ -675,7 +676,7 @@ class TestSubmit(unittest.TestCase): stubs.expect_container_request_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_container_trash_intermediate(self, stubs): exited = arvados_cwl.main( ["--submit", "--no-wait", "--api=containers", "--debug", "--trash-intermediate", @@ -688,6 +689,7 @@ class TestSubmit(unittest.TestCase): '--no-log-timestamps', '--disable-validate', '--disable-color', '--eval-timeout=20', '--thread-count=0', '--enable-reuse', "--collection-cache-size=256", + '--output-name=Output from workflow submit_wf.cwl (%s)' % stubs.git_props["arv:gitDescribe"], '--debug', '--on-error=continue', "--trash-intermediate", '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json'] @@ -698,7 +700,7 @@ class TestSubmit(unittest.TestCase): stubs.expect_container_request_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_container_output_tags(self, stubs): output_tags = "tag0,tag1,tag2" @@ -712,7 +714,7 @@ class TestSubmit(unittest.TestCase): '--no-log-timestamps', '--disable-validate', '--disable-color', '--eval-timeout=20', '--thread-count=0', '--enable-reuse', "--collection-cache-size=256", - "--output-name=Output from workflow submit_wf.cwl", + '--output-name=Output from workflow submit_wf.cwl (%s)' % stubs.git_props["arv:gitDescribe"], "--output-tags="+output_tags, '--debug', '--on-error=continue', '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json'] @@ -722,7 +724,7 @@ class TestSubmit(unittest.TestCase): stubs.expect_container_request_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_container_runner_ram(self, stubs): exited = arvados_cwl.main( ["--submit", "--no-wait", "--api=containers", "--debug", "--submit-runner-ram=2048", @@ -740,7 +742,7 @@ class TestSubmit(unittest.TestCase): @mock.patch("arvados.collection.CollectionReader") @mock.patch("time.sleep") - @stubs + @stubs() def test_submit_file_keepref(self, stubs, tm, collectionReader): collectionReader().exists.return_value = True collectionReader().find.return_value = arvados.arvfile.ArvadosFile(mock.MagicMock(), "blorp.txt") @@ -752,7 +754,7 @@ class TestSubmit(unittest.TestCase): @mock.patch("arvados.collection.CollectionReader") @mock.patch("time.sleep") - @stubs + @stubs() def test_submit_keepref(self, stubs, tm, reader): with open("tests/wf/expect_arvworkflow.cwl") as f: reader().open().__enter__().read.return_value = f.read() @@ -813,13 +815,13 @@ class TestSubmit(unittest.TestCase): self.assertEqual(exited, 0) @mock.patch("time.sleep") - @stubs + @stubs() def test_submit_arvworkflow(self, stubs, tm): with open("tests/wf/expect_arvworkflow.cwl") as f: stubs.api.workflows().get().execute.return_value = {"definition": f.read(), "name": "a test workflow"} exited = arvados_cwl.main( - ["--submit", "--no-wait", "--api=containers", "--debug", + ["--submit", "--no-wait", "--api=containers", "--debug", "--disable-git", "962eh-7fd4e-gkbzl62qqtfig37", "-x", "XxX"], stubs.capture_stdout, sys.stderr, api_client=stubs.api) @@ -863,8 +865,7 @@ class TestSubmit(unittest.TestCase): 'requirements': [ { 'dockerPull': 'debian:buster-slim', - 'class': 'DockerRequirement', - "http://arvados.org/cwl#dockerCollectionPDH": "999999999999999999999999999999d4+99" + 'class': 'DockerRequirement' } ], 'id': '#submit_tool.cwl', @@ -888,8 +889,11 @@ class TestSubmit(unittest.TestCase): 'command': ['arvados-cwl-runner', '--local', '--api=containers', '--no-log-timestamps', '--disable-validate', '--disable-color', '--eval-timeout=20', '--thread-count=0', - '--enable-reuse', "--collection-cache-size=256", '--debug', '--on-error=continue', + '--enable-reuse', "--collection-cache-size=256", + "--output-name=Output from workflow a test workflow", + '--debug', '--on-error=continue', '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json'], + 'output_name': 'Output from workflow a test workflow', 'cwd': '/var/spool/cwl', 'runtime_constraints': { 'API': True, @@ -924,7 +928,7 @@ class TestSubmit(unittest.TestCase): stubs.expect_container_request_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_missing_input(self, stubs): exited = arvados_cwl.main( ["--submit", "--no-wait", "--api=containers", "--debug", @@ -938,7 +942,7 @@ class TestSubmit(unittest.TestCase): stubs.capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client) self.assertEqual(exited, 1) - @stubs + @stubs() def test_submit_container_project(self, stubs): project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz' stubs.api.groups().get().execute.return_value = {"group_class": "project"} @@ -953,7 +957,8 @@ class TestSubmit(unittest.TestCase): '--no-log-timestamps', '--disable-validate', '--disable-color', "--eval-timeout=20", "--thread-count=0", '--enable-reuse', "--collection-cache-size=256", - "--output-name=Output from workflow submit_wf.cwl", '--debug', + '--output-name=Output from workflow submit_wf.cwl (%s)' % stubs.git_props["arv:gitDescribe"], + '--debug', '--on-error=continue', '--project-uuid='+project_uuid, '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json'] @@ -964,7 +969,7 @@ class TestSubmit(unittest.TestCase): stubs.expect_container_request_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_container_eval_timeout(self, stubs): exited = arvados_cwl.main( ["--submit", "--no-wait", "--api=containers", "--debug", "--eval-timeout=60", @@ -976,6 +981,7 @@ class TestSubmit(unittest.TestCase): '--no-log-timestamps', '--disable-validate', '--disable-color', '--eval-timeout=60.0', '--thread-count=0', '--enable-reuse', "--collection-cache-size=256", + '--output-name=Output from workflow submit_wf.cwl (%s)' % stubs.git_props["arv:gitDescribe"], '--debug', '--on-error=continue', '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json'] @@ -985,7 +991,7 @@ class TestSubmit(unittest.TestCase): stubs.expect_container_request_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_container_collection_cache(self, stubs): exited = arvados_cwl.main( ["--submit", "--no-wait", "--api=containers", "--debug", "--collection-cache-size=500", @@ -997,6 +1003,7 @@ class TestSubmit(unittest.TestCase): '--no-log-timestamps', '--disable-validate', '--disable-color', '--eval-timeout=20', '--thread-count=0', '--enable-reuse', "--collection-cache-size=500", + '--output-name=Output from workflow submit_wf.cwl (%s)' % stubs.git_props["arv:gitDescribe"], '--debug', '--on-error=continue', '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json'] expect_container["runtime_constraints"]["ram"] = (1024+500)*1024*1024 @@ -1007,7 +1014,7 @@ class TestSubmit(unittest.TestCase): stubs.expect_container_request_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_container_thread_count(self, stubs): exited = arvados_cwl.main( ["--submit", "--no-wait", "--api=containers", "--debug", "--thread-count=20", @@ -1019,6 +1026,7 @@ class TestSubmit(unittest.TestCase): '--no-log-timestamps', '--disable-validate', '--disable-color', '--eval-timeout=20', '--thread-count=20', '--enable-reuse', "--collection-cache-size=256", + '--output-name=Output from workflow submit_wf.cwl (%s)' % stubs.git_props["arv:gitDescribe"], '--debug', '--on-error=continue', '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json'] @@ -1028,7 +1036,7 @@ class TestSubmit(unittest.TestCase): stubs.expect_container_request_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_container_runner_image(self, stubs): exited = arvados_cwl.main( ["--submit", "--no-wait", "--api=containers", "--debug", "--submit-runner-image=arvados/jobs:123", @@ -1044,7 +1052,7 @@ class TestSubmit(unittest.TestCase): stubs.expect_container_request_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_priority(self, stubs): exited = arvados_cwl.main( ["--submit", "--no-wait", "--api=containers", "--debug", "--priority=669", @@ -1148,13 +1156,16 @@ class TestSubmit(unittest.TestCase): arvados_cwl.runner.arvados_jobs_image(arvrunner, "arvados/jobs:"+arvados_cwl.__version__, arvrunner.runtimeContext)) - @stubs + @stubs() def test_submit_secrets(self, stubs): exited = arvados_cwl.main( ["--submit", "--no-wait", "--api=containers", "--debug", "tests/wf/secret_wf.cwl", "tests/secret_test_job.yml"], stubs.capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client) + stubs.git_props["arv:gitPath"] = "sdk/cwl/tests/wf/secret_wf.cwl" + stubs.git_info["http://arvados.org/cwl#gitPath"] = "sdk/cwl/tests/wf/secret_wf.cwl" + expect_container = { "command": [ "arvados-cwl-runner", @@ -1167,8 +1178,8 @@ class TestSubmit(unittest.TestCase): '--thread-count=0', "--enable-reuse", "--collection-cache-size=256", - '--output-name=Output from workflow secret_wf.cwl' - '--debug', + '--output-name=Output from workflow secret_wf.cwl (%s)' % stubs.git_props["arv:gitDescribe"], + "--debug", "--on-error=continue", "/var/lib/cwl/workflow.json#main", "/var/lib/cwl/cwl.input.json" @@ -1292,11 +1303,11 @@ class TestSubmit(unittest.TestCase): "path": "/var/spool/cwl/cwl.output.json" } }, - "name": "secret_wf.cwl", - "output_name": "Output from workflow secret_wf.cwl", + "name": "secret_wf.cwl (%s)" % stubs.git_props["arv:gitDescribe"], + "output_name": "Output from workflow secret_wf.cwl (%s)" % stubs.git_props["arv:gitDescribe"], "output_path": "/var/spool/cwl", "priority": 500, - "properties": {}, + "properties": stubs.git_props, "runtime_constraints": { "API": True, "ram": 1342177280, @@ -1312,13 +1323,15 @@ class TestSubmit(unittest.TestCase): "use_existing": False } + expect_container["mounts"]["/var/lib/cwl/workflow.json"]["content"].update(stubs.git_info) + stubs.api.container_requests().create.assert_called_with( body=JsonDiffMatcher(expect_container)) self.assertEqual(stubs.capture_stdout.getvalue(), stubs.expect_container_request_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_request_uuid(self, stubs): stubs.api._rootDesc["remoteHosts"]["zzzzz"] = "123" stubs.expect_container_request_uuid = "zzzzz-xvhdp-yyyyyyyyyyyyyyy" @@ -1340,7 +1353,7 @@ class TestSubmit(unittest.TestCase): stubs.expect_container_request_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_container_cluster_id(self, stubs): stubs.api._rootDesc["remoteHosts"]["zbbbb"] = "123" @@ -1357,7 +1370,7 @@ class TestSubmit(unittest.TestCase): stubs.expect_container_request_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_validate_cluster_id(self, stubs): stubs.api._rootDesc["remoteHosts"]["zbbbb"] = "123" exited = arvados_cwl.main( @@ -1366,7 +1379,7 @@ class TestSubmit(unittest.TestCase): stubs.capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client) self.assertEqual(exited, 1) - @stubs + @stubs() def test_submit_validate_project_uuid(self, stubs): # Fails with bad cluster prefix exited = arvados_cwl.main( @@ -1392,7 +1405,7 @@ class TestSubmit(unittest.TestCase): @mock.patch("arvados.collection.CollectionReader") - @stubs + @stubs() def test_submit_uuid_inputs(self, stubs, collectionReader): collectionReader().exists.return_value = True collectionReader().find.return_value = arvados.arvfile.ArvadosFile(mock.MagicMock(), "file1.txt") @@ -1427,7 +1440,7 @@ class TestSubmit(unittest.TestCase): stubs.expect_container_request_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_mismatched_uuid_inputs(self, stubs): def list_side_effect(**kwargs): m = mock.MagicMock() @@ -1460,7 +1473,7 @@ class TestSubmit(unittest.TestCase): cwltool_logger.removeHandler(stderr_logger) @mock.patch("arvados.collection.CollectionReader") - @stubs + @stubs() def test_submit_unknown_uuid_inputs(self, stubs, collectionReader): collectionReader().find.return_value = arvados.arvfile.ArvadosFile(mock.MagicMock(), "file1.txt") capture_stderr = StringIO() @@ -1528,7 +1541,7 @@ class TestSubmit(unittest.TestCase): self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_enable_preemptible(self, stubs): exited = arvados_cwl.main( ["--submit", "--no-wait", "--api=containers", "--debug", "--enable-preemptible", @@ -1537,11 +1550,13 @@ class TestSubmit(unittest.TestCase): expect_container = copy.deepcopy(stubs.expect_container_spec) expect_container['command'] = ['arvados-cwl-runner', '--local', '--api=containers', - '--no-log-timestamps', '--disable-validate', '--disable-color', - '--eval-timeout=20', '--thread-count=0', - '--enable-reuse', "--collection-cache-size=256", '--debug', '--on-error=continue', + '--no-log-timestamps', '--disable-validate', '--disable-color', + '--eval-timeout=20', '--thread-count=0', + '--enable-reuse', "--collection-cache-size=256", + '--output-name=Output from workflow submit_wf.cwl (%s)' % stubs.git_props["arv:gitDescribe"], + '--debug', '--on-error=continue', '--enable-preemptible', - '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json'] + '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json'] stubs.api.container_requests().create.assert_called_with( body=JsonDiffMatcher(expect_container)) @@ -1549,7 +1564,7 @@ class TestSubmit(unittest.TestCase): stubs.expect_container_request_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_submit_disable_preemptible(self, stubs): exited = arvados_cwl.main( ["--submit", "--no-wait", "--api=containers", "--debug", "--disable-preemptible", @@ -1558,11 +1573,57 @@ class TestSubmit(unittest.TestCase): expect_container = copy.deepcopy(stubs.expect_container_spec) expect_container['command'] = ['arvados-cwl-runner', '--local', '--api=containers', - '--no-log-timestamps', '--disable-validate', '--disable-color', - '--eval-timeout=20', '--thread-count=0', - '--enable-reuse', "--collection-cache-size=256", '--debug', '--on-error=continue', + '--no-log-timestamps', '--disable-validate', '--disable-color', + '--eval-timeout=20', '--thread-count=0', + '--enable-reuse', "--collection-cache-size=256", + '--output-name=Output from workflow submit_wf.cwl (%s)' % stubs.git_props["arv:gitDescribe"], + '--debug', '--on-error=continue', '--disable-preemptible', - '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json'] + '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json'] + + stubs.api.container_requests().create.assert_called_with( + body=JsonDiffMatcher(expect_container)) + self.assertEqual(stubs.capture_stdout.getvalue(), + stubs.expect_container_request_uuid + '\n') + self.assertEqual(exited, 0) + + @stubs() + def test_submit_container_prefer_cached_downloads(self, stubs): + exited = arvados_cwl.main( + ["--submit", "--no-wait", "--api=containers", "--debug", "--prefer-cached-downloads", + "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"], + stubs.capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client) + + expect_container = copy.deepcopy(stubs.expect_container_spec) + expect_container["command"] = ['arvados-cwl-runner', '--local', '--api=containers', + '--no-log-timestamps', '--disable-validate', '--disable-color', + '--eval-timeout=20', '--thread-count=0', + '--enable-reuse', "--collection-cache-size=256", + '--output-name=Output from workflow submit_wf.cwl (%s)' % stubs.git_props["arv:gitDescribe"], + '--debug', "--on-error=continue", '--prefer-cached-downloads', + '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json'] + + stubs.api.container_requests().create.assert_called_with( + body=JsonDiffMatcher(expect_container)) + self.assertEqual(stubs.capture_stdout.getvalue(), + stubs.expect_container_request_uuid + '\n') + self.assertEqual(exited, 0) + + @stubs() + def test_submit_container_varying_url_params(self, stubs): + exited = arvados_cwl.main( + ["--submit", "--no-wait", "--api=containers", "--debug", "--varying-url-params", "KeyId,Signature", + "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"], + stubs.capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client) + + expect_container = copy.deepcopy(stubs.expect_container_spec) + expect_container["command"] = ['arvados-cwl-runner', '--local', '--api=containers', + '--no-log-timestamps', '--disable-validate', '--disable-color', + '--eval-timeout=20', '--thread-count=0', + '--enable-reuse', "--collection-cache-size=256", + '--output-name=Output from workflow submit_wf.cwl (%s)' % stubs.git_props["arv:gitDescribe"], + '--debug', "--on-error=continue", "--varying-url-params=KeyId,Signature", + '/var/lib/cwl/workflow.json#main', '/var/lib/cwl/cwl.input.json'] stubs.api.container_requests().create.assert_called_with( body=JsonDiffMatcher(expect_container)) @@ -1574,7 +1635,9 @@ class TestSubmit(unittest.TestCase): class TestCreateWorkflow(unittest.TestCase): existing_workflow_uuid = "zzzzz-7fd4e-validworkfloyml" expect_workflow = StripYAMLComments( - open("tests/wf/expect_upload_packed.cwl").read().rstrip()) + open("tests/wf/expect_upload_wrapper.cwl").read().rstrip()) + expect_workflow_altname = StripYAMLComments( + open("tests/wf/expect_upload_wrapper_altname.cwl").read().rstrip()) def setUp(self): cwltool.process._names = set() @@ -1587,7 +1650,7 @@ class TestCreateWorkflow(unittest.TestCase): handlers = [h for h in root_logger.handlers if not isinstance(h, arvados_cwl.executor.RuntimeStatusLoggingHandler)] root_logger.handlers = handlers - @stubs + @stubs() def test_create(self, stubs): project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz' stubs.api.groups().get().execute.return_value = {"group_class": "project"} @@ -1596,6 +1659,7 @@ class TestCreateWorkflow(unittest.TestCase): ["--create-workflow", "--debug", "--api=containers", "--project-uuid", project_uuid, + "--disable-git", "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"], stubs.capture_stdout, sys.stderr, api_client=stubs.api) @@ -1617,7 +1681,7 @@ class TestCreateWorkflow(unittest.TestCase): stubs.expect_workflow_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_create_name(self, stubs): project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz' stubs.api.groups().get().execute.return_value = {"group_class": "project"} @@ -1627,6 +1691,7 @@ class TestCreateWorkflow(unittest.TestCase): "--api=containers", "--project-uuid", project_uuid, "--name", "testing 123", + "--disable-git", "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"], stubs.capture_stdout, sys.stderr, api_client=stubs.api) @@ -1638,7 +1703,7 @@ class TestCreateWorkflow(unittest.TestCase): "owner_uuid": project_uuid, "name": "testing 123", "description": "", - "definition": self.expect_workflow, + "definition": self.expect_workflow_altname, } } stubs.api.workflows().create.assert_called_with( @@ -1649,7 +1714,7 @@ class TestCreateWorkflow(unittest.TestCase): self.assertEqual(exited, 0) - @stubs + @stubs() def test_update(self, stubs): project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz' stubs.api.workflows().get().execute.return_value = {"owner_uuid": project_uuid} @@ -1657,6 +1722,7 @@ class TestCreateWorkflow(unittest.TestCase): exited = arvados_cwl.main( ["--update-workflow", self.existing_workflow_uuid, "--debug", + "--disable-git", "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"], stubs.capture_stdout, sys.stderr, api_client=stubs.api) @@ -1676,7 +1742,7 @@ class TestCreateWorkflow(unittest.TestCase): self.assertEqual(exited, 0) - @stubs + @stubs() def test_update_name(self, stubs): project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz' stubs.api.workflows().get().execute.return_value = {"owner_uuid": project_uuid} @@ -1684,6 +1750,7 @@ class TestCreateWorkflow(unittest.TestCase): exited = arvados_cwl.main( ["--update-workflow", self.existing_workflow_uuid, "--debug", "--name", "testing 123", + "--disable-git", "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"], stubs.capture_stdout, sys.stderr, api_client=stubs.api) @@ -1691,7 +1758,7 @@ class TestCreateWorkflow(unittest.TestCase): "workflow": { "name": "testing 123", "description": "", - "definition": self.expect_workflow, + "definition": self.expect_workflow_altname, "owner_uuid": project_uuid } } @@ -1702,7 +1769,7 @@ class TestCreateWorkflow(unittest.TestCase): self.existing_workflow_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_create_collection_per_tool(self, stubs): project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz' stubs.api.groups().get().execute.return_value = {"group_class": "project"} @@ -1711,10 +1778,11 @@ class TestCreateWorkflow(unittest.TestCase): ["--create-workflow", "--debug", "--api=containers", "--project-uuid", project_uuid, + "--disable-git", "tests/collection_per_tool/collection_per_tool.cwl"], stubs.capture_stdout, sys.stderr, api_client=stubs.api) - toolfile = "tests/collection_per_tool/collection_per_tool_packed.cwl" + toolfile = "tests/collection_per_tool/collection_per_tool_wrapper.cwl" expect_workflow = StripYAMLComments(open(toolfile).read().rstrip()) body = { @@ -1732,7 +1800,7 @@ class TestCreateWorkflow(unittest.TestCase): stubs.expect_workflow_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_create_with_imports(self, stubs): project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz' stubs.api.groups().get().execute.return_value = {"group_class": "project"} @@ -1751,7 +1819,7 @@ class TestCreateWorkflow(unittest.TestCase): stubs.expect_workflow_uuid + '\n') self.assertEqual(exited, 0) - @stubs + @stubs() def test_create_with_no_input(self, stubs): project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz' stubs.api.groups().get().execute.return_value = {"group_class": "project"}