From c2c34eba62f26bed8cad8b07934e14b4519eef7c Mon Sep 17 00:00:00 2001 From: Gabriel Mazetto Date: Sat, 22 Dec 2018 14:54:33 +0100 Subject: Prepare rake task for storage rollback We are keeping compatibility with existing scheduled jobs. --- spec/lib/gitlab/hashed_storage/migrator_spec.rb | 10 +++++----- spec/tasks/gitlab/storage_rake_spec.rb | 4 ++-- spec/workers/storage_migrator_worker_spec.rb | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'spec') diff --git a/spec/lib/gitlab/hashed_storage/migrator_spec.rb b/spec/lib/gitlab/hashed_storage/migrator_spec.rb index 01d43ed00a2..6d68cb0744b 100644 --- a/spec/lib/gitlab/hashed_storage/migrator_spec.rb +++ b/spec/lib/gitlab/hashed_storage/migrator_spec.rb @@ -4,7 +4,7 @@ describe Gitlab::HashedStorage::Migrator do describe '#bulk_schedule' do it 'schedules job to StorageMigratorWorker' do Sidekiq::Testing.fake! do - expect { subject.bulk_schedule(1, 5) }.to change(StorageMigratorWorker.jobs, :size).by(1) + expect { subject.bulk_schedule(start: 1, finish: 5) }.to change(StorageMigratorWorker.jobs, :size).by(1) end end end @@ -15,13 +15,13 @@ describe Gitlab::HashedStorage::Migrator do it 'enqueue jobs to ProjectMigrateHashedStorageWorker' do Sidekiq::Testing.fake! do - expect { subject.bulk_migrate(ids.min, ids.max) }.to change(ProjectMigrateHashedStorageWorker.jobs, :size).by(2) + expect { subject.bulk_migrate(start: ids.min, finish: ids.max) }.to change(ProjectMigrateHashedStorageWorker.jobs, :size).by(2) end end it 'rescues and log exceptions' do allow_any_instance_of(Project).to receive(:migrate_to_hashed_storage!).and_raise(StandardError) - expect { subject.bulk_migrate(ids.min, ids.max) }.not_to raise_error + expect { subject.bulk_migrate(start: ids.min, finish: ids.max) }.not_to raise_error end it 'delegates each project in specified range to #migrate' do @@ -29,12 +29,12 @@ describe Gitlab::HashedStorage::Migrator do expect(subject).to receive(:migrate).with(project) end - subject.bulk_migrate(ids.min, ids.max) + subject.bulk_migrate(start: ids.min, finish: ids.max) end it 'has migrated projects set as writable' do perform_enqueued_jobs do - subject.bulk_migrate(ids.min, ids.max) + subject.bulk_migrate(start: ids.min, finish: ids.max) end projects.each do |project| diff --git a/spec/tasks/gitlab/storage_rake_spec.rb b/spec/tasks/gitlab/storage_rake_spec.rb index be902d7c679..3b8d5ad7015 100644 --- a/spec/tasks/gitlab/storage_rake_spec.rb +++ b/spec/tasks/gitlab/storage_rake_spec.rb @@ -74,7 +74,7 @@ describe 'rake gitlab:storage:*' do it 'enqueues one StorageMigratorWorker per project' do projects.each do |project| - expect(StorageMigratorWorker).to receive(:perform_async).with(project.id, project.id) + expect(StorageMigratorWorker).to receive(:perform_async).with(project.id, project.id, :migrate) end run_rake_task(task) @@ -89,7 +89,7 @@ describe 'rake gitlab:storage:*' do it 'enqueues one StorageMigratorWorker per 2 projects' do projects.map(&:id).sort.each_slice(2) do |first, last| last ||= first - expect(StorageMigratorWorker).to receive(:perform_async).with(first, last) + expect(StorageMigratorWorker).to receive(:perform_async).with(first, last, :migrate) end run_rake_task(task) diff --git a/spec/workers/storage_migrator_worker_spec.rb b/spec/workers/storage_migrator_worker_spec.rb index 808084c8f7c..63f3c1d1c59 100644 --- a/spec/workers/storage_migrator_worker_spec.rb +++ b/spec/workers/storage_migrator_worker_spec.rb @@ -7,7 +7,7 @@ describe StorageMigratorWorker do describe '#perform' do it 'delegates to MigratorService' do - expect_any_instance_of(Gitlab::HashedStorage::Migrator).to receive(:bulk_migrate).with(5, 10) + expect_any_instance_of(Gitlab::HashedStorage::Migrator).to receive(:bulk_migrate).with(start: 5, finish: 10, operation: :migrate) worker.perform(5, 10) end -- cgit v1.2.1