[ARVADOS] updated: 077878d94771c25c25edfe01a98a523898916d9e
Git user
git at public.curoverse.com
Wed Mar 22 09:22:05 EDT 2017
Summary of changes:
services/api/lib/crunch_dispatch.rb | 9 ++++-----
services/api/test/unit/crunch_dispatch_test.rb | 8 ++++----
services/api/test/unit/fail_jobs_test.rb | 8 ++++----
3 files changed, 12 insertions(+), 13 deletions(-)
via 077878d94771c25c25edfe01a98a523898916d9e (commit)
from 79e53c0eed77396cb37f60b48be0c60fe7e0ab89 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 077878d94771c25c25edfe01a98a523898916d9e
Author: Lucas Di Pentima <lucas at curoverse.com>
Date: Wed Mar 22 10:21:17 2017 -0300
11170: Updated tests to reflect the use of IO instead of File.
diff --git a/services/api/lib/crunch_dispatch.rb b/services/api/lib/crunch_dispatch.rb
index 7c9fa0a..c95db31 100644
--- a/services/api/lib/crunch_dispatch.rb
+++ b/services/api/lib/crunch_dispatch.rb
@@ -963,11 +963,10 @@ class CrunchDispatch
# An array of job_uuids in squeue
def squeue_jobs
if Rails.configuration.crunch_job_wrapper == :slurm_immediate
- IO.popen(['squeue', '-a', '-h', '-o', '%j']) do |squeue_pipe|
- squeue_pipe.readlines.map do |line|
- line.strip
- end
- end
+ p = IO.popen(['squeue', '-a', '-h', '-o', '%j'])
+ l = p.readlines.map {|line| line.strip}
+ p.close
+ l
else
[]
end
diff --git a/services/api/test/unit/crunch_dispatch_test.rb b/services/api/test/unit/crunch_dispatch_test.rb
index 4646f7a..d091847 100644
--- a/services/api/test/unit/crunch_dispatch_test.rb
+++ b/services/api/test/unit/crunch_dispatch_test.rb
@@ -208,14 +208,14 @@ class CrunchDispatchTest < ActiveSupport::TestCase
act_as_system_user do
dispatch = CrunchDispatch.new
- squeue_resp = File.popen("echo zzzzz-8i9sb-pshmckwoma9plh7\necho thisisnotvalidjobuuid\necho zzzzz-8i9sb-4cf0abc123e809j\n")
- scancel_resp = File.popen("true")
+ squeue_resp = IO.popen("echo zzzzz-8i9sb-pshmckwoma9plh7\necho thisisnotvalidjobuuid\necho zzzzz-8i9sb-4cf0abc123e809j\n")
+ scancel_resp = IO.popen("true")
- File.expects(:popen).
+ IO.expects(:popen).
with(['squeue', '-a', '-h', '-o', '%j']).
returns(squeue_resp)
- File.expects(:popen).
+ IO.expects(:popen).
with(dispatch.sudo_preface + ['scancel', '-n', 'zzzzz-8i9sb-4cf0abc123e809j']).
returns(scancel_resp)
diff --git a/services/api/test/unit/fail_jobs_test.rb b/services/api/test/unit/fail_jobs_test.rb
index 8c6539e..3119765 100644
--- a/services/api/test/unit/fail_jobs_test.rb
+++ b/services/api/test/unit/fail_jobs_test.rb
@@ -38,12 +38,12 @@ class FailJobsTest < ActiveSupport::TestCase
test 'cancel slurm jobs' do
Rails.configuration.crunch_job_wrapper = :slurm_immediate
Rails.configuration.crunch_job_user = 'foobar'
- fake_squeue = File.popen("echo #{@job[:before_reboot].uuid}")
- fake_scancel = File.popen("true")
- File.expects(:popen).
+ fake_squeue = IO.popen("echo #{@job[:before_reboot].uuid}")
+ fake_scancel = IO.popen("true")
+ IO.expects(:popen).
with(['squeue', '-a', '-h', '-o', '%j']).
returns(fake_squeue)
- File.expects(:popen).
+ IO.expects(:popen).
with(includes('sudo', '-u', 'foobar', 'scancel', '-n', @job[:before_reboot].uuid)).
returns(fake_scancel)
@dispatch.fail_jobs(before: Time.at(BOOT_TIME).to_s)
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list