Merge branch '8784-dir-listings'
[arvados.git] / services / api / test / integration / crunch_dispatch_test.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 require 'test_helper'
6 require 'helpers/git_test_helper'
7
8 class CrunchDispatchIntegrationTest < ActionDispatch::IntegrationTest
9   include GitTestHelper
10
11   fixtures :all
12
13   @@crunch_dispatch_pid = nil
14
15   def launch_crunch_dispatch
16     @@crunch_dispatch_pid = Process.fork {
17       ENV['PATH'] = ENV['HOME'] + '/arvados/services/crunch:' + ENV['PATH']
18       exec(ENV['HOME'] + '/arvados/services/api/script/crunch-dispatch.rb')
19     }
20   end
21
22   teardown do
23     if @@crunch_dispatch_pid
24       Process.kill "TERM", @@crunch_dispatch_pid
25       Process.wait
26       @@crunch_dispatch_pid = nil
27     end
28   end
29
30   test "job runs" do
31     post "/arvados/v1/jobs", {
32       format: "json",
33       job: {
34         script: "log",
35         repository: "active/crunchdispatchtest",
36         script_version: "f35f99b7d32bac257f5989df02b9f12ee1a9b0d6",
37         script_parameters: "{}"
38       }
39     }, auth(:admin)
40     assert_response :success
41   end
42 end