summaryrefslogtreecommitdiff
path: root/spec/workers
diff options
context:
space:
mode:
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/hashed_storage/migrator_worker_spec.rb (renamed from spec/workers/storage_migrator_worker_spec.rb)4
-rw-r--r--spec/workers/project_migrate_hashed_storage_worker_spec.rb23
2 files changed, 14 insertions, 13 deletions
diff --git a/spec/workers/storage_migrator_worker_spec.rb b/spec/workers/hashed_storage/migrator_worker_spec.rb
index 63f3c1d1c59..a85f820a3eb 100644
--- a/spec/workers/storage_migrator_worker_spec.rb
+++ b/spec/workers/hashed_storage/migrator_worker_spec.rb
@@ -1,13 +1,13 @@
require 'spec_helper'
-describe StorageMigratorWorker do
+describe HashedStorage::MigratorWorker do
subject(:worker) { described_class.new }
let(:projects) { create_list(:project, 2, :legacy_storage, :empty_repo) }
let(:ids) { projects.map(&:id) }
describe '#perform' do
it 'delegates to MigratorService' do
- expect_any_instance_of(Gitlab::HashedStorage::Migrator).to receive(:bulk_migrate).with(start: 5, finish: 10, operation: :migrate)
+ expect_any_instance_of(Gitlab::HashedStorage::Migrator).to receive(:bulk_migrate).with(start: 5, finish: 10)
worker.perform(5, 10)
end
diff --git a/spec/workers/project_migrate_hashed_storage_worker_spec.rb b/spec/workers/project_migrate_hashed_storage_worker_spec.rb
index 18470923316..333eb6a0569 100644
--- a/spec/workers/project_migrate_hashed_storage_worker_spec.rb
+++ b/spec/workers/project_migrate_hashed_storage_worker_spec.rb
@@ -4,12 +4,13 @@ describe ProjectMigrateHashedStorageWorker, :clean_gitlab_redis_shared_state do
include ExclusiveLeaseHelpers
describe '#perform' do
- let(:project) { create(:project, :empty_repo) }
+ let(:project) { create(:project, :empty_repo, :legacy_storage) }
let(:lease_key) { "project_migrate_hashed_storage_worker:#{project.id}" }
- let(:lease_timeout) { ProjectMigrateHashedStorageWorker::LEASE_TIMEOUT }
+ let(:lease_timeout) { described_class::LEASE_TIMEOUT }
+ let(:migration_service) { ::Projects::HashedStorage::MigrationService }
it 'skips when project no longer exists' do
- expect(::Projects::HashedStorage::MigrationService).not_to receive(:new)
+ expect(migration_service).not_to receive(:new)
subject.perform(-1)
end
@@ -17,29 +18,29 @@ describe ProjectMigrateHashedStorageWorker, :clean_gitlab_redis_shared_state do
it 'skips when project is pending delete' do
pending_delete_project = create(:project, :empty_repo, pending_delete: true)
- expect(::Projects::HashedStorage::MigrationService).not_to receive(:new)
+ expect(migration_service).not_to receive(:new)
subject.perform(pending_delete_project.id)
end
- it 'delegates removal to service class when have exclusive lease' do
+ it 'delegates migration to service class when we have exclusive lease' do
stub_exclusive_lease(lease_key, 'uuid', timeout: lease_timeout)
- migration_service = spy
+ service_spy = spy
- allow(::Projects::HashedStorage::MigrationService)
+ allow(migration_service)
.to receive(:new).with(project, project.full_path, logger: subject.logger)
- .and_return(migration_service)
+ .and_return(service_spy)
subject.perform(project.id)
- expect(migration_service).to have_received(:execute)
+ expect(service_spy).to have_received(:execute)
end
- it 'skips when dont have lease when dont have exclusive lease' do
+ it 'skips when it cant acquire the exclusive lease' do
stub_exclusive_lease_taken(lease_key, timeout: lease_timeout)
- expect(::Projects::HashedStorage::MigrationService).not_to receive(:new)
+ expect(migration_service).not_to receive(:new)
subject.perform(project.id)
end