2022-05-07 20:08:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Database
|
|
|
|
module Migrations
|
2022-07-16 23:28:13 +05:30
|
|
|
class TestBackgroundRunner < BaseBackgroundRunner
|
2022-06-21 17:19:12 +05:30
|
|
|
def initialize(result_dir:)
|
2022-07-16 23:28:13 +05:30
|
|
|
super(result_dir: result_dir)
|
2022-05-07 20:08:51 +05:30
|
|
|
@job_coordinator = Gitlab::BackgroundMigration.coordinator_for_database(Gitlab::Database::MAIN_DATABASE_NAME)
|
|
|
|
end
|
|
|
|
|
|
|
|
def traditional_background_migrations
|
|
|
|
@job_coordinator.pending_jobs
|
|
|
|
end
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
def jobs_by_migration_name
|
|
|
|
traditional_background_migrations.group_by { |j| class_name_for_job(j) }
|
2022-05-07 20:08:51 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def run_job(job)
|
|
|
|
Gitlab::BackgroundMigration.perform(job.args[0], job.args[1])
|
|
|
|
end
|
|
|
|
|
|
|
|
def class_name_for_job(job)
|
|
|
|
job.args[0]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|