X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/9fa635c9dc288317f19471291accecf8690f5718..3e5ac41e4e38e6c8fa72883b803d85fcde53e25b:/sdk/cwl/tests/test_submit.py diff --git a/sdk/cwl/tests/test_submit.py b/sdk/cwl/tests/test_submit.py index 8b7e4af816..8875b7d954 100644 --- a/sdk/cwl/tests/test_submit.py +++ b/sdk/cwl/tests/test_submit.py @@ -132,7 +132,8 @@ def stubs(func): "listing": [{ "basename": "renamed.txt", "class": "File", - "location": "keep:99999999999999999999999999999998+99/file1.txt" + "location": "keep:99999999999999999999999999999998+99/file1.txt", + "size": 0 }], 'class': 'Directory' }, @@ -164,7 +165,8 @@ def stubs(func): { 'basename': 'renamed.txt', 'class': 'File', 'location': - 'keep:99999999999999999999999999999998+99/file1.txt' + 'keep:99999999999999999999999999999998+99/file1.txt', + 'size': 0 } ]}}, 'cwl:tool': '3fffdeaa75e018172e1b583425f4ebff+60/workflow.cwl#main', @@ -225,7 +227,8 @@ def stubs(func): 'z': {'basename': 'anonymous', 'class': 'Directory', 'listing': [ {'basename': 'renamed.txt', 'class': 'File', - 'location': 'keep:99999999999999999999999999999998+99/file1.txt' + 'location': 'keep:99999999999999999999999999999998+99/file1.txt', + 'size': 0 } ]} }, @@ -286,14 +289,14 @@ class TestSubmit(unittest.TestCase): 'manifest_text': '. 5bcc9fe8f8d5992e6cf418dc7ce4dbb3+16 0:16:blub.txt\n', 'replication_desired': None, - 'name': 'submit_tool.cwl dependencies', - }), ensure_unique_name=True), + 'name': 'submit_tool.cwl dependencies (5d373e7629203ce39e7c22af98a0f881+52)', + }), ensure_unique_name=False), mock.call(body=JsonDiffMatcher({ 'manifest_text': '. 979af1245a12a1fed634d4222473bfdc+16 0:16:blorp.txt\n', 'replication_desired': None, - 'name': 'submit_wf.cwl input', - }), ensure_unique_name=True), + 'name': 'submit_wf.cwl input (169f39d466a5438ac4a90e779bf750c7+53)', + }), ensure_unique_name=False), mock.call(body=JsonDiffMatcher({ 'manifest_text': '. 61df2ed9ee3eb7dd9b799e5ca35305fa+1217 0:1217:workflow.cwl\n', @@ -482,14 +485,14 @@ class TestSubmit(unittest.TestCase): 'manifest_text': '. 5bcc9fe8f8d5992e6cf418dc7ce4dbb3+16 0:16:blub.txt\n', 'replication_desired': None, - 'name': 'submit_tool.cwl dependencies', - }), ensure_unique_name=True), + 'name': 'submit_tool.cwl dependencies (5d373e7629203ce39e7c22af98a0f881+52)', + }), ensure_unique_name=False), mock.call(body=JsonDiffMatcher({ 'manifest_text': '. 979af1245a12a1fed634d4222473bfdc+16 0:16:blorp.txt\n', 'replication_desired': None, - 'name': 'submit_wf.cwl input', - }), ensure_unique_name=True)]) + 'name': 'submit_wf.cwl input (169f39d466a5438ac4a90e779bf750c7+53)', + }), ensure_unique_name=False)]) expect_container = copy.deepcopy(stubs.expect_container_spec) stubs.api.container_requests().create.assert_called_with( @@ -781,6 +784,7 @@ class TestSubmit(unittest.TestCase): @stubs def test_submit_file_keepref(self, stubs, tm, collectionReader): capture_stdout = cStringIO.StringIO() + collectionReader().find.return_value = arvados.arvfile.ArvadosFile(mock.MagicMock(), "blorp.txt") exited = arvados_cwl.main( ["--submit", "--no-wait", "--api=containers", "--debug", "tests/wf/submit_keepref_wf.cwl"], @@ -1131,6 +1135,42 @@ class TestSubmit(unittest.TestCase): stubs.expect_container_request_uuid + '\n') + @stubs + def test_submit_wf_runner_resources(self, stubs): + capture_stdout = cStringIO.StringIO() + try: + exited = arvados_cwl.main( + ["--submit", "--no-wait", "--api=containers", "--debug", + "tests/wf/submit_wf_runner_resources.cwl", "tests/submit_test_job.json"], + capture_stdout, sys.stderr, api_client=stubs.api, keep_client=stubs.keep_client) + self.assertEqual(exited, 0) + except: + logging.exception("") + + expect_container = copy.deepcopy(stubs.expect_container_spec) + expect_container["runtime_constraints"] = { + "API": True, + "vcpus": 2, + "ram": 2000 * 2**20 + } + expect_container["name"] = "submit_wf_runner_resources.cwl" + expect_container["mounts"]["/var/lib/cwl/workflow.json"]["content"]["$graph"][1]["hints"] = [ + { + "class": "http://arvados.org/cwl#WorkflowRunnerResources", + "coresMin": 2, + "ramMin": 2000 + } + ] + expect_container["mounts"]["/var/lib/cwl/workflow.json"]["content"]["$graph"][0]["$namespaces"] = { + "arv": "http://arvados.org/cwl#", + } + + stubs.api.container_requests().create.assert_called_with( + body=JsonDiffMatcher(expect_container)) + self.assertEqual(capture_stdout.getvalue(), + stubs.expect_container_request_uuid + '\n') + + @mock.patch("arvados.commands.keepdocker.find_one_image_hash") @mock.patch("cwltool.docker.DockerCommandLineJob.get_image") @mock.patch("arvados.api")