Commit 1dfbbbaf authored by Shinya Maeda's avatar Shinya Maeda

Merge branch 'fix-fixtures' into 'master'

Truly create forks when seeding DB

See merge request gitlab-org/gitlab!35770
parents 089b43a5 4ad251d3
......@@ -10,17 +10,30 @@ Sidekiq::Testing.inline! do
# we use randomized approach (e.g. `Array#sample`).
return unless source_project
fork_project = Projects::ForkService.new(
source_project,
user,
namespace: user.namespace,
skip_disk_validation: true
).execute
Sidekiq::Worker.skipping_transaction_check do
fork_project = Projects::ForkService.new(
source_project,
user,
namespace: user.namespace,
skip_disk_validation: true
).execute
if fork_project.valid?
print '.'
else
print 'F'
# Seed-Fu runs this entire fixture in a transaction, so the `after_commit`
# hook won't run until after the fixture is loaded. That is too late
# since the Sidekiq::Testing block has already exited. Force clearing
# the `after_commit` queue to ensure the job is run now.
fork_project.send(:_run_after_commit_queue)
fork_project.import_state.send(:_run_after_commit_queue)
# Expire repository cache after import to ensure
# valid_repo? call below returns a correct answer
fork_project.repository.expire_all_method_caches
if fork_project.valid? && fork_project.valid_repo?
print '.'
else
print 'F'
end
end
end
end
......
......@@ -18,6 +18,7 @@ module Gitlab
MASS_INSERT_PROJECT_START = 'mass_insert_project_'
MASS_INSERT_USER_START = 'mass_insert_user_'
REPORTED_USER_START = 'reported_user_'
ESTIMATED_INSERT_PER_MINUTE = 2_000_000
MASS_INSERT_ENV = 'MASS_INSERT'
......@@ -36,7 +37,7 @@ module Gitlab
included do
scope :not_mass_generated, -> do
where.not("username LIKE '#{MASS_INSERT_USER_START}%'")
where.not("username LIKE '#{MASS_INSERT_USER_START}%' OR username LIKE '#{REPORTED_USER_START}%'")
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment