[ARVADOS] created: fc2ae47151fd54b4cdcacada714ee40ff2039918
git at public.curoverse.com
git at public.curoverse.com
Mon Oct 6 09:58:23 EDT 2014
at fc2ae47151fd54b4cdcacada714ee40ff2039918 (commit)
commit fc2ae47151fd54b4cdcacada714ee40ff2039918
Author: Tom Clegg <tom at curoverse.com>
Date: Mon Oct 6 09:57:49 2014 -0400
3882: refactor update-or-cancel code.
diff --git a/services/api/test/functional/arvados/v1/jobs_controller_test.rb b/services/api/test/functional/arvados/v1/jobs_controller_test.rb
index c28cdf7..85b3056 100644
--- a/services/api/test/functional/arvados/v1/jobs_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/jobs_controller_test.rb
@@ -102,14 +102,14 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase
end
[
- ['cancelled_at', Time.now, :success],
- ['state', 'Cancelled', :success],
- ['state', 'Running', :unprocessable_entity],
- ['state', 'Failed', :unprocessable_entity],
- ['state', 'Complete', :unprocessable_entity],
- [:use_action, :cancel, :success],
- ].each do |attribute, value, expected_response|
- test "cancelled job stays cancelled when updated using #{attribute} #{value}" do
+ [:put, :update, {job:{cancelled_at: Time.now}}, :success],
+ [:put, :update, {job:{state: 'Cancelled'}}, :success],
+ [:put, :update, {job:{state: 'Running'}}, :unprocessable_entity],
+ [:put, :update, {job:{state: 'Failed'}}, :unprocessable_entity],
+ [:put, :update, {job:{state: 'Complete'}}, :unprocessable_entity],
+ [:post, :cancel, {}, :success],
+ ].each do |http_method, action, params, expected_response|
+ test "cancelled job stays cancelled after #{[http_method, action, params].inspect}" do
# We need to verify that "cancel" creates a trigger file, so first
# let's make sure there is no stale trigger file.
begin
@@ -118,20 +118,14 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase
end
authorize_with :active
- if attribute == :use_action
- post value, { id: jobs(:cancelled).uuid }
- else
- put :update, {
- id: jobs(:cancelled).uuid,
- job: {
- attribute => value
- }
- }
- end
+ self.send http_method, action, { id: jobs(:cancelled).uuid }.merge(params)
assert_response expected_response
- job = json_response
- assert_not_nil job['cancelled_at'], 'job cancelled again using #{attribute}=#{value} did not have cancelled_at value'
- assert_equal job['state'], 'Cancelled', 'cancelled again job state changed when updated using using #{attribute}=#{value}'
+ if expected_response == :success
+ job = json_response
+ assert_not_nil job['cancelled_at'], 'job cancelled again using #{attribute}=#{value} did not have cancelled_at value'
+ assert_equal job['state'], 'Cancelled', 'cancelled again job state changed when updated using using #{attribute}=#{value}'
+ end
+ assert_equal 'Cancelled', jobs(:cancelled).state, 'job was un-cancelled'
end
end
commit bb8669fd6be817468769fd5dd3faeed54f1e1888
Author: Tom Clegg <tom at curoverse.com>
Date: Mon Oct 6 09:41:25 2014 -0400
3882: Test response status and #cancel method.
diff --git a/services/api/test/functional/arvados/v1/jobs_controller_test.rb b/services/api/test/functional/arvados/v1/jobs_controller_test.rb
index a3d4452..c28cdf7 100644
--- a/services/api/test/functional/arvados/v1/jobs_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/jobs_controller_test.rb
@@ -102,12 +102,13 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase
end
[
- ['cancelled_at', Time.now],
- ['state', 'Cancelled'],
- ['state', 'Running'],
- ['state', 'Failed'],
- ['state', 'Complete'],
- ].each do |attribute, value|
+ ['cancelled_at', Time.now, :success],
+ ['state', 'Cancelled', :success],
+ ['state', 'Running', :unprocessable_entity],
+ ['state', 'Failed', :unprocessable_entity],
+ ['state', 'Complete', :unprocessable_entity],
+ [:use_action, :cancel, :success],
+ ].each do |attribute, value, expected_response|
test "cancelled job stays cancelled when updated using #{attribute} #{value}" do
# We need to verify that "cancel" creates a trigger file, so first
# let's make sure there is no stale trigger file.
@@ -117,13 +118,18 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase
end
authorize_with :active
- put :update, {
- id: jobs(:cancelled).uuid,
- job: {
- attribute => value
+ if attribute == :use_action
+ post value, { id: jobs(:cancelled).uuid }
+ else
+ put :update, {
+ id: jobs(:cancelled).uuid,
+ job: {
+ attribute => value
+ }
}
- }
- job = JSON.parse(@response.body)
+ end
+ assert_response expected_response
+ job = json_response
assert_not_nil job['cancelled_at'], 'job cancelled again using #{attribute}=#{value} did not have cancelled_at value'
assert_equal job['state'], 'Cancelled', 'cancelled again job state changed when updated using using #{attribute}=#{value}'
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list