Merge branch 'master' into 6064-collection-output-of-perf-issue
[arvados.git] / apps / workbench / test / integration_performance / collections_perf_test.rb
1 require 'integration_helper'
2
3 class CollectionsPerfTest < ActionDispatch::IntegrationTest
4   setup do
5     Capybara.current_driver = :rack_test
6
7     skip "ENV variable RUN_INTG_PERF_TESTS with value 'y' is not found" if !ENV["RUN_INTG_PERF_TESTS"].andand.start_with? 'y'
8   end
9
10   def create_large_collection size, file_name_prefix
11     manifest_text = ". d41d8cd98f00b204e9800998ecf8427e+0"
12
13     i = 0
14     until manifest_text.length > size do
15       manifest_text << " 0:0:#{file_name_prefix}#{i.to_s}"
16       i += 1
17     end
18     manifest_text << "\n"
19
20     Collection.create! ({manifest_text: manifest_text})
21   end
22
23   [
24     1000000,
25     10000000,
26     20000000,
27   ].each do |size|
28     test "Create and show large collection with manifest text of #{size}" do
29       use_token :active
30       new_collection = create_large_collection size, 'collection_file_name_with_prefix_'
31
32       visit page_with_token('active', "/collections/#{new_collection.uuid}")
33
34       assert_text new_collection.uuid
35       assert(page.has_link?('collection_file_name_with_prefix_0'), "Collection page did not include file link")
36     end
37   end
38
39   # This does not work with larger sizes because of need_javascript.
40   # Just use one test with 100,000 for now.
41   [
42     100000,
43   ].each do |size|
44     test "Create, show, and update description for large collection with manifest text of #{size}" do
45       need_javascript
46
47       use_token :active
48       new_collection = create_large_collection size, 'collection_file_name_with_prefix_'
49
50       visit page_with_token('active', "/collections/#{new_collection.uuid}")
51
52       assert_text new_collection.uuid
53       assert(page.has_link?('collection_file_name_with_prefix_0'), "Collection page did not include file link")
54
55       # edit description
56       within('.arv-description-as-subtitle') do
57         find('.fa-pencil').click
58         find('.editable-input textarea').set('description for this large collection')
59         find('.editable-submit').click
60       end
61
62       assert_text 'description for this large collection'
63     end
64   end
65
66   [
67     [1000000, 10000],
68     [10000000, 10000],
69     [20000000, 10000],
70   ].each do |size1, size2|
71     test "Create one large collection of #{size1} and one small collection of #{size2} and combine them" do
72       use_token :active
73       first_collection = create_large_collection size1, 'collection_file_name_with_prefix_1_'
74       second_collection = create_large_collection size2, 'collection_file_name_with_prefix_2_'
75
76       visit page_with_token('active', "/collections")
77
78       assert_text first_collection.uuid
79       assert_text second_collection.uuid
80
81       within('tr', text: first_collection['uuid']) do
82         find('input[type=checkbox]').click
83       end
84
85       within('tr', text: second_collection['uuid']) do
86         find('input[type=checkbox]').click
87       end
88
89       click_button 'Selection...'
90       within('.selection-action-container') do
91         click_link 'Create new collection with selected collections'
92       end
93
94       assert(page.has_link?('collection_file_name_with_prefix_1_0'), "Collection page did not include file link")
95     end
96   end
97 end