Fix 2.4.2 upgrade notes formatting refs #19330
[arvados.git] / apps / workbench / test / integration_performance / collections_perf_test.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 require 'integration_helper'
6
7 # The tests in the "integration_performance" dir are not included in regular
8 #   build pipeline since it is not one of the "standard" test directories.
9 #
10 # To run tests in this directory use the following command:
11 # ./run-tests.sh WORKSPACE=~/arvados --only apps/workbench apps/workbench_test="TEST=test/integration_performance/*.rb"
12 #
13
14 class CollectionsPerfTest < ActionDispatch::IntegrationTest
15   setup do
16     Capybara.current_driver = :rack_test
17   end
18
19   def create_large_collection size, file_name_prefix
20     manifest_text = ". d41d8cd98f00b204e9800998ecf8427e+0"
21
22     i = 0
23     until manifest_text.length > size do
24       manifest_text << " 0:0:#{file_name_prefix}#{i.to_s}"
25       i += 1
26     end
27     manifest_text << "\n"
28
29     Rails.logger.info "Creating collection at #{Time.now.to_f}"
30     collection = Collection.create! ({manifest_text: manifest_text})
31     Rails.logger.info "Done creating collection at #{Time.now.to_f}"
32
33     collection
34   end
35
36   [
37     1000000,
38     10000000,
39     20000000,
40   ].each do |size|
41     test "Create and show large collection with manifest text of #{size}" do
42       use_token :active
43       new_collection = create_large_collection size, 'collection_file_name_with_prefix_'
44
45       Rails.logger.info "Visiting collection at #{Time.now.to_f}"
46       visit page_with_token('active', "/collections/#{new_collection.uuid}")
47       Rails.logger.info "Done visiting collection at #{Time.now.to_f}"
48
49       assert_selector "input[value=\"#{new_collection.uuid}\"]"
50       assert(page.has_link?('collection_file_name_with_prefix_0'), "Collection page did not include file link")
51     end
52   end
53
54   # This does not work with larger sizes because of need_javascript.
55   # Just use one test with 100,000 for now.
56   [
57     100000,
58   ].each do |size|
59     test "Create, show, and update description for large collection with manifest text of #{size}" do
60       need_javascript
61
62       use_token :active
63       new_collection = create_large_collection size, 'collection_file_name_with_prefix_'
64
65       Rails.logger.info "Visiting collection at #{Time.now.to_f}"
66       visit page_with_token('active', "/collections/#{new_collection.uuid}")
67       Rails.logger.info "Done visiting collection at #{Time.now.to_f}"
68
69       assert_selector "input[value=\"#{new_collection.uuid}\"]"
70       assert(page.has_link?('collection_file_name_with_prefix_0'), "Collection page did not include file link")
71
72       # edit description
73       Rails.logger.info "Editing description at #{Time.now.to_f}"
74       within('.arv-description-as-subtitle') do
75         find('.fa-pencil').click
76         find('.editable-input textarea').set('description for this large collection')
77         find('.editable-submit').click
78       end
79       Rails.logger.info "Done editing description at #{Time.now.to_f}"
80
81       assert_text 'description for this large collection'
82     end
83   end
84
85   [
86     [1000000, 10000],
87     [10000000, 10000],
88     [20000000, 10000],
89   ].each do |size1, size2|
90     test "Create one large collection of #{size1} and one small collection of #{size2} and combine them" do
91       use_token :active
92       first_collection = create_large_collection size1, 'collection_file_name_with_prefix_1_'
93       second_collection = create_large_collection size2, 'collection_file_name_with_prefix_2_'
94
95       Rails.logger.info "Visiting collections page at #{Time.now.to_f}"
96       visit page_with_token('active', "/collections")
97       Rails.logger.info "Done visiting collections page at at #{Time.now.to_f}"
98
99       assert_text first_collection.uuid
100       assert_text second_collection.uuid
101
102       within('tr', text: first_collection['uuid']) do
103         find('input[type=checkbox]').click
104       end
105
106       within('tr', text: second_collection['uuid']) do
107         find('input[type=checkbox]').click
108       end
109
110       Rails.logger.info "Clicking on combine collections option at #{Time.now.to_f}"
111       click_button 'Selection...'
112       within('.selection-action-container') do
113         click_link 'Create new collection with selected collections'
114       end
115       Rails.logger.info "Done combining collections at #{Time.now.to_f}"
116
117       assert(page.has_link?('collection_file_name_with_prefix_1_0'), "Collection page did not include file link")
118     end
119   end
120 end