summaryrefslogtreecommitdiff
path: root/spec/workers
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-01-08 13:06:49 +0000
committerRémy Coutable <remy@rymai.me>2018-01-08 13:06:49 +0000
commit8ff0c9b15124a391bc2fc9059211d2b8d5373a2d (patch)
tree68338bf5810c4c00d08098b3d198e0acaa1025e7 /spec/workers
parent93f30e2d3f654051adbf2271783382b3de53245d (diff)
parent7f30bb9c29bc1ff0c903a16bbf678db31c7408ec (diff)
downloadgitlab-ce-8ff0c9b15124a391bc2fc9059211d2b8d5373a2d.tar.gz
Merge branch 'delay-background-migrations' into 'master'
Run background migrations with a minimum interval Closes #41624 See merge request gitlab-org/gitlab-ce!16230
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