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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-01 00:08:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-01 00:08:05 +0300
commitabae8f34f377519946a91101ef7abf504454531c (patch)
tree359fab0082860b6850d4a0a492b8f12eb3d4eb0b /spec/workers
parent580622bdb3c762a8e89facd8a3946881ee480442 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/namespaces/schedule_aggregation_worker_spec.rb11
-rw-r--r--spec/workers/project_update_repository_storage_worker_spec.rb30
2 files changed, 37 insertions, 4 deletions
diff --git a/spec/workers/namespaces/schedule_aggregation_worker_spec.rb b/spec/workers/namespaces/schedule_aggregation_worker_spec.rb
index a2ce9891b5f..e7da346df46 100644
--- a/spec/workers/namespaces/schedule_aggregation_worker_spec.rb
+++ b/spec/workers/namespaces/schedule_aggregation_worker_spec.rb
@@ -54,6 +54,17 @@ describe Namespaces::ScheduleAggregationWorker, '#perform', :clean_gitlab_redis_
end
end
+ it_behaves_like 'an idempotent worker' do
+ let(:job_args) { [group.id] }
+
+ it 'creates a single aggregation schedule' do
+ expect { worker.perform(*job_args) }
+ .to change { Namespace::AggregationSchedule.count }.by(1)
+ expect { worker.perform(*job_args) }
+ .not_to change { Namespace::AggregationSchedule.count }
+ end
+ end
+
def stub_aggregation_schedule_statistics
# Namespace::Aggregations are deleted by
# Namespace::AggregationSchedule::schedule_root_storage_statistics,
diff --git a/spec/workers/project_update_repository_storage_worker_spec.rb b/spec/workers/project_update_repository_storage_worker_spec.rb
index 4cc44281a69..ed99b8135c2 100644
--- a/spec/workers/project_update_repository_storage_worker_spec.rb
+++ b/spec/workers/project_update_repository_storage_worker_spec.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
require 'spec_helper'
+require 'securerandom'
describe ProjectUpdateRepositoryStorageWorker do
let(:project) { create(:project, :repository) }
@@ -8,12 +9,33 @@ describe ProjectUpdateRepositoryStorageWorker do
subject { described_class.new }
describe "#perform" do
- it "calls the update repository storage service" do
- expect_next_instance_of(Projects::UpdateRepositoryStorageService) do |instance|
- expect(instance).to receive(:execute).with('new_storage')
+ context 'when source and target repositories are on different filesystems' do
+ before do
+ allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('default').and_call_original
+ allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('new_storage').and_return(SecureRandom.uuid)
end
- subject.perform(project.id, 'new_storage')
+ it "calls the update repository storage service" do
+ expect_next_instance_of(Projects::UpdateRepositoryStorageService) do |instance|
+ expect(instance).to receive(:execute).with('new_storage')
+ end
+
+ subject.perform(project.id, 'new_storage')
+ end
+ end
+
+ context 'when source and target repositories are on the same filesystems' do
+ let(:filesystem_id) { SecureRandom.uuid }
+
+ before do
+ allow(Gitlab::GitalyClient).to receive(:filesystem_id).and_return(filesystem_id)
+ end
+
+ it 'raises an error' do
+ expect_any_instance_of(::Projects::UpdateRepositoryStorageService).not_to receive(:new)
+
+ expect { subject.perform(project.id, 'new_storage') }.to raise_error(ProjectUpdateRepositoryStorageWorker::SameFilesystemError)
+ end
end
end
end