X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/bb8669fd6be817468769fd5dd3faeed54f1e1888..80d28abfb972c34d7769fbfeac5e3b67049f216b:/services/api/test/functional/arvados/v1/jobs_controller_test.rb 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 c28cdf7dac..1e1425e92b 100644 --- a/services/api/test/functional/arvados/v1/jobs_controller_test.rb +++ b/services/api/test/functional/arvados/v1/jobs_controller_test.rb @@ -10,7 +10,7 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase post :create, job: { script: "hash", script_version: "master", - repository: "foo", + repository: "active/foo", script_parameters: {} } assert_response :success @@ -27,7 +27,7 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase script: "hash", script_version: "master", script_parameters: {}, - repository: "foo", + repository: "active/foo", started_at: Time.now, finished_at: Time.now, running: false, @@ -102,14 +102,16 @@ 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:{cancelled_at: nil}}, :unprocessable_entity], + [:put, :update, {job:{state: 'Cancelled'}}, :success], + [:put, :update, {job:{state: 'Queued'}}, :unprocessable_entity], + [: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 +120,15 @@ 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 + # Verify database record still says Cancelled + assert_equal 'Cancelled', Job.find(jobs(:cancelled).id).state, 'job was un-cancelled' end end @@ -395,4 +392,45 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase post :lock, {id: jobs(:running).uuid} assert_response 403 # forbidden end + + test 'reject invalid commit in remote repository' do + authorize_with :active + url = "http://localhost:1/fake/fake.git" + fetch_remote_from_local_repo url, :foo + post :create, job: { + script: "hash", + script_version: "abc123", + repository: url, + script_parameters: {} + } + assert_response 422 + end + + test 'tag remote commit in internal repository' do + authorize_with :active + url = "http://localhost:1/fake/fake.git" + fetch_remote_from_local_repo url, :foo + post :create, job: { + script: "hash", + script_version: "master", + repository: url, + script_parameters: {} + } + assert_response :success + assert_equal('077ba2ad3ea24a929091a9e6ce545c93199b8e57', + internal_tag(json_response['uuid'])) + end + + test 'tag local commit in internal repository' do + authorize_with :active + post :create, job: { + script: "hash", + script_version: "master", + repository: "active/foo", + script_parameters: {} + } + assert_response :success + assert_equal('077ba2ad3ea24a929091a9e6ce545c93199b8e57', + internal_tag(json_response['uuid'])) + end end