github.com/cozy/cozy-stack@v0.0.0-20240603063001-31110fa4cae1/tests/system/scalability/sharings.rb (about)

     1  
     2  require_relative './base_tests.rb'
     3  
     4  N_SHARINGS = 100
     5  MAX_RECIPIENTS = 5
     6  N_FILES_INIT = 100
     7  
     8  # This test creates several sharings with several recipients
     9  
    10  # Create the instances
    11  names = Array.new(MAX_RECIPIENTS + 1) { Faker::Internet.domain_word }
    12  
    13  insts = create_instances names
    14  inst_a = insts[0]
    15  recipients = insts.drop 1
    16  
    17  N_SHARINGS.times do |i|
    18    # Create the hierarchy to share
    19    folder = Folder.create inst_a, name: Faker::Internet.unique.slug
    20    create_hierarchy inst_a, folder, N_FILES_INIT
    21  
    22    # Randomly select the recipients
    23    n_rec = Random.rand(MAX_RECIPIENTS) + 1
    24    recs = recipients.sample(n_rec)
    25    members = [inst_a]
    26    members.concat recs
    27  
    28    # Share it
    29    create_sharing members, folder
    30  
    31    # Check everything went well for each recipient of this sharing
    32    da = File.join Helpers.current_dir, inst_a.domain, folder.name
    33    rec_path = "/#{Helpers::SHARED_WITH_ME}/#{folder.name}"
    34    recs.each do |recipient|
    35      drec = File.join Helpers.current_dir, recipient.domain, rec_path
    36      poll_for_diff da, drec
    37    end
    38    puts "OK for sharing #{i + 1}"
    39  end