Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-01-08 16:06:49 +0300
committerLuke Bennett <lbennett@gitlab.com>2018-01-10 14:48:40 +0300
commitc76e5ef887c15190866c5984a37bdeaa961c3cc0 (patch)
tree3c36596249821099460c68d267ff75fb965ea354 /spec/workers
parent2e0f4f658133e975b792584153fd468c76c5e1ef (diff)
Merge branch 'delay-background-migrations' into 'master'
Run background migrations with a minimum interval Closes #41624 See merge request gitlab-org/gitlab-ce!16230 (cherry picked from commit 8ff0c9b15124a391bc2fc9059211d2b8d5373a2d) 7f30bb9c Run background migrations with a minimum interval
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/background_migration_worker_spec.rb23
1 files changed, 21 insertions, 2 deletions
diff --git a/spec/workers/background_migration_worker_spec.rb b/spec/workers/background_migration_worker_spec.rb
index 1c54cf55fa0..d67e7698635 100644
--- a/spec/workers/background_migration_worker_spec.rb
+++ b/spec/workers/background_migration_worker_spec.rb
@@ -1,13 +1,32 @@
require 'spec_helper'
-describe BackgroundMigrationWorker, :sidekiq do
+describe BackgroundMigrationWorker, :sidekiq, :clean_gitlab_redis_shared_state do
+ let(:worker) { described_class.new }
+
describe '.perform' do
it 'performs a background migration' do
expect(Gitlab::BackgroundMigration)
.to receive(:perform)
.with('Foo', [10, 20])
- described_class.new.perform('Foo', [10, 20])
+ 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])
end
end
end