2017-06-02 11:12:36 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-01-04 10:49:15 -05:00
|
|
|
describe BackgroundMigrationWorker, :sidekiq, :clean_gitlab_redis_shared_state do
|
|
|
|
let(:worker) { described_class.new }
|
|
|
|
|
2017-06-02 11:12:36 -04:00
|
|
|
describe '.perform' do
|
|
|
|
it 'performs a background migration' do
|
2017-06-21 09:48:12 -04:00
|
|
|
expect(Gitlab::BackgroundMigration)
|
|
|
|
.to receive(:perform)
|
|
|
|
.with('Foo', [10, 20])
|
2017-06-02 11:12:36 -04:00
|
|
|
|
2018-01-04 10:49:15 -05:00
|
|
|
worker.perform('Foo', [10, 20])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'reschedules a migration if it was performed recently' do
|
|
|
|
expect(worker)
|
|
|
|
.to receive(:always_perform?)
|
|
|
|
.and_return(false)
|
|
|
|
|
|
|
|
worker.lease_for('Foo').try_obtain
|
|
|
|
|
|
|
|
expect(Gitlab::BackgroundMigration)
|
|
|
|
.not_to receive(:perform)
|
|
|
|
|
|
|
|
expect(described_class)
|
|
|
|
.to receive(:perform_in)
|
|
|
|
.with(a_kind_of(Numeric), 'Foo', [10, 20])
|
|
|
|
|
|
|
|
worker.perform('Foo', [10, 20])
|
2017-06-02 11:12:36 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|