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