16202: Add Workbench.SSHHelpHostSuffix
[arvados.git] / apps / workbench / test / integration_performance / collection_unit_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 BigCollectionTest < ActiveSupport::TestCase
13   include ManifestExamples
14
15   setup do
16     Blob.stubs(:sign_locator).returns 'd41d8cd98f00b204e9800998ecf8427e+0'
17   end
18
19   teardown do
20     Thread.current[:arvados_api_client] = nil
21   end
22
23   # You can try with compress=false here too, but at last check it
24   # didn't make a significant difference.
25   [true].each do |compress|
26     test "crud cycle for collection with big manifest (compress=#{compress})" do
27       Rails.configuration.Workbench.APIResponseCompression = compress
28       Thread.current[:arvados_api_client] = nil
29       crudtest
30     end
31   end
32
33   def crudtest
34     use_token :active
35     bigmanifest = time_block 'build example' do
36       make_manifest(streams: 100,
37                     files_per_stream: 100,
38                     blocks_per_file: 20,
39                     bytes_per_block: 0)
40     end
41     c = time_block "new (manifest size = #{bigmanifest.length>>20}MiB)" do
42       Collection.new manifest_text: bigmanifest
43     end
44     time_block 'create' do
45       c.save!
46     end
47     time_block 'read' do
48       Collection.find c.uuid
49     end
50     time_block 'read(cached)' do
51       Collection.find c.uuid
52     end
53     time_block 'list' do
54       list = Collection.select(['uuid', 'manifest_text']).filter [['uuid','=',c.uuid]]
55       assert_equal 1, list.count
56       assert_equal c.uuid, list.first.uuid
57       assert_not_nil list.first.manifest_text
58     end
59     time_block 'update(name-only)' do
60       manifest_text_length = c.manifest_text.length
61       c.update_attributes name: 'renamed during test case'
62       assert_equal c.manifest_text.length, manifest_text_length
63     end
64     time_block 'update' do
65       c.manifest_text += ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:empty.txt\n"
66       c.save!
67     end
68     time_block 'delete' do
69       c.destroy
70     end
71     time_block 'read(404)' do
72       assert_empty Collection.filter([['uuid','=',c.uuid]])
73     end
74   end
75 end