Merge branch '14807-dispatch-cloud-fixes'
[arvados.git] / services / api / test / integration / pipeline_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
7 class PipelineIntegrationTest < ActionDispatch::IntegrationTest
8   # These tests simulate the workflow of arv-run-pipeline-instance
9   # and other pipeline-running code.
10
11   def check_component_match(comp_key, comp_hash)
12     assert_response :success
13     built_json = json_response
14     built_component = built_json["components"][comp_key]
15     comp_hash.each_pair do |key, expected|
16       assert_equal(expected, built_component[key.to_s],
17                    "component's #{key} field changed")
18     end
19   end
20
21   test "creating a pipeline instance preserves required component parameters" do
22     comp_name = "test_component"
23     component = {
24       repository: "test_repo",
25       script: "test_script",
26       script_version: "test_refspec",
27       script_parameters: {},
28     }
29
30     post("/arvados/v1/pipeline_instances",
31          {pipeline_instance: {components: {comp_name => component}}.to_json},
32          auth(:active))
33     check_component_match(comp_name, component)
34     pi_uuid = json_response["uuid"]
35
36     @response = nil
37     get("/arvados/v1/pipeline_instances/#{pi_uuid}", {}, auth(:active))
38     check_component_match(comp_name, component)
39   end
40 end