1 require 'helpers/fake_websocket_helper'
2 require 'integration_helper'
4 class WorkUnitsTest < ActionDispatch::IntegrationTest
5 include FakeWebsocketHelper
11 test "scroll all_processes page" do
12 expected_min, expected_max, expected, not_expected = [
14 ['/pipeline_instances/zzzzz-d1hrv-1yfj61234abcdk3',
15 '/pipeline_instances/zzzzz-d1hrv-jobspeccomponts',
16 '/jobs/zzzzz-8i9sb-grx15v5mjnsyxk7',
17 '/jobs/zzzzz-8i9sb-n7omg50bvt0m1nf',
18 '/container_requests/zzzzz-xvhdp-cr4completedcr2',
19 '/container_requests/zzzzz-xvhdp-cr4requestercn2'],
20 ['/pipeline_instances/zzzzz-d1hrv-scarxiyajtshq3l',
21 '/container_requests/zzzzz-xvhdp-oneof60crs00001']
24 visit page_with_token('active', "/all_processes")
26 page_scrolls = expected_max/20 + 2
27 within('.arv-recent-all-processes') do
28 (0..page_scrolls).each do |i|
29 page.driver.scroll_to 0, 999000
37 # Verify that expected number of processes are found
38 found_items = page.all('tr[data-object-uuid]')
39 found_count = found_items.count
40 if expected_min == expected_max
41 assert_equal(true, found_count == expected_min,
42 "Not found expected number of items. Expected #{expected_min} and found #{found_count}")
43 assert page.has_no_text? 'request failed'
45 assert_equal(true, found_count>=expected_min,
46 "Found too few items. Expected at least #{expected_min} and found #{found_count}")
47 assert_equal(true, found_count<=expected_max,
48 "Found too many items. Expected at most #{expected_max} and found #{found_count}")
51 # verify that all expected uuid links are found
52 expected.each do |link|
53 assert_selector "a[href=\"#{link}\"]"
56 # verify that none of the not_expected uuid links are found
57 not_expected.each do |link|
58 assert_no_selector "a[href=\"#{link}\"]"
63 ['jobs', 'running_job_with_components', true],
64 ['pipeline_instances', 'components_is_jobspec', false],
65 ['containers', 'running', false],
66 ['container_requests', 'running', true],
67 ].each do |type, fixture, cancelable|
68 test "cancel button for #{type}/#{fixture}" do
70 need_selenium 'to cancel'
73 obj = api_fixture(type)[fixture]
74 visit page_with_token "active", "/#{type}/#{obj['uuid']}"
76 assert_text 'created_at'
79 assert_text 'priority: 1' if type.include?('container')
80 assert_selector 'button', text: 'Cancel'
81 first('a,button', text: 'Cancel').click
84 assert_text 'priority: 0' if cancelable and type.include?('container')
89 ['jobs', 'running_job_with_components'],
90 ['pipeline_instances', 'has_component_with_completed_jobs'],
91 ['container_requests', 'running'],
92 ['container_requests', 'completed'],
93 ].each do |type, fixture|
94 test "edit description for #{type}/#{fixture}" do
95 obj = api_fixture(type)[fixture]
96 visit page_with_token "active", "/#{type}/#{obj['uuid']}"
98 within('.arv-description-as-subtitle') do
99 find('.fa-pencil').click
100 find('.editable-input textarea').set('*Textile description for object*')
101 find('.editable-submit').click
106 assert page.has_no_text? '*Textile description for object*'
107 assert page.has_text? 'Textile description for object'
112 ['Two Part Pipeline Template', 'part-one', 'Provide a value for the following'],
113 ['Workflow with input specifications', 'this workflow has inputs specified', 'Provide a value for the following'],
114 ].each do |template_name, preview_txt, process_txt|
115 test "run a process using template #{template_name} from dashboard" do
116 visit page_with_token('admin')
117 assert_text 'Recent pipelines and processes' # seeing dashboard now
119 within('.recent-processes-actions') do
120 assert page.has_link?('All processes')
121 find('a', text: 'Run a pipeline').click
124 # in the chooser, verify preview and click Next button
125 within('.modal-dialog') do
126 find('.selectable', text: template_name).click
127 assert_text preview_txt
128 find('.btn', text: 'Next: choose inputs').click
131 # in the process page now
132 assert_text process_txt
133 assert_selector 'a', text: template_name
137 test 'display container state changes in Container Request live log' do
138 use_fake_websocket_driver
139 c = api_fixture('containers')['queued']
140 cr = api_fixture('container_requests')['queued']
141 visit page_with_token('active', '/container_requests/'+cr['uuid'])
144 # The attrs of the "terminal window" text div in the log tab
145 # indicates which objects' events are worth displaying. Events
146 # that arrive too early (before that div exists) are not
147 # shown. For the user's sake, these early logs should also be
148 # retrieved and shown one way or another -- but in this particular
149 # test, we are only interested in logs that arrive by
150 # websocket. Therefore, to avoid races, we wait for the log tab to
151 # display before sending any events.
152 assert_text 'Recent logs'
155 event_type: 'dispatch',
157 text: "dispatch logged a fake message\n",
159 }, "dispatch logged"],
161 event_type: 'update',
163 old_attributes: {state: 'Locked'},
164 new_attributes: {state: 'Queued'},
166 }, "Container #{c['uuid']} was returned to the queue"],
168 event_type: 'update',
170 old_attributes: {state: 'Queued'},
171 new_attributes: {state: 'Locked'},
173 }, "Container #{c['uuid']} was taken from the queue by a dispatch process"],
175 event_type: 'crunch-run',
177 text: "according to fake crunch-run,\nsome setup stuff happened on the compute node\n",
179 }, "setup stuff happened"],
181 event_type: 'update',
183 old_attributes: {state: 'Locked'},
184 new_attributes: {state: 'Running'},
186 }, "Container #{c['uuid']} started"],
188 event_type: 'update',
190 old_attributes: {state: 'Running'},
191 new_attributes: {state: 'Complete', exit_code: 1},
193 }, "Container #{c['uuid']} finished with exit code 1 (failure)"],
194 # It's unrealistic for state to change again once it's Complete,
195 # but the logging code doesn't care, so we do it to keep the test
198 event_type: 'update',
200 old_attributes: {state: 'Running'},
201 new_attributes: {state: 'Cancelled'},
203 }, "Container #{c['uuid']} was cancelled"],
204 ].each do |send_event, expect_log_text|
205 assert_no_text(expect_log_text)
206 fake_websocket_event(send_event.merge(object_uuid: c['uuid']))
207 assert_text(expect_log_text)