X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0d62edcb9d25bf4dcdb20d8872ea7b438e12fc59..72d7d41944006d1f48f570784dafe56b9812b0c8:/apps/workbench/test/integration/work_units_test.rb diff --git a/apps/workbench/test/integration/work_units_test.rb b/apps/workbench/test/integration/work_units_test.rb index 5b5848ee77..36b29468ff 100644 --- a/apps/workbench/test/integration/work_units_test.rb +++ b/apps/workbench/test/integration/work_units_test.rb @@ -1,3 +1,7 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + require 'helpers/fake_websocket_helper' require 'integration_helper' @@ -8,21 +12,34 @@ class WorkUnitsTest < ActionDispatch::IntegrationTest need_javascript end - test "scroll all_processes page" do - expected_min, expected_max, expected, not_expected = [ - 25, 100, - ['/pipeline_instances/zzzzz-d1hrv-1yfj61234abcdk3', - '/pipeline_instances/zzzzz-d1hrv-jobspeccomponts', - '/jobs/zzzzz-8i9sb-grx15v5mjnsyxk7', - '/jobs/zzzzz-8i9sb-n7omg50bvt0m1nf', - '/container_requests/zzzzz-xvhdp-cr4completedcr2', - '/container_requests/zzzzz-xvhdp-cr4requestercn2'], - ['/pipeline_instances/zzzzz-d1hrv-scarxiyajtshq3l', - '/container_requests/zzzzz-xvhdp-oneof60crs00001'] - ] - + [[true, 25, 100, + ['/pipeline_instances/zzzzz-d1hrv-1yfj61234abcdk3', + '/pipeline_instances/zzzzz-d1hrv-1yfj61234abcdk4', + '/jobs/zzzzz-8i9sb-grx15v5mjnsyxk7', + '/jobs/zzzzz-8i9sb-n7omg50bvt0m1nf', + '/container_requests/zzzzz-xvhdp-cr4completedcr2', + '/container_requests/zzzzz-xvhdp-cr4requestercn2'], + ['/pipeline_instances/zzzzz-d1hrv-scarxiyajtshq3l', + '/container_requests/zzzzz-xvhdp-oneof60crs00001']], + [false, 25, 100, + ['/pipeline_instances/zzzzz-d1hrv-1yfj61234abcdk3', + '/pipeline_instances/zzzzz-d1hrv-1yfj61234abcdk4', + '/container_requests/zzzzz-xvhdp-cr4completedcr2'], + ['/pipeline_instances/zzzzz-d1hrv-scarxiyajtshq3l', + '/container_requests/zzzzz-xvhdp-oneof60crs00001', + '/jobs/zzzzz-8i9sb-grx15v5mjnsyxk7', + '/jobs/zzzzz-8i9sb-n7omg50bvt0m1nf', + '/container_requests/zzzzz-xvhdp-cr4requestercn2' + ]] + ].each do |show_children, expected_min, expected_max, expected, not_expected| + test "scroll all_processes page with show_children=#{show_children}" do visit page_with_token('active', "/all_processes") + if show_children + find('#IncludeChildProcs').click + wait_for_ajax + end + page_scrolls = expected_max/20 + 2 within('.arv-recent-all-processes') do (0..page_scrolls).each do |i| @@ -39,13 +56,13 @@ class WorkUnitsTest < ActionDispatch::IntegrationTest found_count = found_items.count if expected_min == expected_max assert_equal(true, found_count == expected_min, - "Not found expected number of items. Expected #{expected_min} and found #{found_count}") + "Not found expected number of items. Expected #{expected_min} and found #{found_count}") assert page.has_no_text? 'request failed' else assert_equal(true, found_count>=expected_min, - "Found too few items. Expected at least #{expected_min} and found #{found_count}") + "Found too few items. Expected at least #{expected_min} and found #{found_count}") assert_equal(true, found_count<=expected_max, - "Found too many items. Expected at most #{expected_max} and found #{found_count}") + "Found too many items. Expected at most #{expected_max} and found #{found_count}") end # verify that all expected uuid links are found @@ -57,14 +74,13 @@ class WorkUnitsTest < ActionDispatch::IntegrationTest not_expected.each do |link| assert_no_selector "a[href=\"#{link}\"]" end + end end [ - ['jobs', 'running_job_with_components', true], - ['pipeline_instances', 'components_is_jobspec', false], ['containers', 'running', false], ['container_requests', 'running', true], - ].each do |type, fixture, cancelable| + ].each do |type, fixture, cancelable, confirm_cancellation| test "cancel button for #{type}/#{fixture}" do if cancelable need_selenium 'to cancel' @@ -74,20 +90,36 @@ class WorkUnitsTest < ActionDispatch::IntegrationTest visit page_with_token "active", "/#{type}/#{obj['uuid']}" assert_text 'created_at' - if cancelable - assert_text 'priority: 1' if type.include?('container') - assert_selector 'button', text: 'Cancel' - first('a,button', text: 'Cancel').click + assert_text 'priority: 501' if type.include?('container') + if type.include?('pipeline') + assert_selector 'a', text: 'Pause' + first('a,link', text: 'Pause').click + else + assert_selector 'button', text: 'Cancel' + first('a,button', text: 'Cancel').click + end + if confirm_cancellation + alert = page.driver.browser.switch_to.alert + alert.accept + end wait_for_ajax end - assert_text 'priority: 0' if cancelable and type.include?('container') + + if type.include?('pipeline') + assert_selector 'a', text: 'Resume' + assert_no_selector 'a', text: 'Pause' + elsif type.include?('job') + assert_text 'Cancelled' + assert_text 'Paused' # this job has a pipeline child which was also cancelled + assert_no_selector 'button', text: 'Cancel' + elsif cancelable + assert_text 'priority: 0' + end end end [ - ['jobs', 'running_job_with_components'], - ['pipeline_instances', 'has_component_with_completed_jobs'], ['container_requests', 'running'], ['container_requests', 'completed'], ].each do |type, fixture| @@ -109,12 +141,11 @@ class WorkUnitsTest < ActionDispatch::IntegrationTest end [ - ['Pipeline with default input specifications', 'part-one', 'Provide values for the following'], ['Workflow with default input specifications', 'this workflow has inputs specified', 'Provide a value for the following'], ].each do |template_name, preview_txt, process_txt| test "run a process using template #{template_name} from dashboard" do visit page_with_token('admin') - assert_text 'Recent pipelines and processes' # seeing dashboard now + assert_text 'Recent processes' # seeing dashboard now within('.recent-processes-actions') do assert page.has_link?('All processes') @@ -132,7 +163,9 @@ class WorkUnitsTest < ActionDispatch::IntegrationTest assert_text process_txt assert_selector 'a', text: template_name - assert_equal "Set value for ex_string_def", find('div.form-group > div > p.form-control-static > a', text: "hello-testing-123")[:"data-title"] + assert_equal "true", find('span[data-name="reuse_steps"]').text + + assert_equal "Set value for ex_string_def", find('div.form-group > div.form-control-static > a', text: "hello-testing-123")[:"data-title"] page.assert_selector 'a.disabled,button.disabled', text: 'Run' end @@ -194,7 +227,7 @@ class WorkUnitsTest < ActionDispatch::IntegrationTest old_attributes: {state: 'Running'}, new_attributes: {state: 'Complete', exit_code: 1}, }, - }, "Container #{c['uuid']} finished with exit code 1 (failure)"], + }, "Container #{c['uuid']} finished"], # It's unrealistic for state to change again once it's Complete, # but the logging code doesn't care, so we do it to keep the test # simple. @@ -212,28 +245,63 @@ class WorkUnitsTest < ActionDispatch::IntegrationTest end end - [ - ['jobs', 'active', 'running_job_with_components', 'component1', '/jobs/zzzzz-8i9sb-jyq01m7in1jlofj#Log'], - ['pipeline_instances', 'active', 'pipeline_in_running_state', 'foo', '/jobs/zzzzz-8i9sb-pshmckwoma9plh7#Log'], - ['pipeline_instances', nil, 'pipeline_in_publicly_accessible_project_but_other_objects_elsewhere', 'foo', 'Log unavailable'], - ].each do |type, token, fixture, child, log_link| - test "link_to_log for #{fixture} for #{token}" do - obj = api_fixture(type)[fixture] - if token - visit page_with_token token, "/#{type}/#{obj['uuid']}" - else - Rails.configuration.anonymous_user_token = - api_fixture("api_client_authorizations", "anonymous", "api_token") - visit "/#{type}/#{obj['uuid']}" - end + test 'Run from workflows index page' do + visit page_with_token('active', '/workflows') - click_link(child) + wf_count = page.all('a[data-original-title="show workflow"]').count + assert_equal true, wf_count>0 - if token - assert_selector "a[href=\"#{log_link}\"]" - else - assert_text log_link - end + # Run one of the workflows + wf_name = 'Workflow with input specifications' + within('tr', text: wf_name) do + find('a,button', text: 'Run').click + end + + # Choose project for the container_request being created + within('.modal-dialog') do + find('.selectable', text: 'A Project').click + find('button', text: 'Choose').click + end + + # In newly created container_request page now + assert_text 'A Project' # CR created in "A Project" + assert_text "This container request was created from the workflow #{wf_name}" + assert_match /Provide a value for .* then click the \"Run\" button to start the workflow/, page.text + end + + test 'Run workflow from show page' do + visit page_with_token('active', '/workflows/zzzzz-7fd4e-validwithinputs') + + find('a,button', text: 'Run this workflow').click + + # Choose project for the container_request being created + within('.modal-dialog') do + find('.selectable', text: 'A Project').click + find('button', text: 'Choose').click + end + + # In newly created container_request page now + assert_text 'A Project' # CR created in "A Project" + assert_text "This container request was created from the workflow" + assert_match /Provide a value for .* then click the \"Run\" button to start the workflow/, page.text + end + + test "create workflow with WorkflowRunnerResources" do + visit page_with_token('active', '/workflows/zzzzz-7fd4e-validwithinput3') + + find('a,button', text: 'Run this workflow').click + + # Choose project for the container_request being created + within('.modal-dialog') do + find('.selectable', text: 'A Project').click + find('button', text: 'Choose').click end + click_link 'Advanced' + click_link("API response") + assert_text('"container_image": "arvados/jobs:2.0.4"') + assert_text('"vcpus": 2') + assert_text('"ram": 1293942784') + assert_text('"--collection-cache-size=678"') + end end