X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0e4e5d028290bc8d5a4ffe5469a6993f640027a6..cb781d9b5e61c5494d29d53a0a12c678c839eecd:/sdk/cwl/tests/test_submit.py diff --git a/sdk/cwl/tests/test_submit.py b/sdk/cwl/tests/test_submit.py index 6674efb8c4..7c8659a187 100644 --- a/sdk/cwl/tests/test_submit.py +++ b/sdk/cwl/tests/test_submit.py @@ -112,6 +112,38 @@ def stubs(func): 'script_version': 'master', 'script': 'cwl-runner' } + stubs.pipeline_component = stubs.expect_job_spec.copy() + stubs.expect_pipeline_instance = { + 'name': 'submit_wf.cwl', + 'state': 'RunningOnServer', + "components": { + "cwl-runner": { + 'runtime_constraints': {'docker_image': 'arvados/jobs'}, + 'script_parameters': { + 'y': {'basename': '99999999999999999999999999999998+99', 'location': 'keep:99999999999999999999999999999998+99', 'class': 'Directory'}, + 'x': {'basename': 'blorp.txt', 'class': 'File', 'location': 'keep:99999999999999999999999999999994+99/blorp.txt'}, + 'z': {'basename': 'anonymous', 'class': 'Directory', + 'listing': [ + {'basename': 'renamed.txt', 'class': 'File', 'location': 'keep:99999999999999999999999999999998+99/file1.txt'} + ]}, + 'cwl:tool': '99999999999999999999999999999991+99/wf/submit_wf.cwl' + }, + 'repository': 'arvados', + 'script_version': 'master', + 'script': 'cwl-runner' + } + } + } + stubs.pipeline_create = copy.deepcopy(stubs.expect_pipeline_instance) + stubs.expect_pipeline_uuid = "zzzzz-d1hrv-zzzzzzzzzzzzzzz" + stubs.pipeline_create["uuid"] = stubs.expect_pipeline_uuid + stubs.pipeline_with_job = copy.deepcopy(stubs.pipeline_create) + stubs.pipeline_with_job["components"]["cwl-runner"]["job"] = { + "uuid": "zzzzz-8i9sb-zzzzzzzzzzzzzzz", + "state": "Queued" + } + stubs.api.pipeline_instances().create().execute.return_value = stubs.pipeline_create + stubs.api.pipeline_instances().get().execute.return_value = stubs.pipeline_with_job stubs.expect_container_spec = { 'priority': 1, @@ -157,11 +189,12 @@ def stubs(func): class TestSubmit(unittest.TestCase): + @mock.patch("time.sleep") @stubs - def test_submit(self, stubs): + def test_submit(self, stubs, tm): capture_stdout = cStringIO.StringIO() exited = arvados_cwl.main( - ["--submit", "--no-wait", + ["--submit", "--no-wait", "--debug", "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"], capture_stdout, sys.stderr, api_client=stubs.api) self.assertEqual(exited, 0) @@ -192,16 +225,16 @@ class TestSubmit(unittest.TestCase): }, ensure_unique_name=True), mock.call().execute()]) - expect_job = copy.deepcopy(stubs.expect_job_spec) - expect_job["owner_uuid"] = stubs.fake_user_uuid - stubs.api.jobs().create.assert_called_with( - body=expect_job, - find_or_create=True) + expect_pipeline = copy.deepcopy(stubs.expect_pipeline_instance) + expect_pipeline["owner_uuid"] = stubs.fake_user_uuid + stubs.api.pipeline_instances().create.assert_called_with( + body=expect_pipeline) self.assertEqual(capture_stdout.getvalue(), - stubs.expect_job_uuid + '\n') + stubs.expect_pipeline_uuid + '\n') + @mock.patch("time.sleep") @stubs - def test_submit_with_project_uuid(self, stubs): + def test_submit_with_project_uuid(self, stubs, tm): project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz' exited = arvados_cwl.main( @@ -211,11 +244,10 @@ class TestSubmit(unittest.TestCase): sys.stdout, sys.stderr, api_client=stubs.api) self.assertEqual(exited, 0) - expect_body = copy.deepcopy(stubs.expect_job_spec) - expect_body["owner_uuid"] = project_uuid - stubs.api.jobs().create.assert_called_with( - body=expect_body, - find_or_create=True) + expect_pipeline = copy.deepcopy(stubs.expect_pipeline_instance) + expect_pipeline["owner_uuid"] = project_uuid + stubs.api.pipeline_instances().create.assert_called_with( + body=expect_pipeline) @stubs def test_submit_container(self, stubs):