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, '<pre 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, '<pre 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\""
48 test "cancel request for queued container" do
49 cr_fixture = api_fixture('container_requests')['queued']
50 post :cancel, {id: cr_fixture['uuid']}, session_for(:active)
54 cr = ContainerRequest.find(cr_fixture['uuid'])
55 assert_equal 'Final', cr.state
56 assert_equal 0, cr.priority
57 c = Container.find(cr_fixture['container_uuid'])
58 assert_equal 'Queued', c.state
59 assert_equal 0, c.priority
63 ['completed', false, false],
64 ['completed', true, false],
65 ['completed-older', false, true],
66 ['completed-older', true, true],
67 ].each do |cr_fixture, reuse_enabled, uses_acr|
68 test "container request #{uses_acr ? '' : 'not'} using arvados-cwl-runner copy #{reuse_enabled ? 'with' : 'without'} reuse enabled" do
69 completed_cr = api_fixture('container_requests')[cr_fixture]
70 # Set up post request params
71 copy_params = {id: completed_cr['uuid']}
73 copy_params.merge!({use_existing: true})
75 post(:copy, copy_params, session_for(:active))
77 copied_cr = assigns(:object)
78 assert_not_nil copied_cr
79 assert_equal 'Uncommitted', copied_cr[:state]
80 assert_equal "Copy of #{completed_cr['name']}", copied_cr['name']
81 assert_equal completed_cr['cmd'], copied_cr['cmd']
82 assert_equal completed_cr['runtime_constraints']['ram'], copied_cr['runtime_constraints'][:ram]
84 assert copied_cr[:use_existing]
86 refute copied_cr[:use_existing]
88 # If the CR's command is arvados-cwl-runner, the appropriate flag should
92 # arvados-cwl-runner's default behavior is to enable reuse
93 assert_includes copied_cr['command'], 'arvados-cwl-runner'
94 assert_not_includes copied_cr['command'], '--disable-reuse'
96 assert_includes copied_cr['command'], 'arvados-cwl-runner'
97 assert_includes copied_cr['command'], '--disable-reuse'
98 assert_not_includes copied_cr['command'], '--enable-reuse'
101 # If no arvados-cwl-runner is being used, the command should be left alone
102 assert_equal completed_cr['command'], copied_cr['command']
111 ['uncommitted', false],
112 ].each do |cr_fixture, should_show|
113 test "provenance tab should #{should_show ? '' : 'not'} be shown on #{cr_fixture} container requests" do
114 cr = api_fixture('container_requests')[cr_fixture]
118 session_for(:active))
119 assert_response :success
121 assert_includes @response.body, "href=\"#Provenance\""
123 assert_not_includes @response.body, "href=\"#Provenance\""
128 test "container request display" do
131 cr = api_fixture('container_requests')['completed_with_input_mounts']
133 get :show, {id: cr['uuid']}, session_for(:active)
134 assert_response :success
136 assert_match /hello/, @response.body
137 assert_includes @response.body, "href=\"\/collections/fa7aeb5140e2848d39b416daeef4ffc5+45/foo" # mount input1
138 assert_includes @response.body, "href=\"\/collections/fa7aeb5140e2848d39b416daeef4ffc5+45/bar" # mount input2
139 assert_includes @response.body, "href=\"\/collections/1fd08fc162a5c6413070a8bd0bffc818+150" # mount workflow
140 assert_includes @response.body, "href=\"#Log\""
141 assert_includes @response.body, "href=\"#Provenance\""