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