1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
7 class JobsApiTest < ActionDispatch::IntegrationTest
11 post "/arvados/v1/jobs/#{jobs(:running).uuid}/cancel",
12 params: {:format => :json},
13 headers: {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
14 assert_response :success
15 assert_equal "arvados#job", json_response['kind']
16 assert_not_nil json_response['cancelled_at']
19 test "cancel someone else's visible job" do
20 post "/arvados/v1/jobs/#{jobs(:runningbarbaz).uuid}/cancel",
21 params: {:format => :json},
22 headers: {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:spectator).api_token}"}
26 test "cancel someone else's invisible job" do
27 post "/arvados/v1/jobs/#{jobs(:running).uuid}/cancel",
28 params: {:format => :json},
29 headers: {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:spectator).api_token}"}
33 test "task qsequence values automatically increase monotonically" do
34 post_args = ["/arvados/v1/job_tasks",
36 job_uuid: jobs(:running).uuid,
39 headers: auth(:active)]
41 (1..3).each do |task_num|
44 assert_response :success
45 qsequence = json_response["qsequence"]
46 assert_not_nil(qsequence, "task not assigned qsequence")
47 assert_operator(qsequence, :>, last_qsequence,
48 "qsequence did not increase between tasks")
49 last_qsequence = qsequence
53 test 'get_delete components_get again for job with components' do
54 authorize_with :active
55 get "/arvados/v1/jobs/#{jobs(:running_job_with_components).uuid}",
56 headers: auth(:active)
58 assert_not_nil json_response["components"]
59 assert_equal ["component1", "component2"], json_response["components"].keys
61 # delete second component
62 put "/arvados/v1/jobs/#{jobs(:running_job_with_components).uuid}", params: {
64 components: {"component1" => "zzzzz-8i9sb-jobuuid00000001"}
67 }, headers: auth(:active)
70 get "/arvados/v1/jobs/#{jobs(:running_job_with_components).uuid}",
71 headers: auth(:active)
73 assert_not_nil json_response["components"]
74 assert_equal ["component1"], json_response["components"].keys
76 # delete all components
77 put "/arvados/v1/jobs/#{jobs(:running_job_with_components).uuid}", params: {
82 }, headers: auth(:active)
85 get "/arvados/v1/jobs/#{jobs(:running_job_with_components).uuid}",
86 headers: auth(:active)
88 assert_not_nil json_response["components"]
89 assert_equal [], json_response["components"].keys