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

     1  require_relative './base_tests.rb'
     2  
     3  N_FILES_INIT = 1000
     4  N_INSERTS_OR_DELETES = 1000
     5  
     6  # This test creates a sharing with many inserts and deletes
     7  
     8  # Create the instances
     9  inst_names = ["Alice", "Bob"]
    10  insts = create_instances inst_names
    11  inst_a = insts[0]
    12  inst_b = insts[1]
    13  
    14  # Create the hierarchy to share
    15  folder = Folder.create inst_a
    16  dirs, files = create_hierarchy inst_a, folder, N_FILES_INIT
    17  
    18  # Create the sharing
    19  create_sharing insts, folder
    20  
    21  # Check everything went well
    22  da = File.join Helpers.current_dir, inst_a.domain, folder.name
    23  db = File.join Helpers.current_dir, inst_b.domain, "/#{Helpers::SHARED_WITH_ME}/#{folder.name}"
    24  poll_for_diff da, db
    25  
    26  # Randomly add or remove folder/files in the hierarchy
    27  N_INSERTS_OR_DELETES.times do
    28    is_creation = (dirs.length + files.length) < 2 ? true : [true, false].sample
    29    if is_creation
    30      create_dir_or_file inst_a, dirs, files
    31    else
    32      remove_folder_or_file inst_a, dirs, files
    33    end
    34  end
    35  poll_for_diff da, db