16750: Avoids using params on requests to make it compatible with federation.
[arvados.git] / apps / workbench / test / integration_performance / collections_controller_test.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 require 'test_helper'
6 require 'helpers/manifest_examples'
7 require 'helpers/time_block'
8
9 class Blob
10 end
11
12 class BigCollectionsControllerTest < ActionController::TestCase
13   include ManifestExamples
14
15   setup do
16     Blob.stubs(:sign_locator).returns 'd41d8cd98f00b204e9800998ecf8427e+0'
17   end
18
19   test "combine two big and two small collections" do
20     @controller = ActionsController.new
21     bigmanifest1 = time_block 'build example' do
22       make_manifest(streams: 100,
23                     files_per_stream: 100,
24                     blocks_per_file: 20,
25                     bytes_per_block: 0)
26     end
27     bigmanifest2 = bigmanifest1.gsub '.txt', '.txt2'
28     smallmanifest1 = ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:small1.txt\n"
29     smallmanifest2 = ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:small2.txt\n"
30     totalsize = bigmanifest1.length + bigmanifest2.length +
31       smallmanifest1.length + smallmanifest2.length
32     parts = time_block "create (total #{totalsize>>20}MiB)" do
33       use_token :active do
34         {
35           big1: Collection.create(manifest_text: bigmanifest1),
36           big2: Collection.create(manifest_text: bigmanifest2),
37           small1: Collection.create(manifest_text: smallmanifest1),
38           small2: Collection.create(manifest_text: smallmanifest2),
39         }
40       end
41     end
42     time_block 'combine' do
43       post :combine_selected_files_into_collection, {
44         selection: [parts[:big1].uuid,
45                     parts[:big2].uuid,
46                     parts[:small1].uuid + '/small1.txt',
47                     parts[:small2].uuid + '/small2.txt',
48                    ],
49         format: :html
50       }, session_for(:active)
51     end
52     assert_response :redirect
53   end
54
55   [:json, :html].each do |format|
56     test "show collection with big manifest (#{format})" do
57       bigmanifest = time_block 'build example' do
58         make_manifest(streams: 100,
59                       files_per_stream: 100,
60                       blocks_per_file: 20,
61                       bytes_per_block: 0)
62       end
63       @controller = CollectionsController.new
64       c = time_block "create (manifest size #{bigmanifest.length>>20}MiB)" do
65         use_token :active do
66           Collection.create(manifest_text: bigmanifest)
67         end
68       end
69       time_block 'show' do
70         get :show, {id: c.uuid, format: format}, session_for(:active)
71       end
72       assert_response :success
73     end
74   end
75 end