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,6 +10,7 @@ Sidekiq::Testing.inline! do ...@@ -10,6 +10,7 @@ Sidekiq::Testing.inline! do
# we use randomized approach (e.g. `Array#sample`). # we use randomized approach (e.g. `Array#sample`).
return unless source_project return unless source_project
Sidekiq::Worker.skipping_transaction_check do
fork_project = Projects::ForkService.new( fork_project = Projects::ForkService.new(
source_project, source_project,
user, user,
...@@ -17,11 +18,23 @@ Sidekiq::Testing.inline! do ...@@ -17,11 +18,23 @@ Sidekiq::Testing.inline! do
skip_disk_validation: true skip_disk_validation: true
).execute ).execute
if fork_project.valid? # 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 '.' print '.'
else else
print 'F' print 'F'
end end
end end
end end
end
end end
...@@ -18,6 +18,7 @@ module Gitlab ...@@ -18,6 +18,7 @@ module Gitlab
MASS_INSERT_PROJECT_START = 'mass_insert_project_' MASS_INSERT_PROJECT_START = 'mass_insert_project_'
MASS_INSERT_USER_START = 'mass_insert_user_' MASS_INSERT_USER_START = 'mass_insert_user_'
REPORTED_USER_START = 'reported_user_'
ESTIMATED_INSERT_PER_MINUTE = 2_000_000 ESTIMATED_INSERT_PER_MINUTE = 2_000_000
MASS_INSERT_ENV = 'MASS_INSERT' MASS_INSERT_ENV = 'MASS_INSERT'
...@@ -36,7 +37,7 @@ module Gitlab ...@@ -36,7 +37,7 @@ module Gitlab
included do included do
scope :not_mass_generated, -> 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 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