X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/18b51f2620505d4efbc9de322e24d5218a5ca19b..08123387faf00b0af64ea01f7196d8c5ca3fae1e:/sdk/cwl/tests/test_container.py diff --git a/sdk/cwl/tests/test_container.py b/sdk/cwl/tests/test_container.py index 46184325f1..de21fc0b92 100644 --- a/sdk/cwl/tests/test_container.py +++ b/sdk/cwl/tests/test_container.py @@ -2,8 +2,12 @@ # # SPDX-License-Identifier: Apache-2.0 +from builtins import str +from builtins import object + import arvados_cwl import arvados_cwl.context +import arvados_cwl.util from arvados_cwl.arvdocker import arv_docker_clear_cache import copy import arvados.config @@ -70,7 +74,9 @@ class TestContainer(unittest.TestCase): "make_fs_access": make_fs_access, "tmpdir": "/tmp", "enable_reuse": enable_reuse, - "priority": 500}) + "priority": 500, + "project_uuid": "zzzzz-8i9sb-zzzzzzzzzzzzzzz" + }) return loadingContext, runtimeContext @@ -82,7 +88,6 @@ class TestContainer(unittest.TestCase): arv_docker_clear_cache() runner = mock.MagicMock() - runner.project_uuid = "zzzzz-8i9sb-zzzzzzzzzzzzzzz" runner.ignore_docker_for_reuse = False runner.intermediate_output_ttl = 0 runner.secret_store = cwltool.secrets.SecretStore() @@ -132,7 +137,7 @@ class TestContainer(unittest.TestCase): 'owner_uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz', 'output_path': '/var/spool/cwl', 'output_ttl': 0, - 'container_image': 'arvados/jobs', + 'container_image': '99999999999999999999999999999993+99', 'command': ['ls', '/var/spool/cwl'], 'cwd': '/var/spool/cwl', 'scheduling_parameters': {}, @@ -146,7 +151,6 @@ class TestContainer(unittest.TestCase): def test_resource_requirements(self, keepdocker): arv_docker_clear_cache() runner = mock.MagicMock() - runner.project_uuid = "zzzzz-8i9sb-zzzzzzzzzzzzzzz" runner.ignore_docker_for_reuse = False runner.intermediate_output_ttl = 3600 runner.secret_store = cwltool.secrets.SecretStore() @@ -219,7 +223,7 @@ class TestContainer(unittest.TestCase): 'owner_uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz', 'output_path': '/var/spool/cwl', 'output_ttl': 7200, - 'container_image': 'arvados/jobs', + 'container_image': '99999999999999999999999999999993+99', 'command': ['ls'], 'cwd': '/var/spool/cwl', 'scheduling_parameters': { @@ -242,7 +246,6 @@ class TestContainer(unittest.TestCase): def test_initial_work_dir(self, collection_mock, keepdocker): arv_docker_clear_cache() runner = mock.MagicMock() - runner.project_uuid = "zzzzz-8i9sb-zzzzzzzzzzzzzzz" runner.ignore_docker_for_reuse = False runner.intermediate_output_ttl = 0 runner.secret_store = cwltool.secrets.SecretStore() @@ -351,7 +354,7 @@ class TestContainer(unittest.TestCase): 'owner_uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz', 'output_path': '/var/spool/cwl', 'output_ttl': 0, - 'container_image': 'arvados/jobs', + 'container_image': '99999999999999999999999999999993+99', 'command': ['ls'], 'cwd': '/var/spool/cwl', 'scheduling_parameters': { @@ -372,7 +375,6 @@ class TestContainer(unittest.TestCase): arv_docker_clear_cache() runner = mock.MagicMock() - runner.project_uuid = "zzzzz-8i9sb-zzzzzzzzzzzzzzz" runner.ignore_docker_for_reuse = False runner.intermediate_output_ttl = 0 runner.secret_store = cwltool.secrets.SecretStore() @@ -439,7 +441,7 @@ class TestContainer(unittest.TestCase): 'owner_uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz', 'output_path': '/var/spool/cwl', 'output_ttl': 0, - 'container_image': 'arvados/jobs', + 'container_image': '99999999999999999999999999999993+99', 'command': ['ls', '/var/spool/cwl'], 'cwd': '/var/spool/cwl', 'scheduling_parameters': {}, @@ -453,7 +455,6 @@ class TestContainer(unittest.TestCase): runner = mock.MagicMock() runner.api = api - runner.project_uuid = "zzzzz-8i9sb-zzzzzzzzzzzzzzz" runner.num_retries = 0 runner.ignore_docker_for_reuse = False runner.intermediate_output_ttl = 0 @@ -465,7 +466,10 @@ class TestContainer(unittest.TestCase): col().open.return_value = [] + loadingContext, runtimeContext = self.helper(runner) + arvjob = arvados_cwl.ArvadosContainer(runner, + runtimeContext, mock.MagicMock(), {}, None, @@ -496,7 +500,7 @@ class TestContainer(unittest.TestCase): arvjob.output_callback.assert_called_with({"out": "stuff"}, "success") runner.add_intermediate_output.assert_called_with("zzzzz-4zz18-zzzzzzzzzzzzzz2") - @mock.patch("arvados_cwl.get_current_container") + @mock.patch("arvados_cwl.util.get_current_container") @mock.patch("arvados.collection.CollectionReader") @mock.patch("arvados.collection.Collection") def test_child_failure(self, col, reader, gcc_mock): @@ -507,11 +511,11 @@ class TestContainer(unittest.TestCase): # Set up runner with mocked runtime_status_update() self.assertFalse(gcc_mock.called) runtime_status_update = mock.MagicMock() - arvados_cwl.ArvCwlRunner.runtime_status_update = runtime_status_update - runner = arvados_cwl.ArvCwlRunner(api) + arvados_cwl.ArvCwlExecutor.runtime_status_update = runtime_status_update + runner = arvados_cwl.ArvCwlExecutor(api) self.assertEqual(runner.work_api, 'containers') - # Make sure ArvCwlRunner thinks it's running inside a container so it + # Make sure ArvCwlExecutor thinks it's running inside a container so it # adds the logging handler that will call runtime_status_update() mock gcc_mock.return_value = {"uuid" : "zzzzz-dz642-zzzzzzzzzzzzzzz"} self.assertTrue(gcc_mock.called) @@ -519,7 +523,6 @@ class TestContainer(unittest.TestCase): handlerClasses = [h.__class__ for h in root_logger.handlers] self.assertTrue(arvados_cwl.RuntimeStatusLoggingHandler in handlerClasses) - runner.project_uuid = "zzzzz-8i9sb-zzzzzzzzzzzzzzz" runner.num_retries = 0 runner.ignore_docker_for_reuse = False runner.intermediate_output_ttl = 0 @@ -536,7 +539,10 @@ class TestContainer(unittest.TestCase): col().open.return_value = [] + loadingContext, runtimeContext = self.helper(runner) + arvjob = arvados_cwl.ArvadosContainer(runner, + runtimeContext, mock.MagicMock(), {}, None, @@ -573,7 +579,6 @@ class TestContainer(unittest.TestCase): arv_docker_clear_cache() runner = mock.MagicMock() - runner.project_uuid = "zzzzz-8i9sb-zzzzzzzzzzzzzzz" runner.ignore_docker_for_reuse = False runner.intermediate_output_ttl = 0 runner.secret_store = cwltool.secrets.SecretStore() @@ -648,7 +653,7 @@ class TestContainer(unittest.TestCase): 'owner_uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz', 'output_path': '/var/spool/cwl', 'output_ttl': 0, - 'container_image': 'arvados/jobs', + 'container_image': '99999999999999999999999999999994+99', 'command': ['ls', '/var/spool/cwl'], 'cwd': '/var/spool/cwl', 'scheduling_parameters': {}, @@ -663,7 +668,6 @@ class TestContainer(unittest.TestCase): arv_docker_clear_cache() runner = mock.MagicMock() - runner.project_uuid = "zzzzz-8i9sb-zzzzzzzzzzzzzzz" runner.ignore_docker_for_reuse = False runner.intermediate_output_ttl = 0 runner.secret_store = cwltool.secrets.SecretStore() @@ -741,7 +745,7 @@ class TestContainer(unittest.TestCase): 'owner_uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz', 'output_path': '/var/spool/cwl', 'output_ttl': 0, - 'container_image': 'arvados/jobs', + 'container_image': '99999999999999999999999999999993+99', 'command': ['md5sum', 'example.conf'], 'cwd': '/var/spool/cwl', 'scheduling_parameters': {}, @@ -761,7 +765,6 @@ class TestContainer(unittest.TestCase): arv_docker_clear_cache() runner = mock.MagicMock() - runner.project_uuid = "zzzzz-8i9sb-zzzzzzzzzzzzzzz" runner.ignore_docker_for_reuse = False runner.intermediate_output_ttl = 0 runner.secret_store = cwltool.secrets.SecretStore()