3 class Arvados::V1::JobsControllerTest < ActionController::TestCase
9 script_version: "master",
12 assert_response :success
13 assert_not_nil assigns(:object)
14 new_job = JSON.parse(@response.body)
15 assert_not_nil new_job['uuid']
16 assert_not_nil new_job['script_version'].match(/^[0-9a-f]{40}$/)
19 test "normalize output and log uuids when creating job" do
20 authorize_with :active
23 script_version: "master",
24 script_parameters: {},
26 finished_at: Time.now,
29 output: 'd41d8cd98f00b204e9800998ecf8427e+0+K@xyzzy',
30 log: 'd41d8cd98f00b204e9800998ecf8427e+0+K@xyzzy'
32 assert_response :success
33 assert_not_nil assigns(:object)
34 new_job = JSON.parse(@response.body)
35 assert_equal 'd41d8cd98f00b204e9800998ecf8427e+0', new_job['log']
36 assert_equal 'd41d8cd98f00b204e9800998ecf8427e+0', new_job['output']
37 version = new_job['script_version']
39 # Make sure version doesn't get mangled by normalize
40 assert_not_nil version.match(/^[0-9a-f]{40}$/)
47 assert_equal version, JSON.parse(@response.body)['script_version']
50 test "cancel a running job" do
51 # We need to verify that "cancel" creates a trigger file, so first
52 # let's make sure there is no stale trigger file.
54 File.unlink(Rails.configuration.crunch_refresh_trigger)
58 authorize_with :active
60 id: jobs(:running).uuid,
62 cancelled_at: 4.day.ago
65 assert_response :success
66 assert_not_nil assigns(:object)
67 job = JSON.parse(@response.body)
68 assert_not_nil job['uuid']
69 assert_not_nil job['cancelled_at']
70 assert_not_nil job['cancelled_by_user_uuid']
71 assert_not_nil job['cancelled_by_client_uuid']
72 assert_equal(true, Time.parse(job['cancelled_at']) > 1.minute.ago,
73 'server should correct bogus cancelled_at ' +
76 File.exists?(Rails.configuration.crunch_refresh_trigger),
77 'trigger file should be created when job is cancelled')
80 id: jobs(:running).uuid,
85 job = JSON.parse(@response.body)
86 assert_not_nil job['cancelled_at'], 'un-cancelled job stays cancelled'
89 test "update a job without failing script_version check" do
92 id: jobs(:uses_nonexistent_script_version).uuid,
94 owner_uuid: users(:admin).uuid
97 assert_response :success
99 id: jobs(:uses_nonexistent_script_version).uuid,
101 owner_uuid: users(:active).uuid
104 assert_response :success