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