Merge branch 'master' into 3219-further-docker-improvements
[arvados.git] / services / api / test / integration / crunch_dispatch_test.rb
1 require 'test_helper'
2 require 'helpers/git_test_helper'
3
4 class CrunchDispatchTest < ActionDispatch::IntegrationTest
5   include GitTestHelper
6
7   fixtures :all
8
9   @@crunch_dispatch_pid = nil
10
11   def launch_crunch_dispatch
12     @@crunch_dispatch_pid = Process.fork {
13       ENV['PATH'] = ENV['HOME'] + '/arvados/services/crunch:' + ENV['PATH']
14       exec(ENV['HOME'] + '/arvados/services/api/script/crunch-dispatch.rb')
15     }
16   end
17
18   teardown do
19     if @@crunch_dispatch_pid
20       Process.kill "TERM", @@crunch_dispatch_pid
21       Process.wait
22       @@crunch_dispatch_pid = nil
23     end
24   end
25
26   test "job runs" do
27     post "/arvados/v1/jobs", {
28       format: "json",
29       job: {
30         script: "log",
31         repository: "crunch_dispatch_test",
32         script_version: "f35f99b7d32bac257f5989df02b9f12ee1a9b0d6",
33         script_parameters: "{}"
34       }
35     }, auth(:admin)
36     assert_response :success
37   end
38 end