1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
7 class ContainerRequestsControllerTest < ActionController::TestCase
8 test "visit completed container request log tab" do
11 cr = api_fixture('container_requests')['completed']
12 container_uuid = cr['container_uuid']
13 container = Container.find(container_uuid)
15 get :show, {id: cr['uuid'], tab_pane: 'Log'}, session_for(:active)
16 assert_response :success
18 assert_select "a", {:href=>"/collections/#{container['log']}", :text=>"Download the log"}
19 assert_select "a", {:href=>"#{container['log']}/baz"}
20 assert_not_includes @response.body, '<div id="event_log_div"'
23 test "visit running container request log tab" do
26 cr = api_fixture('container_requests')['running']
27 container_uuid = cr['container_uuid']
28 container = Container.find(container_uuid)
30 get :show, {id: cr['uuid'], tab_pane: 'Log'}, session_for(:active)
31 assert_response :success
33 assert_includes @response.body, '<div id="event_log_div"'
34 assert_select 'Download the log', false
37 test "completed container request offers re-run option" do
40 uuid = api_fixture('container_requests')['completed']['uuid']
42 get :show, {id: uuid}, session_for(:active)
43 assert_response :success
45 assert_includes @response.body, "action=\"/container_requests/#{uuid}/copy\""
49 ['completed', false, false],
50 ['completed', true, false],
51 ['completed-older', false, true],
52 ['completed-older', true, true],
53 ].each do |cr_fixture, reuse_enabled, uses_acr|
54 test "container request #{uses_acr ? '' : 'not'} using arvados-cwl-runner copy #{reuse_enabled ? 'with' : 'without'} reuse enabled" do
55 completed_cr = api_fixture('container_requests')[cr_fixture]
56 # Set up post request params
57 copy_params = {id: completed_cr['uuid']}
59 copy_params.merge!({use_existing: true})
61 post(:copy, copy_params, session_for(:active))
63 copied_cr = assigns(:object)
64 assert_not_nil copied_cr
65 assert_equal 'Uncommitted', copied_cr[:state]
66 assert_equal "Copy of #{completed_cr['name']}", copied_cr['name']
67 assert_equal completed_cr['cmd'], copied_cr['cmd']
68 assert_equal completed_cr['runtime_constraints']['ram'], copied_cr['runtime_constraints'][:ram]
70 assert copied_cr[:use_existing]
72 refute copied_cr[:use_existing]
74 # If the CR's command is arvados-cwl-runner, the appropriate flag should
78 # arvados-cwl-runner's default behavior is to enable reuse
79 assert_includes copied_cr['command'], 'arvados-cwl-runner'
80 assert_not_includes copied_cr['command'], '--disable-reuse'
82 assert_includes copied_cr['command'], 'arvados-cwl-runner'
83 assert_includes copied_cr['command'], '--disable-reuse'
84 assert_not_includes copied_cr['command'], '--enable-reuse'
87 # If no arvados-cwl-runner is being used, the command should be left alone
88 assert_equal completed_cr['command'], copied_cr['command']
97 ['uncommitted', false],
98 ].each do |cr_fixture, should_show|
99 test "provenance tab should #{should_show ? '' : 'not'} be shown on #{cr_fixture} container requests" do
100 cr = api_fixture('container_requests')[cr_fixture]
104 session_for(:active))
105 assert_response :success
107 assert_includes @response.body, "href=\"#Provenance\""
109 assert_not_includes @response.body, "href=\"#Provenance\""
114 test "container request display" do
117 cr = api_fixture('container_requests')['completed_with_input_mounts']
119 get :show, {id: cr['uuid']}, session_for(:active)
120 assert_response :success
122 assert_match /hello/, @response.body
123 assert_includes @response.body, "href=\"\/collections/fa7aeb5140e2848d39b416daeef4ffc5+45/foo" # mount input1
124 assert_includes @response.body, "href=\"\/collections/fa7aeb5140e2848d39b416daeef4ffc5+45/bar" # mount input2
125 assert_includes @response.body, "href=\"\/collections/1fd08fc162a5c6413070a8bd0bffc818+150" # mount workflow
126 assert_includes @response.body, "href=\"#Log\""
127 assert_includes @response.body, "href=\"#Provenance\""