1 require 'integration_helper'
2 require 'selenium-webdriver'
5 class PipelineInstancesTest < ActionDispatch::IntegrationTest
7 # Selecting collections requiresLocalStorage
8 headless = Headless.new
10 Capybara.current_driver = :selenium
13 test 'Create and run a pipeline' do
14 visit page_with_token('active_trustedclient')
16 visit '/pipeline_templates'
17 within('tr', text: 'Two Part Pipeline Template') do
18 find('a,button', text: 'Run').click
22 within('.modal-dialog') do
23 find('.selectable', text: 'A Project').click
24 find('button', text: 'Choose').click
27 # This pipeline needs input. So, Run should be disabled
28 page.assert_selector 'a.disabled,button.disabled', text: 'Run'
30 instance_page = current_path
32 # Add this collection to the project
34 find("#projects-menu").click
35 find('.dropdown-menu a,button', text: 'A Project').click
36 find('.btn', text: 'Add data').click
37 within('.modal-dialog') do
39 first('span', text: 'foo_tag').click
40 find('.btn', text: 'Add').click
42 using_wait_time(Capybara.default_wait_time * 3) do
46 click_link 'Jobs and pipelines'
47 find('tr[data-kind="arvados#pipelineInstance"]', text: '(none)').
48 find('a', text: 'Show').
51 assert find('p', text: 'Provide a value')
53 find('div.form-group', text: 'Foo/bar pair').
54 find('.btn', text: 'Choose').
57 within('.modal-dialog') do
58 assert(has_text?("Foo/bar pair"),
59 "pipeline input picker missing name of input")
61 first('span', text: 'foo_tag').click
62 find('button', text: 'OK').click
66 # Ensure that the collection's portable_data_hash, uuid and name
67 # are saved in the desired places. (#4015)
69 # foo_collection_in_aproject is the collection tagged with foo_tag.
70 col = api_fixture('collections', 'foo_collection_in_aproject')
72 click_link 'API response'
73 api_response = JSON.parse(find('div#advanced_api_response pre').text)
74 input_params = api_response['components']['part-one']['script_parameters']['input']
75 assert_equal input_params['value'], col['portable_data_hash']
76 assert_equal input_params['selection_name'], col['name']
77 assert_equal input_params['selection_uuid'], col['uuid']
79 # "Run" button is now enabled
80 page.assert_no_selector 'a.disabled,button.disabled', text: 'Run'
82 first('a,button', text: 'Run').click
84 # Pipeline is running. We have a "Pause" button instead now.
85 page.assert_selector 'a,button', text: 'Pause'
86 find('a,button', text: 'Pause').click
88 # Pipeline is stopped. It should now be in paused state and Runnable again.
89 assert page.has_text? 'Paused'
90 page.assert_no_selector 'a.disabled,button.disabled', text: 'Resume'
91 page.assert_selector 'a,button', text: 'Re-run with latest'
92 page.assert_selector 'a,button', text: 'Re-run options'
94 # Since it is test env, no jobs are created to run. So, graph not visible
95 assert_not page.has_text? 'Graph'
98 # Create a pipeline instance from within a project and run
99 test 'Create pipeline inside a project and run' do
100 visit page_with_token('active_trustedclient')
102 # Add this collection to the project using collections menu from top nav
104 find("#projects-menu").click
105 find('.dropdown-menu a,button', text: 'A Project').click
106 find('.btn', text: 'Add data').click
107 within('.modal-dialog') do
109 first('span', text: 'foo_tag').click
110 find('.btn', text: 'Add').click
112 using_wait_time(Capybara.default_wait_time * 3) do
116 create_and_run_pipeline_in_aproject true, 'Two Part Pipeline Template', false
119 # Create a pipeline instance from outside of a project
120 test 'Run a pipeline from dashboard' do
121 visit page_with_token('active_trustedclient')
122 create_and_run_pipeline_in_aproject false, 'Two Part Pipeline Template', false
125 test 'view pipeline with job and see graph' do
126 visit page_with_token('active_trustedclient')
128 visit '/pipeline_instances'
129 assert page.has_text? 'pipeline_with_job'
131 find('a', text: 'pipeline_with_job').click
133 # since the pipeline component has a job, expect to see the graph
134 assert page.has_text? 'Graph'
136 page.assert_selector "#provenance_graph"
139 test 'pipeline description' do
140 visit page_with_token('active_trustedclient')
142 visit '/pipeline_instances'
143 assert page.has_text? 'pipeline_with_job'
145 find('a', text: 'pipeline_with_job').click
147 within('.arv-description-as-subtitle') do
148 find('.fa-pencil').click
149 find('.editable-input textarea').set('*Textile description for pipeline instance*')
150 find('.editable-submit').click
155 assert page.has_no_text? '*Textile description for pipeline instance*'
156 assert page.has_text? 'Textile description for pipeline instance'
159 test "JSON popup available for strange components" do
160 uuid = api_fixture("pipeline_instances")["components_is_jobspec"]["uuid"]
161 visit page_with_token("active", "/pipeline_instances/#{uuid}")
162 click_on "Components"
163 assert(page.has_no_text?("script_parameters"),
164 "components JSON visible without popup")
165 click_on "Show components JSON"
166 assert(page.has_text?("script_parameters"),
167 "components JSON not found")
170 PROJECT_WITH_SEARCH_COLLECTION = "A Subproject"
171 def check_parameter_search(proj_name)
172 template = api_fixture("pipeline_templates")["parameter_with_search"]
173 search_text = template["components"]["with-search"]["script_parameters"]["input"]["search_for"]
174 visit page_with_token("active", "/pipeline_templates/#{template['uuid']}")
175 click_on "Run this pipeline"
176 within(".modal-dialog") do # Set project for the new pipeline instance
177 find(".selectable", text: proj_name).click
180 assert(has_text?("This pipeline was created from the template"), "did not land on pipeline instance page")
181 first("a.btn,button", text: "Choose").click
182 within(".modal-body") do
183 if (proj_name != PROJECT_WITH_SEARCH_COLLECTION)
184 # Switch finder modal to Subproject to find the Collection.
186 click_on PROJECT_WITH_SEARCH_COLLECTION
188 assert_equal(search_text, first("input").value,
189 "parameter search not preseeded")
190 assert(has_text?(api_fixture("collections")["baz_collection_name_in_asubproject"]["name"]),
191 "baz Collection not in preseeded search results")
195 test "Workbench respects search_for parameter in templates" do
196 check_parameter_search(PROJECT_WITH_SEARCH_COLLECTION)
199 test "Workbench preserves search_for parameter after project switch" do
200 check_parameter_search("A Project")
204 ['active', false, false, false, 'Two Part Pipeline Template', false],
205 ['active', false, false, true, 'Two Part Pipeline Template', false],
206 ['active', true, false, false, 'Two Part Pipeline Template', false],
207 ['active', true, true, false, 'Two Part Pipeline Template', false],
208 ['active', true, false, true, 'Two Part Pipeline Template', false],
209 ['active', true, true, true, 'Two Part Pipeline Template', false],
210 ['project_viewer', false, false, true, 'Two Part Pipeline Template', false],
211 ['project_viewer', true, false, true, 'Two Part Pipeline Template', false],
212 ['project_viewer', true, true, true, 'Two Part Pipeline Template', false],
213 ['active', false, false, false, 'Two Part Template with dataclass File', true],
214 ['active', false, false, true, 'Two Part Template with dataclass File', true],
215 ].each do |user, with_options, choose_options, in_aproject, template_name, choose_file|
216 test "Rerun pipeline instance as #{user} using options #{with_options} #{choose_options}
217 in #{in_aproject} with #{template_name} with file #{choose_file}" do
218 visit page_with_token('active')
220 # need bigger modal size when choosing a file from collection
221 Capybara.current_session.driver.browser.manage.window.resize_to(1024, 768)
224 find("#projects-menu").click
225 find('.dropdown-menu a,button', text: 'A Project').click
228 create_and_run_pipeline_in_aproject in_aproject, template_name, choose_file
229 instance_path = current_path
232 find('a,button', text: 'Pause').click
233 assert page.has_text? 'Paused'
234 page.assert_no_selector 'a.disabled,button.disabled', text: 'Resume'
235 page.assert_selector 'a,button', text: 'Re-run with latest'
236 page.assert_selector 'a,button', text: 'Re-run options'
238 # Pipeline can be re-run now. Access it as the specified user, and re-run
239 if user == 'project_viewer'
240 visit page_with_token(user, instance_path)
241 assert page.has_text? 'A Project'
242 page.assert_no_selector 'a.disabled,button.disabled', text: 'Resume'
243 page.assert_selector 'a,button', text: 'Re-run with latest'
244 page.assert_selector 'a,button', text: 'Re-run options'
247 # Now re-run the pipeline
249 find('a,button', text: 'Re-run options').click
250 within('.modal-dialog') do
251 page.assert_selector 'a,button', text: 'Copy and edit inputs'
252 page.assert_selector 'a,button', text: 'Run now'
254 find('button', text: 'Copy and edit inputs').click
256 find('button', text: 'Run now').click
260 find('a,button', text: 'Re-run with latest').click
263 # Verify that the newly created instance is created in the right project.
264 # In case of project_viewer user, since the use cannot write to the project,
265 # the pipeline should have been created in the user's Home project.
266 rerun_instance_path = current_path
267 assert_not_equal instance_path, rerun_instance_path, 'Rerun instance path expected to be different'
268 assert page.has_text? 'Home'
269 if in_aproject && (user != 'project_viewer')
270 assert page.has_text? 'A Project'
272 assert page.has_no_text? 'A Project'
277 # Create and run a pipeline for 'Two Part Pipeline Template' in 'A Project'
278 def create_and_run_pipeline_in_aproject in_aproject, template_name, choose_file
279 # create a pipeline instance
280 find('.btn', text: 'Run a pipeline').click
281 within('.modal-dialog') do
282 find('.selectable', text: template_name).click
283 find('.btn', text: 'Next: choose inputs').click
286 assert find('p', text: 'Provide a value')
288 find('div.form-group', text: 'Foo/bar pair').
289 find('.btn', text: 'Choose').
292 within('.modal-dialog') do
294 assert_selector 'button.dropdown-toggle', text: 'A Project'
297 assert_selector 'button.dropdown-toggle', text: 'Home'
300 click_link "A Project"
303 first('span', text: 'foo_tag').click
306 find('input[type=checkbox]').click
308 find('button', text: 'OK').click
312 # Ensure that the collection's portable_data_hash, uuid and name
313 # are saved in the desired places. (#4015)
315 # foo_collection_in_aproject is the collection tagged with foo_tag.
316 col = api_fixture('collections', 'foo_collection_in_aproject')
317 click_link 'Advanced'
318 click_link 'API response'
319 api_response = JSON.parse(find('div#advanced_api_response pre').text)
320 input_params = api_response['components']['part-one']['script_parameters']['input']
321 assert_equal(input_params['selection_uuid'], col['uuid'], "Not found expected input param uuid")
323 assert_equal(input_params['value'], col['portable_data_hash']+'/foo', "Not found expected input file param value")
324 assert_equal(input_params['selection_name'], col['name']+'/foo', "Not found expected input file param name")
326 assert_equal(input_params['value'], col['portable_data_hash'], "Not found expected input param value")
327 assert_equal(input_params['selection_name'], col['name'], "Not found expected input param name")
330 # "Run" button present and enabled
331 page.assert_no_selector 'a.disabled,button.disabled', text: 'Run'
332 first('a,button', text: 'Run').click
334 # Pipeline is running. We have a "Pause" button instead now.
335 page.assert_no_selector 'a,button', text: 'Run'
336 page.assert_no_selector 'a.disabled,button.disabled', text: 'Resume'
337 page.assert_selector 'a,button', text: 'Pause'
339 # Since it is test env, no jobs are created to run. So, graph not visible
340 assert_not page.has_text? 'Graph'
344 [1, 0], # run time 0 minutes
345 [10, 17*60*60 + 51*60], # run time 17 hours and 51 minutes
346 ].each do |index, run_time|
347 test "pipeline start and finish time display #{index}" do
348 visit page_with_token("user1_with_load", "/pipeline_instances/zzzzz-d1hrv-10pipelines0#{index.to_s.rjust(3, '0')}")
350 assert page.has_text? 'This pipeline started at'
351 page_text = page.text
353 match = /This pipeline started at (.*)\. It failed after (.*) seconds at (.*)\. Check the Log/.match page_text
354 assert_not_nil(match, 'Did not find text - This pipeline started at . . . ')
357 finished_at = match[3]
358 assert_not_nil(start_at, 'Did not find start_at time')
359 assert_not_nil(finished_at, 'Did not find finished_at time')
361 # start and finished time display is of the format '2:20 PM 10/20/2014'
362 start_time = DateTime.strptime(start_at, '%H:%M %p %m/%d/%Y').to_time
363 finished_time = DateTime.strptime(finished_at, '%H:%M %p %m/%d/%Y').to_time
364 assert_equal(run_time, finished_time-start_time,
365 "Time difference did not match for start_at #{start_at}, finished_at #{finished_at}, ran_for #{match[2]}")