Commit 03310908 authored by Matija Čupić's avatar Matija Čupić

Yield job to BackgroundMigration#steal predicate

parent cd2ff96f
......@@ -33,7 +33,7 @@ module Gitlab
next unless job.queue == self.queue
next unless migration_class == steal_class
next if block_given? && !(yield migration_args)
next if block_given? && !(yield job)
begin
perform(migration_class, migration_args) if job.delete
......
......@@ -55,7 +55,7 @@ RSpec.describe Gitlab::BackgroundMigration do
expect(described_class).to receive(:perform)
.with('Foo', [10, 20])
described_class.steal('Foo') { |(arg1, arg2)| arg1 == 10 && arg2 == 20 }
described_class.steal('Foo') { |job| job.args.second.first == 10 && job.args.second.second == 20 }
end
it 'does not steal jobs that do not match the predicate' do
......
......@@ -513,6 +513,7 @@ RSpec.describe Gitlab::Database::PartitioningMigrationHelpers::TableManagementHe
context 'finishing pending background migration jobs' do
let(:source_table_double) { double('table name') }
let(:raw_arguments) { [1, 50_000, source_table_double, partitioned_table, source_column] }
let(:background_job) { double('background job', args: raw_arguments) }
before do
allow(migration).to receive(:table_exists?).with(partitioned_table).and_return(true)
......@@ -528,7 +529,7 @@ RSpec.describe Gitlab::Database::PartitioningMigrationHelpers::TableManagementHe
expect(Gitlab::BackgroundMigration).to receive(:steal)
.with(described_class::MIGRATION_CLASS_NAME)
.and_yield(raw_arguments)
.and_yield(background_job)
expect(source_table_double).to receive(:==).with(source_table.to_s)
......
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