From a8aa509cf3913c8dc91640ddcad6b25e6609517a Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Thu, 8 Aug 2019 16:50:51 -0400 Subject: [PATCH] 15133: Fix more tests Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- .../test/test_arv-run-pipeline-instance.rb | 37 ----- sdk/cli/test/test_crunch-job.rb | 141 ------------------ sdk/cwl/tests/test_container.py | 2 - sdk/python/arvados/commands/run.py | 2 + 4 files changed, 2 insertions(+), 180 deletions(-) delete mode 100644 sdk/cli/test/test_arv-run-pipeline-instance.rb delete mode 100644 sdk/cli/test/test_crunch-job.rb diff --git a/sdk/cli/test/test_arv-run-pipeline-instance.rb b/sdk/cli/test/test_arv-run-pipeline-instance.rb deleted file mode 100644 index b6a0328add..0000000000 --- a/sdk/cli/test/test_arv-run-pipeline-instance.rb +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (C) The Arvados Authors. All rights reserved. -# -# SPDX-License-Identifier: Apache-2.0 - -require 'minitest/autorun' - -class TestRunPipelineInstance < Minitest::Test - def setup - end - - def test_run_pipeline_instance_get_help - out, err = capture_subprocess_io do - system ('arv-run-pipeline-instance -h') - end - assert_equal '', err - end - - def test_run_pipeline_instance_with_no_such_option - out, err = capture_subprocess_io do - system ('arv-run-pipeline-instance --junk') - end - refute_equal '', err - end - - def test_run_pipeline_instance_for_bogus_template_uuid - out, err = capture_subprocess_io do - # fails with error SSL_connect error because HOST_INSECURE is not being used - # system ('arv-run-pipeline-instance --template bogus-abcde-fghijklmnopqrs input=c1bad4b39ca5a924e481008009d94e32+210') - - # fails with error: fatal: cannot load such file -- arvados - # system ('./bin/arv-run-pipeline-instance --template bogus-abcde-fghijklmnopqrs input=c1bad4b39ca5a924e481008009d94e32+210') - end - #refute_equal '', err - assert_equal '', err - end - -end diff --git a/sdk/cli/test/test_crunch-job.rb b/sdk/cli/test/test_crunch-job.rb deleted file mode 100644 index 5f111e78d0..0000000000 --- a/sdk/cli/test/test_crunch-job.rb +++ /dev/null @@ -1,141 +0,0 @@ -# Copyright (C) The Arvados Authors. All rights reserved. -# -# SPDX-License-Identifier: Apache-2.0 - -require 'minitest/autorun' - -class TestCrunchJob < Minitest::Test - SPECIAL_EXIT = { - EX_RETRY_UNLOCKED: 93, - EX_TEMPFAIL: 75, - } - - JOBSPEC = { - grep_local: { - owner_uuid: 'zzzzz-j7d0g-it30l961gq3t0oi', - script: 'grep', - script_version: 'master', - repository: File.absolute_path('../../../..', __FILE__), - script_parameters: {foo: 'bar'}, - }, - } - - def setup - end - - def crunchjob - File.absolute_path '../../bin/crunch-job', __FILE__ - end - - # Return environment suitable for running crunch-job. - def crunchenv opts={} - env = ENV.to_h - env['CRUNCH_REFRESH_TRIGGER'] = - File.absolute_path('../../../../tmp/crunch-refresh-trigger', __FILE__) - env - end - - def jobspec label - JOBSPEC[label].dup - end - - # Encode job record to json and run it with crunch-job. - # - # opts[:binstubs] is an array of X where ./binstub_X is added to - # PATH in order to mock system programs. - def tryjobrecord jobrecord, opts={} - env = crunchenv - (opts[:binstubs] || []).each do |binstub| - env['PATH'] = File.absolute_path('../binstub_'+binstub, __FILE__) + ':' + env['PATH'] - end - system env, crunchjob, '--job', jobrecord.to_json - end - - def test_bogus_json - out, err = capture_subprocess_io do - system crunchenv, crunchjob, '--job', '"}{"' - end - assert_equal false, $?.success? - # Must not conflict with our special exit statuses - assert_jobfail $? - assert_match /JSON/, err - end - - def test_fail_sanity_check - out, err = capture_subprocess_io do - j = {} - tryjobrecord j, binstubs: ['sanity_check'] - end - assert_equal 75, $?.exitstatus - assert_match /Sanity check failed: 7/, err - end - - def test_fail_docker_sanity_check - out, err = capture_subprocess_io do - j = {} - j[:docker_image_locator] = '4d449b9d34f2e2222747ef79c53fa3ff+1234' - tryjobrecord j, binstubs: ['sanity_check'] - end - assert_equal 75, $?.exitstatus - assert_match /Sanity check failed: 8/, err - end - - def test_no_script_specified - out, err = capture_subprocess_io do - j = jobspec :grep_local - j.delete :script - tryjobrecord j - end - assert_match /No script specified/, err - assert_jobfail $? - end - - def test_fail_clean_tmp - out, err = capture_subprocess_io do - j = jobspec :grep_local - tryjobrecord j, binstubs: ['clean_fail'] - end - assert_match /Failing mount stub was called/, err - assert_match /clean work dirs: exit 44\n.*Transient failure.* exiting 93\n(.*arv_put.*INFO.*\n)?$/, err - assert_equal SPECIAL_EXIT[:EX_RETRY_UNLOCKED], $?.exitstatus - end - - def test_output_collection_owner_uuid - skip "Depends on a post 1.3 python-arvados-python-client package being installed" - - j = jobspec :grep_local - out, err = capture_subprocess_io do - tryjobrecord j, binstubs: ['arv-mount', 'output_coll_owner'] - end - assert_match /owner_uuid: #{j['owner_uuid']}/, err - end - - def test_docker_image_missing - skip 'API bug: it refuses to create this job in Running state' - out, err = capture_subprocess_io do - j = jobspec :grep_local - j[:docker_image_locator] = '4d449b9d34f2e2222747ef79c53fa3ff+1234' - tryjobrecord j, binstubs: ['docker_noop'] - end - assert_match /No Docker image hash found from locator/, err - assert_jobfail $? - end - - def test_script_version_not_found_in_repository - bogus_version = 'f8b72707c1f5f740dbf1ed56eb429a36e0dee770' - out, err = capture_subprocess_io do - j = jobspec :grep_local - j[:script_version] = bogus_version - tryjobrecord j, binstubs: ['arv-mount'] - end - assert_match /'#{bogus_version}' not found, giving up/, err - assert_jobfail $? - end - - # Ensure procstatus is not interpreted as a temporary infrastructure - # problem. Would be assert_http_4xx if this were http. - def assert_jobfail procstatus - refute_includes SPECIAL_EXIT.values, procstatus.exitstatus - assert_equal false, procstatus.success? - end -end diff --git a/sdk/cwl/tests/test_container.py b/sdk/cwl/tests/test_container.py index c22ece38b6..3374e1c13f 100644 --- a/sdk/cwl/tests/test_container.py +++ b/sdk/cwl/tests/test_container.py @@ -88,7 +88,6 @@ class TestContainer(unittest.TestCase): def setup_and_test_container_executor_and_logging(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() mock @@ -1071,6 +1070,5 @@ class TestWorkflow(unittest.TestCase): api = mock.MagicMock() api._rootDesc = copy.deepcopy(get_rootDesc()) - del api._rootDesc.get('resources')['jobs']['methods']['create'] runner = arvados_cwl.executor.ArvCwlExecutor(api) self.assertEqual(runner.work_api, 'containers') diff --git a/sdk/python/arvados/commands/run.py b/sdk/python/arvados/commands/run.py index f0d518d4e9..a45775470a 100644 --- a/sdk/python/arvados/commands/run.py +++ b/sdk/python/arvados/commands/run.py @@ -39,6 +39,8 @@ import arvados.config as config from arvados._version import __version__ +logger = logging.getLogger('arvados.arv-run') +logger.setLevel(logging.INFO) class ArvFile(object): def __init__(self, prefix, fn): -- 2.30.2