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, params: {id: cr['uuid'], tab_pane: 'Log'}, session: 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, params: {id: cr['uuid'], tab_pane: 'Log'}, session: 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, params: {id: uuid}, session: 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, params: {id: cr_fixture['uuid']}, session: 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, params: copy_params, session: 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['runtime_constraints']['ram'], copied_cr['runtime_constraints'][:ram]
83 assert copied_cr[:use_existing]
85 refute copied_cr[:use_existing]
87 # If the CR's command is arvados-cwl-runner, the appropriate flag should
91 # arvados-cwl-runner's default behavior is to enable reuse
92 assert_includes copied_cr['command'], 'arvados-cwl-runner'
93 assert_not_includes copied_cr['command'], '--disable-reuse'
95 assert_includes copied_cr['command'], 'arvados-cwl-runner'
96 assert_includes copied_cr['command'], '--disable-reuse'
97 assert_not_includes copied_cr['command'], '--enable-reuse'
100 # If no arvados-cwl-runner is being used, the command should be left alone
101 assert_equal completed_cr['command'], copied_cr['command']
110 ['uncommitted', false],
111 ].each do |cr_fixture, should_show|
112 test "provenance tab should #{should_show ? '' : 'not'} be shown on #{cr_fixture} container requests" do
113 cr = api_fixture('container_requests')[cr_fixture]
116 params: {id: cr['uuid']},
117 session: session_for(:active))
118 assert_response :success
120 assert_includes @response.body, "href=\"#Provenance\""
122 assert_not_includes @response.body, "href=\"#Provenance\""
127 test "container request display" do
130 cr = api_fixture('container_requests')['completed_with_input_mounts']
132 get :show, params: {id: cr['uuid']}, session: session_for(:active)
133 assert_response :success
135 assert_match /hello/, @response.body
136 assert_includes @response.body, "href=\"\/collections/fa7aeb5140e2848d39b416daeef4ffc5+45/baz\?" # locator on command
137 assert_includes @response.body, "href=\"\/collections/fa7aeb5140e2848d39b416daeef4ffc5+45/foobar\?" # locator on command
138 assert_includes @response.body, "href=\"\/collections/fa7aeb5140e2848d39b416daeef4ffc5+45/foo" # mount input1
139 assert_includes @response.body, "href=\"\/collections/fa7aeb5140e2848d39b416daeef4ffc5+45/bar" # mount input2
140 assert_includes @response.body, "href=\"\/collections/f9ddda46bb293b6847da984e3aa735db+290" # mount workflow
141 assert_includes @response.body, "href=\"#Log\""
142 assert_includes @response.body, "href=\"#Provenance\""