2 require 'helpers/manifest_examples'
3 require 'helpers/time_block'
5 class CollectionModelPerformanceTest < ActiveSupport::TestCase
6 include ManifestExamples
9 # The Collection model needs to have a current token, not just a
10 # current user, to sign & verify manifests:
11 Thread.current[:api_client_authorization] =
12 api_client_authorizations(:active)
16 Thread.current[:api_client_authorization] = nil
19 # "crrud" == "create read render update delete", not a typo
20 test "crrud cycle for a collection with a big manifest)" do
22 bigmanifest = time_block 'make example' do
23 make_manifest(streams: 100,
24 files_per_stream: 100,
26 bytes_per_block: 2**26,
27 api_token: api_token(:active))
29 act_as_user users(:active) do
30 c = time_block "new (manifest_text is #{bigmanifest.length>>20}MiB)" do
31 Collection.new manifest_text: bigmanifest.dup
33 time_block 'check signatures' do
36 time_block 'check signatures + save' do
37 c.instance_eval do @signatures_checked = false end
40 c = time_block 'read' do
41 Collection.find_by_uuid(c.uuid)
44 c.signed_manifest_text
46 time_block 'sign + render' do
47 resp = c.as_api_response(nil)
49 loc = Blob.sign_locator(Digest::MD5.hexdigest('foo') + '+3',
50 api_token: api_token(:active))
51 # Note Collection's strip_manifest_text method has now removed
52 # the signatures from c.manifest_text, so we have to start from
53 # bigmanifest again here instead of just appending with "+=".
54 c.manifest_text = bigmanifest.dup + ". #{loc} 0:3:foo.txt\n"
55 time_block 'update' do
58 time_block 'delete' do