[ARVADOS] updated: 3412c35d3da73b94c133099dceab9770fb465165
git at public.curoverse.com
git at public.curoverse.com
Wed Oct 1 11:23:42 EDT 2014
Summary of changes:
services/api/app/models/arvados_model.rb | 6 ++++++
services/api/app/models/job.rb | 2 +-
services/api/test/fixtures/jobs.yml | 28 ++++++++++++++++++++++++++
services/api/test/integration/jobs_api_test.rb | 4 ++--
services/api/test/unit/job_test.rb | 4 ++--
5 files changed, 39 insertions(+), 5 deletions(-)
via 3412c35d3da73b94c133099dceab9770fb465165 (commit)
from 1afcc0c00dc9f901acce6d5b166ee51c497f8555 (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 3412c35d3da73b94c133099dceab9770fb465165
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Wed Oct 1 11:23:37 2014 -0400
3859: Added AlreadyLockedError for job lock conflict. Added runningbarbaz
fixture so test "cancel someone else's visible job" is testing the right thing.
diff --git a/services/api/app/models/arvados_model.rb b/services/api/app/models/arvados_model.rb
index 376df0c..2e17747 100644
--- a/services/api/app/models/arvados_model.rb
+++ b/services/api/app/models/arvados_model.rb
@@ -36,6 +36,12 @@ class ArvadosModel < ActiveRecord::Base
end
end
+ class AlreadyLockedError < StandardError
+ def http_status
+ 403
+ end
+ end
+
class UnauthorizedError < StandardError
def http_status
401
diff --git a/services/api/app/models/job.rb b/services/api/app/models/job.rb
index aa9075f..4b86be7 100644
--- a/services/api/app/models/job.rb
+++ b/services/api/app/models/job.rb
@@ -93,7 +93,7 @@ class Job < ArvadosModel
transaction do
self.reload
unless self.state == Queued and self.is_locked_by_uuid.nil?
- raise PermissionDeniedError
+ raise AlreadyLockedError
end
self.state = Running
self.is_locked_by_uuid = locked_by_uuid
diff --git a/services/api/test/fixtures/jobs.yml b/services/api/test/fixtures/jobs.yml
index b84922d..acb3bb4 100644
--- a/services/api/test/fixtures/jobs.yml
+++ b/services/api/test/fixtures/jobs.yml
@@ -124,6 +124,34 @@ barbaz:
runtime_constraints: {}
state: Complete
+runningbarbaz:
+ uuid: zzzzz-8i9sb-cjs4pklxxjykyuj
+ owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+ cancelled_at: ~
+ cancelled_by_user_uuid: ~
+ cancelled_by_client_uuid: ~
+ script_version: 7def43a4d3f20789dda4700f703b5514cc3ed250
+ script_parameters:
+ input: fa7aeb5140e2848d39b416daeef4ffc5+45
+ an_integer: 1
+ created_at: <%= 4.minute.ago.to_s(:db) %>
+ started_at: <%= 3.minute.ago.to_s(:db) %>
+ finished_at: <%= 2.minute.ago.to_s(:db) %>
+ running: true
+ success: ~
+ repository: foo
+ output: ea10d51bcf88862dbcc36eb292017dfd+45
+ priority: 0
+ log: d41d8cd98f00b204e9800998ecf8427e+0
+ is_locked_by_uuid: ~
+ tasks_summary:
+ failed: 0
+ todo: 0
+ running: 1
+ done: 0
+ runtime_constraints: {}
+ state: Running
+
previous_job_run:
uuid: zzzzz-8i9sb-cjs4pklxxjykqqq
created_at: <%= 14.minute.ago.to_s(:db) %>
diff --git a/services/api/test/integration/jobs_api_test.rb b/services/api/test/integration/jobs_api_test.rb
index 91d8d8f..bf86b7d 100644
--- a/services/api/test/integration/jobs_api_test.rb
+++ b/services/api/test/integration/jobs_api_test.rb
@@ -11,8 +11,8 @@ class JobsApiTest < ActionDispatch::IntegrationTest
end
test "cancel someone else's visible job" do
- post "/arvados/v1/jobs/#{jobs(:barbaz).uuid}/cancel", {:format => :json}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:spectator).api_token}"}
- assert_response 422
+ post "/arvados/v1/jobs/#{jobs(:runningbarbaz).uuid}/cancel", {:format => :json}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:spectator).api_token}"}
+ assert_response 403
end
test "cancel someone else's invisible job" do
diff --git a/services/api/test/unit/job_test.rb b/services/api/test/unit/job_test.rb
index ed10d91..19b6eb2 100644
--- a/services/api/test/unit/job_test.rb
+++ b/services/api/test/unit/job_test.rb
@@ -216,7 +216,7 @@ class JobTest < ActiveSupport::TestCase
job.lock current_user.uuid
assert_equal "Running", job.state
- assert_raises ArvadosModel::PermissionDeniedError do
+ assert_raises ArvadosModel::AlreadyLockedError do
# Can't lock it again
job.lock current_user.uuid
end
@@ -224,7 +224,7 @@ class JobTest < ActiveSupport::TestCase
assert_equal "Running", job.state
set_user_from_auth :project_viewer
- assert_raises ArvadosModel::PermissionDeniedError do
+ assert_raises ArvadosModel::AlreadyLockedError do
# Can't lock it as a different user either
job.lock current_user.uuid
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list