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