9119: Use Oj strict mode for decoding JSON.
[arvados.git] / services / api / test / integration / collections_performance_test.rb
1 require 'test_helper'
2 require 'helpers/manifest_examples'
3 require 'helpers/time_block'
4
5 class CollectionsApiPerformanceTest < ActionDispatch::IntegrationTest
6   include ManifestExamples
7
8   test "crud cycle for a collection with a big manifest" do
9     bigmanifest = time_block 'make example' do
10       make_manifest(streams: 100,
11                     files_per_stream: 100,
12                     blocks_per_file: 20,
13                     bytes_per_block: 2**26,
14                     api_token: api_token(:active))
15     end
16     json = time_block "JSON encode #{bigmanifest.length>>20}MiB manifest" do
17       Oj.dump({"manifest_text" => bigmanifest})
18     end
19     time_block 'create' do
20       post '/arvados/v1/collections', {collection: json}, auth(:active)
21       assert_response :success
22     end
23     uuid = json_response['uuid']
24     time_block 'read' do
25       get '/arvados/v1/collections/' + uuid, {}, auth(:active)
26       assert_response :success
27     end
28     time_block 'list' do
29       get '/arvados/v1/collections', {select: ['manifest_text'], filters: [['uuid', '=', uuid]].to_json}, auth(:active)
30       assert_response :success
31     end
32     time_block 'update' do
33       put '/arvados/v1/collections/' + uuid, {collection: json}, auth(:active)
34       assert_response :success
35     end
36     time_block 'delete' do
37       delete '/arvados/v1/collections/' + uuid, {}, auth(:active)
38     end
39   end
40
41   test "memory usage" do
42      hugemanifest = make_manifest(streams: 1,
43                                   files_per_stream: 2000,
44                                   blocks_per_file: 200,
45                                   bytes_per_block: 2**26,
46                                   api_token: api_token(:active))
47     json = time_block "JSON encode #{hugemanifest.length>>20}MiB manifest" do
48       Oj.dump({manifest_text: hugemanifest})
49     end
50      vmpeak "post" do
51        post '/arvados/v1/collections', {collection: json}, auth(:active)
52      end
53   end
54 end