Commit 4ad251d3 authored by Kamil Trzciński's avatar Kamil Trzciński

Truly create forks when seeding DB

Previously we would not run after commit hooks.
This resulted in a defunct forks.

This additionaly ensures that we generate
only on legitimate users, instead of mass
generated.
parent 4f81918a
......@@ -10,6 +10,7 @@ Sidekiq::Testing.inline! do
# we use randomized approach (e.g. `Array#sample`).
return unless source_project
Sidekiq::Worker.skipping_transaction_check do
fork_project = Projects::ForkService.new(
source_project,
user,
......@@ -17,11 +18,23 @@ Sidekiq::Testing.inline! do
skip_disk_validation: true
).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 '.'
else
print 'F'
end
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