summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-06 12:10:44 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-06 12:10:44 +0000
commitba174c982f40d71a87fd511b091753807174f7e7 (patch)
treeb89d55c715288f2c2f76724c1b7ff4a6ebf90154 /spec/services
parenteaea945e0355826c58c3dcf887496ea91064f85c (diff)
downloadgitlab-ce-ba174c982f40d71a87fd511b091753807174f7e7.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/projects/hashed_storage/migration_service_spec.rb31
-rw-r--r--spec/services/projects/hashed_storage/rollback_service_spec.rb26
-rw-r--r--spec/services/web_hook_service_spec.rb10
3 files changed, 57 insertions, 10 deletions
diff --git a/spec/services/projects/hashed_storage/migration_service_spec.rb b/spec/services/projects/hashed_storage/migration_service_spec.rb
index f3ac26e7761..0a7975305dc 100644
--- a/spec/services/projects/hashed_storage/migration_service_spec.rb
+++ b/spec/services/projects/hashed_storage/migration_service_spec.rb
@@ -5,6 +5,11 @@ require 'spec_helper'
describe Projects::HashedStorage::MigrationService do
let(:project) { create(:project, :empty_repo, :wiki_repo, :legacy_storage) }
let(:logger) { double }
+ let!(:project_attachment) { build(:file_uploader, project: project) }
+ let(:project_hashed_path) { Storage::Hashed.new(project).disk_path }
+ let(:project_legacy_path) { Storage::LegacyProject.new(project).disk_path }
+ let(:wiki_hashed_path) { "#{project_hashed_path}.wiki" }
+ let(:wiki_legacy_path) { "#{project_legacy_path}.wiki" }
subject(:service) { described_class.new(project, project.full_path, logger: logger) }
@@ -29,9 +34,24 @@ describe Projects::HashedStorage::MigrationService do
service.execute
end
+
+ it 'migrates legacy repositories to hashed storage' do
+ legacy_attachments_path = FileUploader.absolute_base_dir(project)
+ hashed_project = project.dup.tap { |p| p.id = project.id }
+ hashed_project.storage_version = ::Project::HASHED_STORAGE_FEATURES[:attachments]
+ hashed_attachments_path = FileUploader.absolute_base_dir(hashed_project)
+
+ expect(logger).to receive(:info).with(/Repository moved from '#{project_legacy_path}' to '#{project_hashed_path}'/)
+ expect(logger).to receive(:info).with(/Repository moved from '#{wiki_legacy_path}' to '#{wiki_hashed_path}'/)
+ expect(logger).to receive(:info).with(/Project attachments moved from '#{legacy_attachments_path}' to '#{hashed_attachments_path}'/)
+
+ expect { service.execute }.to change { project.storage_version }.from(nil).to(2)
+ end
end
context 'attachments migration' do
+ let(:project) { create(:project, :empty_repo, :wiki_repo, storage_version: ::Project::HASHED_STORAGE_FEATURES[:repository]) }
+
let(:attachments_service) do
Projects::HashedStorage::MigrateAttachmentsService.new(project: project,
old_disk_path: project.full_path,
@@ -51,6 +71,17 @@ describe Projects::HashedStorage::MigrationService do
service.execute
end
+
+ it 'migrates legacy attachments to hashed storage' do
+ legacy_attachments_path = FileUploader.absolute_base_dir(project)
+ hashed_project = project.dup.tap { |p| p.id = project.id }
+ hashed_project.storage_version = ::Project::HASHED_STORAGE_FEATURES[:attachments]
+ hashed_attachments_path = FileUploader.absolute_base_dir(hashed_project)
+
+ expect(logger).to receive(:info).with(/Project attachments moved from '#{legacy_attachments_path}' to '#{hashed_attachments_path}'/)
+
+ expect { service.execute }.to change { project.storage_version }.from(1).to(2)
+ end
end
end
end
diff --git a/spec/services/projects/hashed_storage/rollback_service_spec.rb b/spec/services/projects/hashed_storage/rollback_service_spec.rb
index 48d4eac9eb7..e6b7daba99e 100644
--- a/spec/services/projects/hashed_storage/rollback_service_spec.rb
+++ b/spec/services/projects/hashed_storage/rollback_service_spec.rb
@@ -5,6 +5,11 @@ require 'spec_helper'
describe Projects::HashedStorage::RollbackService do
let(:project) { create(:project, :empty_repo, :wiki_repo) }
let(:logger) { double }
+ let!(:project_attachment) { build(:file_uploader, project: project) }
+ let(:project_hashed_path) { Storage::Hashed.new(project).disk_path }
+ let(:project_legacy_path) { Storage::LegacyProject.new(project).disk_path }
+ let(:wiki_hashed_path) { "#{project_hashed_path}.wiki" }
+ let(:wiki_legacy_path) { "#{project_legacy_path}.wiki" }
subject(:service) { described_class.new(project, project.disk_path, logger: logger) }
@@ -26,6 +31,20 @@ describe Projects::HashedStorage::RollbackService do
service.execute
end
+
+ it 'rollbacks to legacy storage' do
+ hashed_attachments_path = FileUploader.absolute_base_dir(project)
+ legacy_project = project.dup
+ legacy_project.storage_version = nil
+ legacy_attachments_path = FileUploader.absolute_base_dir(legacy_project)
+
+ expect(logger).to receive(:info).with(/Project attachments moved from '#{hashed_attachments_path}' to '#{legacy_attachments_path}'/)
+
+ expect(logger).to receive(:info).with(/Repository moved from '#{project_hashed_path}' to '#{project_legacy_path}'/)
+ expect(logger).to receive(:info).with(/Repository moved from '#{wiki_hashed_path}' to '#{wiki_legacy_path}'/)
+
+ expect { service.execute }.to change { project.storage_version }.from(2).to(nil)
+ end
end
context 'repository rollback' do
@@ -47,6 +66,13 @@ describe Projects::HashedStorage::RollbackService do
service.execute
end
+
+ it 'rollbacks to legacy storage' do
+ expect(logger).to receive(:info).with(/Repository moved from '#{project_hashed_path}' to '#{project_legacy_path}'/)
+ expect(logger).to receive(:info).with(/Repository moved from '#{wiki_hashed_path}' to '#{wiki_legacy_path}'/)
+
+ expect { service.execute }.to change { project.storage_version }.from(1).to(nil)
+ end
end
end
end
diff --git a/spec/services/web_hook_service_spec.rb b/spec/services/web_hook_service_spec.rb
index d8f13bc2e61..4a917ecdbb5 100644
--- a/spec/services/web_hook_service_spec.rb
+++ b/spec/services/web_hook_service_spec.rb
@@ -71,16 +71,6 @@ describe WebHookService do
end
end
- it 'POSTs to the webhook URL' do
- stub_full_request(project_hook.url, method: :post)
-
- service_instance.execute
-
- expect(WebMock).to have_requested(:post, stubbed_hostname(project_hook.url)).with(
- headers: headers
- ).once
- end
-
it 'POSTs the data as JSON' do
stub_full_request(project_hook.url, method: :post)