X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/2c3a6a67bc01241f57e815f4f7e4678bd6eadb03..0818f8a837bd9d60132f0c7bc8cd06f15e0002d2:/sdk/cwl/tests/test_container.py diff --git a/sdk/cwl/tests/test_container.py b/sdk/cwl/tests/test_container.py index de21fc0b92..4d6bcd2f68 100644 --- a/sdk/cwl/tests/test_container.py +++ b/sdk/cwl/tests/test_container.py @@ -500,6 +500,30 @@ class TestContainer(unittest.TestCase): arvjob.output_callback.assert_called_with({"out": "stuff"}, "success") runner.add_intermediate_output.assert_called_with("zzzzz-4zz18-zzzzzzzzzzzzzz2") + # Test to make sure we dont call runtime_status_update if we already did + # some where higher up in the call stack + @mock.patch("arvados_cwl.util.get_current_container") + def test_infinite_runtime_status_update(self, gcc_mock): + api = mock.MagicMock() + api._rootDesc = copy.deepcopy(get_rootDesc()) + del api._rootDesc.get('resources')['jobs']['methods']['create'] + + # Make sure ArvCwlExecutor thinks it's running inside a container so it + # adds the logging handler that will call runtime_status_update() + runner = arvados_cwl.ArvCwlExecutor(api) + self.assertEqual(runner.work_api, 'containers') + root_logger = logging.getLogger('') + handlerClasses = [h.__class__ for h in root_logger.handlers] + self.assertTrue(arvados_cwl.RuntimeStatusLoggingHandler in handlerClasses) + + # get_current_container is invoked when we call runtime_status_update + # so try and log again! + gcc_mock.side_effect = lambda *args: root_logger.error("Second Error") + try: + root_logger.error("First Error") + except RuntimeError as e: + self.fail(str(e)) + @mock.patch("arvados_cwl.util.get_current_container") @mock.patch("arvados.collection.CollectionReader") @mock.patch("arvados.collection.Collection")