[ARVADOS] created: bbec60169a83a0022061201758a04b3c6023957a

git at public.curoverse.com git at public.curoverse.com
Mon Oct 6 13:47:30 EDT 2014


        at  bbec60169a83a0022061201758a04b3c6023957a (commit)


commit bbec60169a83a0022061201758a04b3c6023957a
Merge: 5c1f516 77e3dec
Author: radhika <radhika at curoverse.com>
Date:   Mon Oct 6 13:47:22 2014 -0400

    Merge branch 'master' into 4046-job-queue-position


commit 5c1f5168af4c3d5a30fdcc5a4364da6640c8c5fd
Author: radhika <radhika at curoverse.com>
Date:   Mon Oct 6 13:45:58 2014 -0400

    4046: update queue_position method to increment index and add unit test.

diff --git a/services/api/app/models/job.rb b/services/api/app/models/job.rb
index 4b86be7..2482256 100644
--- a/services/api/app/models/job.rb
+++ b/services/api/app/models/job.rb
@@ -75,10 +75,9 @@ class Job < ArvadosModel
   end
 
   def queue_position
-    i = 0
-    Job::queue.each do |j|
-      if j[:uuid] == self.uuid
-        return i
+    Job::queue.each_with_index do |job, index|
+      if job[:uuid] == self.uuid
+        return index
       end
     end
     nil
diff --git a/services/api/test/unit/job_test.rb b/services/api/test/unit/job_test.rb
index abf7ce3..1fbaf6c 100644
--- a/services/api/test/unit/job_test.rb
+++ b/services/api/test/unit/job_test.rb
@@ -267,4 +267,18 @@ class JobTest < ActiveSupport::TestCase
     assert_equal "Failed", job.state
   end
 
+  test "verify job queue position" do
+    job1 = Job.create! job_attrs
+    assert job1.valid?, job1.errors.full_messages.to_s
+    assert_equal 'Queued', job1.state, "job.state"
+
+    job2 = Job.create! job_attrs
+    assert job2.valid?, job2.errors.full_messages.to_s
+    assert_equal 'Queued', job2.state, "job.state"
+
+    assert_not_nil job1.queue_position, "Expected non-nil queue position for job1"
+    assert_not_nil job2.queue_position, "Expected non-nil queue position for job2"
+    assert_not_equal job1.queue_position, job2.queue_position
+  end
+ 
 end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list