2017-09-10 17:25:29 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe BackgroundMigrationWorker, :sidekiq, :clean_gitlab_redis_shared_state do
|
|
|
|
let(:worker) { described_class.new }
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
describe '.perform' do
|
|
|
|
it 'performs a background migration' do
|
|
|
|
expect(Gitlab::BackgroundMigration)
|
|
|
|
.to receive(:perform)
|
|
|
|
.with('Foo', [10, 20])
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
worker.perform('Foo', [10, 20])
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it 'reschedules a migration if it was performed recently' do
|
|
|
|
expect(worker)
|
|
|
|
.to receive(:always_perform?)
|
|
|
|
.and_return(false)
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
worker.lease_for('Foo').try_obtain
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(Gitlab::BackgroundMigration)
|
|
|
|
.not_to receive(:perform)
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(described_class)
|
|
|
|
.to receive(:perform_in)
|
|
|
|
.with(a_kind_of(Numeric), 'Foo', [10, 20])
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
worker.perform('Foo', [10, 20])
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|