2019-11-21 07:06:40 -05:00
|
|
|
require './spec/support/sidekiq_middleware'
|
2018-12-06 04:42:55 -05:00
|
|
|
|
|
|
|
Sidekiq::Testing.inline! do
|
|
|
|
Gitlab::Seeder.quiet do
|
2019-11-15 07:06:12 -05:00
|
|
|
User.not_mass_generated.sample(10).each do |user|
|
|
|
|
source_project = Project.not_mass_generated.public_only.sample
|
2018-12-26 01:05:17 -05:00
|
|
|
|
|
|
|
##
|
2019-09-18 10:02:45 -04:00
|
|
|
# 03_project.rb might not have created a public project because
|
2018-12-26 01:05:17 -05:00
|
|
|
# we use randomized approach (e.g. `Array#sample`).
|
2018-12-25 19:40:19 -05:00
|
|
|
return unless source_project
|
|
|
|
|
2020-07-02 08:09:02 -04:00
|
|
|
Sidekiq::Worker.skipping_transaction_check do
|
|
|
|
fork_project = Projects::ForkService.new(
|
|
|
|
source_project,
|
|
|
|
user,
|
|
|
|
namespace: user.namespace,
|
|
|
|
skip_disk_validation: true
|
|
|
|
).execute
|
2018-12-06 04:42:55 -05:00
|
|
|
|
2020-07-02 08:09:02 -04:00
|
|
|
# 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
|
2018-12-06 04:42:55 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|