12216: Allow Content-Type header via CORS.
[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', {collection: json}, auth(:active)
26       assert_response :success
27     end
28     uuid = json_response['uuid']
29     time_block 'read' do
30       get '/arvados/v1/collections/' + uuid, {}, auth(:active)
31       assert_response :success
32     end
33     time_block 'list' do
34       get '/arvados/v1/collections', {select: ['manifest_text'], filters: [['uuid', '=', uuid]].to_json}, auth(:active)
35       assert_response :success
36     end
37     time_block 'update' do
38       put '/arvados/v1/collections/' + uuid, {collection: json}, auth(:active)
39       assert_response :success
40     end
41     time_block 'delete' do
42       delete '/arvados/v1/collections/' + uuid, {}, auth(:active)
43     end
44   end
45
46   slow_test "memory usage" do
47     hugemanifest = make_manifest(streams: 1,
48                                  files_per_stream: 2000,
49                                  blocks_per_file: 200,
50                                  bytes_per_block: 2**26,
51                                  api_token: api_token(:active))
52     json = time_block "JSON encode #{hugemanifest.length>>20}MiB manifest" do
53       SafeJSON.dump({manifest_text: hugemanifest})
54     end
55     vmpeak "post" do
56       post '/arvados/v1/collections', {collection: json}, auth(:active)
57     end
58   end
59 end