From: Peter Amstutz Date: Thu, 1 Dec 2016 18:36:55 +0000 (-0500) Subject: 10651: Check --submit-runner-ram has a valid value. Add tests. X-Git-Tag: 1.1.0~572^2 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/66622dea0bb8725d0cbec0976175d11162b17815 10651: Check --submit-runner-ram has a valid value. Add tests. --- diff --git a/sdk/cwl/arvados_cwl/__init__.py b/sdk/cwl/arvados_cwl/__init__.py index 817efaeae4..ce84b815e7 100644 --- a/sdk/cwl/arvados_cwl/__init__.py +++ b/sdk/cwl/arvados_cwl/__init__.py @@ -529,8 +529,8 @@ def arg_parser(): # type: () -> argparse.ArgumentParser dest="compute_checksum") parser.add_argument("--submit-runner-ram", type=int, - help="RAM (in MiB) required for the workflow runner job.", - default=0) + help="RAM (in MiB) required for the workflow runner job (default 1024)", + default=1024) parser.add_argument("workflow", type=str, nargs="?", default=None, help="The workflow to execute") parser.add_argument("job_order", nargs=argparse.REMAINDER, help="The input object to the workflow.") diff --git a/sdk/cwl/arvados_cwl/runner.py b/sdk/cwl/arvados_cwl/runner.py index 373424c5e8..0eb356295f 100644 --- a/sdk/cwl/arvados_cwl/runner.py +++ b/sdk/cwl/arvados_cwl/runner.py @@ -177,6 +177,9 @@ class Runner(object): else: self.submit_runner_ram = 1024 + if self.submit_runner_ram <= 0: + raise Exception("Value of --submit-runner-ram must be greater than zero") + def update_pipeline_component(self, record): pass diff --git a/sdk/cwl/tests/test_submit.py b/sdk/cwl/tests/test_submit.py index e49a09f4aa..dea04b3222 100644 --- a/sdk/cwl/tests/test_submit.py +++ b/sdk/cwl/tests/test_submit.py @@ -275,6 +275,36 @@ class TestSubmit(unittest.TestCase): self.assertEqual(capture_stdout.getvalue(), stubs.expect_pipeline_uuid + '\n') + + @mock.patch("time.sleep") + @stubs + def test_submit_runner_ram(self, stubs, tm): + capture_stdout = cStringIO.StringIO() + exited = arvados_cwl.main( + ["--submit", "--no-wait", "--debug", "--submit-runner-ram=2048", + "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"], + capture_stdout, sys.stderr, api_client=stubs.api) + self.assertEqual(exited, 0) + + stubs.expect_pipeline_instance["components"]["cwl-runner"]["runtime_constraints"]["min_ram_mb_per_node"] = 2048 + + expect_pipeline = copy.deepcopy(stubs.expect_pipeline_instance) + stubs.api.pipeline_instances().create.assert_called_with( + body=expect_pipeline) + self.assertEqual(capture_stdout.getvalue(), + stubs.expect_pipeline_uuid + '\n') + + + @mock.patch("time.sleep") + @stubs + def test_submit_invalid_runner_ram(self, stubs, tm): + capture_stdout = cStringIO.StringIO() + exited = arvados_cwl.main( + ["--submit", "--no-wait", "--debug", "--submit-runner-ram=-2048", + "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"], + capture_stdout, sys.stderr, api_client=stubs.api) + self.assertEqual(exited, 1) + @mock.patch("time.sleep") @stubs def test_submit_output_name(self, stubs, tm): @@ -439,6 +469,26 @@ class TestSubmit(unittest.TestCase): self.assertEqual(capture_stdout.getvalue(), stubs.expect_container_request_uuid + '\n') + @stubs + def test_submit_container_runner_ram(self, stubs): + capture_stdout = cStringIO.StringIO() + try: + exited = arvados_cwl.main( + ["--submit", "--no-wait", "--api=containers", "--debug", "--submit-runner-ram=2048", + "tests/wf/submit_wf.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("") + + stubs.expect_container_spec["runtime_constraints"]["ram"] = 2048*1024*1024 + + expect_container = copy.deepcopy(stubs.expect_container_spec) + stubs.api.container_requests().create.assert_called_with( + body=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.get_image") @mock.patch("arvados.api")