17810: Fix S3 signature verification.
[arvados.git] / services / api / test / integration / collections_performance_test.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 require 'safe_json'
6 require 'test_helper'
7 require 'helpers/manifest_examples'
8 require 'helpers/time_block'
9
10 class CollectionsApiPerformanceTest < ActionDispatch::IntegrationTest
11   include ManifestExamples
12
13   slow_test "crud cycle for a collection with a big manifest" do
14     bigmanifest = time_block 'make example' do
15       make_manifest(streams: 100,
16                     files_per_stream: 100,
17                     blocks_per_file: 20,
18                     bytes_per_block: 2**26,
19                     api_token: api_token(:active))
20     end
21     json = time_block "JSON encode #{bigmanifest.length>>20}MiB manifest" do
22       SafeJSON.dump({"manifest_text" => bigmanifest})
23     end
24     time_block 'create' do
25       post '/arvados/v1/collections',
26         params: {collection: json},
27         headers: auth(:active)
28       assert_response :success
29     end
30     uuid = json_response['uuid']
31     time_block 'read' do
32       get '/arvados/v1/collections/' + uuid, params: {}, headers: auth(:active)
33       assert_response :success
34     end
35     time_block 'list' do
36       get '/arvados/v1/collections',
37         params: {select: ['manifest_text'], filters: [['uuid', '=', uuid]].to_json},
38         headers: auth(:active)
39       assert_response :success
40     end
41     time_block 'update' do
42       put '/arvados/v1/collections/' + uuid,
43         params: {collection: json},
44         headers: auth(:active)
45       assert_response :success
46     end
47     time_block 'delete' do
48       delete '/arvados/v1/collections/' + uuid, params: {}, headers: auth(:active)
49     end
50   end
51
52   slow_test "memory usage" do
53     hugemanifest = make_manifest(streams: 1,
54                                  files_per_stream: 2000,
55                                  blocks_per_file: 200,
56                                  bytes_per_block: 2**26,
57                                  api_token: api_token(:active))
58     json = time_block "JSON encode #{hugemanifest.length>>20}MiB manifest" do
59       SafeJSON.dump({manifest_text: hugemanifest})
60     end
61     vmpeak "post" do
62       post '/arvados/v1/collections',
63         params: {collection: json},
64         headers: auth(:active)
65     end
66   end
67 end