[ARVADOS] updated: b6756a24c6f7269de13719620edb1a93df295d74
Git user
git at public.curoverse.com
Fri Jul 14 16:34:40 EDT 2017
Summary of changes:
services/api/app/models/container_request.rb | 2 +-
.../v1/container_requests_controller_test.rb | 15 --------------
services/api/test/unit/container_request_test.rb | 24 ++++++++++++++++++++++
3 files changed, 25 insertions(+), 16 deletions(-)
via b6756a24c6f7269de13719620edb1a93df295d74 (commit)
from 27b7b6699084cf091b50f44139232860c5804715 (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 b6756a24c6f7269de13719620edb1a93df295d74
Author: radhika <radhika at curoverse.com>
Date: Fri Jul 14 16:32:13 2017 -0400
11682: before_destroy callback sets prority to zero only when the container_request is not in Final state.
Arvados-DCO-1.1-Signed-off-by: Radhika Chippada <radhika at curoverse.com>
diff --git a/services/api/app/models/container_request.rb b/services/api/app/models/container_request.rb
index ac40708..94e4e1f 100644
--- a/services/api/app/models/container_request.rb
+++ b/services/api/app/models/container_request.rb
@@ -264,7 +264,7 @@ class ContainerRequest < ArvadosModel
end
def set_priority_zero
- self.update_attributes!(priority: 0)
+ self.update_attributes!(priority: 0) if self.state != Final
end
def set_requesting_container_uuid
diff --git a/services/api/test/functional/arvados/v1/container_requests_controller_test.rb b/services/api/test/functional/arvados/v1/container_requests_controller_test.rb
index 4713a4a..4ebda97 100644
--- a/services/api/test/functional/arvados/v1/container_requests_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/container_requests_controller_test.rb
@@ -23,19 +23,4 @@ class Arvados::V1::ContainerRequestsControllerTest < ActionController::TestCase
assert_not_nil cr, 'Expected container request'
assert_equal sp, cr['scheduling_parameters']
end
-
- test "delete container_request and check its container's priority" do
- authorize_with :active
-
- # initially the container's priority is 1
- c = Container.find_by_uuid containers(:running_to_be_deleted).uuid
- assert_equal 1, c.priority
-
- post :destroy, id: container_requests(:running_to_be_deleted).uuid
- assert_response :success
-
- # now the container's priority should be set to zero
- c = Container.find_by_uuid containers(:running_to_be_deleted).uuid
- assert_equal 0, c.priority
- end
end
diff --git a/services/api/test/unit/container_request_test.rb b/services/api/test/unit/container_request_test.rb
index 280e939..e751d61 100644
--- a/services/api/test/unit/container_request_test.rb
+++ b/services/api/test/unit/container_request_test.rb
@@ -750,4 +750,28 @@ class ContainerRequestTest < ActiveSupport::TestCase
end
end
end
+
+ test "delete container_request and check its container's priority" do
+ act_as_user users(:active) do
+ cr = ContainerRequest.find_by_uuid container_requests(:running_to_be_deleted).uuid
+
+ # initially the cr's container has priority > 0
+ c = Container.find_by_uuid(cr.container_uuid)
+ assert_equal 1, c.priority
+
+ # destroy the cr
+ assert_nothing_raised {cr.destroy}
+
+ # the cr's container now has priority of 0
+ c = Container.find_by_uuid(cr.container_uuid)
+ assert_equal 0, c.priority
+ end
+ end
+
+ test "delete container_request in final state and expect no error due to before_destroy callback" do
+ act_as_user users(:active) do
+ cr = ContainerRequest.find_by_uuid container_requests(:completed).uuid
+ assert_nothing_raised {cr.destroy}
+ end
+ end
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list