Skip to content
Snippets Groups Projects
Commit 5edd94ae authored by Sean McGivern's avatar Sean McGivern
Browse files

Merge branch '40744-hashed-storage-specs' into 'master'

Use hashed storage in the specs

Closes #40744

See merge request gitlab-org/gitlab-ce!15681
parents 5708241b 6b0c6e69
No related branches found
No related tags found
No related merge requests found
Showing
with 193 additions and 159 deletions
Loading
@@ -168,84 +168,105 @@ describe Namespace do
Loading
@@ -168,84 +168,105 @@ describe Namespace do
end end
   
describe '#move_dir', :request_store do describe '#move_dir', :request_store do
let(:namespace) { create(:namespace) } shared_examples "namespace restrictions" do
let!(:project) { create(:project_empty_repo, namespace: namespace) } context "when any project has container images" do
let(:container_repository) { create(:container_repository) }
   
it "raises error when directory exists" do before do
expect { namespace.move_dir }.to raise_error("namespace directory cannot be moved") stub_container_registry_config(enabled: true)
end stub_container_registry_tags(repository: :any, tags: ['tag'])
   
it "moves dir if path changed" do create(:project, namespace: namespace, container_repositories: [container_repository])
namespace.update_attributes(path: namespace.full_path + '_new')
   
expect(gitlab_shell.exists?(project.repository_storage_path, "#{namespace.path}/#{project.path}.git")).to be_truthy allow(namespace).to receive(:path_was).and_return(namespace.path)
end allow(namespace).to receive(:path).and_return('new_path')
end
   
context "when any project has container images" do it 'raises an error about not movable project' do
let(:container_repository) { create(:container_repository) } expect { namespace.move_dir }.to raise_error(/Namespace cannot be moved/)
end
end
end
   
before do context 'legacy storage' do
stub_container_registry_config(enabled: true) let(:namespace) { create(:namespace) }
stub_container_registry_tags(repository: :any, tags: ['tag']) let!(:project) { create(:project_empty_repo, :legacy_storage, namespace: namespace) }
   
create(:project, namespace: namespace, container_repositories: [container_repository]) it_behaves_like 'namespace restrictions'
   
allow(namespace).to receive(:path_was).and_return(namespace.path) it "raises error when directory exists" do
allow(namespace).to receive(:path).and_return('new_path') expect { namespace.move_dir }.to raise_error("namespace directory cannot be moved")
end end
   
it 'raises an error about not movable project' do it "moves dir if path changed" do
expect { namespace.move_dir }.to raise_error(/Namespace cannot be moved/) namespace.update_attributes(path: namespace.full_path + '_new')
expect(gitlab_shell.exists?(project.repository_storage_path, "#{namespace.path}/#{project.path}.git")).to be_truthy
end end
end
   
context 'with subgroups' do context 'with subgroups' do
let(:parent) { create(:group, name: 'parent', path: 'parent') } let(:parent) { create(:group, name: 'parent', path: 'parent') }
let(:child) { create(:group, name: 'child', path: 'child', parent: parent) } let(:child) { create(:group, name: 'child', path: 'child', parent: parent) }
let!(:project) { create(:project_empty_repo, path: 'the-project', namespace: child, skip_disk_validation: true) } let!(:project) { create(:project_empty_repo, :legacy_storage, path: 'the-project', namespace: child, skip_disk_validation: true) }
let(:uploads_dir) { FileUploader.root } let(:uploads_dir) { FileUploader.root }
let(:pages_dir) { File.join(TestEnv.pages_path) } let(:pages_dir) { File.join(TestEnv.pages_path) }
   
before do before do
FileUtils.mkdir_p(File.join(uploads_dir, 'parent', 'child', 'the-project')) FileUtils.mkdir_p(File.join(uploads_dir, project.full_path))
FileUtils.mkdir_p(File.join(pages_dir, 'parent', 'child', 'the-project')) FileUtils.mkdir_p(File.join(pages_dir, project.full_path))
end end
context 'renaming child' do
it 'correctly moves the repository, uploads and pages' do
expected_repository_path = File.join(TestEnv.repos_path, 'parent', 'renamed', 'the-project.git')
expected_upload_path = File.join(uploads_dir, 'parent', 'renamed', 'the-project')
expected_pages_path = File.join(pages_dir, 'parent', 'renamed', 'the-project')
   
context 'renaming child' do child.update_attributes!(path: 'renamed')
it 'correctly moves the repository, uploads and pages' do
expected_repository_path = File.join(TestEnv.repos_path, 'parent', 'renamed', 'the-project.git')
expected_upload_path = File.join(uploads_dir, 'parent', 'renamed', 'the-project')
expected_pages_path = File.join(pages_dir, 'parent', 'renamed', 'the-project')
   
child.update_attributes!(path: 'renamed') expect(File.directory?(expected_repository_path)).to be(true)
expect(File.directory?(expected_upload_path)).to be(true)
expect(File.directory?(expected_pages_path)).to be(true)
end
end
context 'renaming parent' do
it 'correctly moves the repository, uploads and pages' do
expected_repository_path = File.join(TestEnv.repos_path, 'renamed', 'child', 'the-project.git')
expected_upload_path = File.join(uploads_dir, 'renamed', 'child', 'the-project')
expected_pages_path = File.join(pages_dir, 'renamed', 'child', 'the-project')
   
expect(File.directory?(expected_repository_path)).to be(true) parent.update_attributes!(path: 'renamed')
expect(File.directory?(expected_upload_path)).to be(true)
expect(File.directory?(expected_pages_path)).to be(true) expect(File.directory?(expected_repository_path)).to be(true)
expect(File.directory?(expected_upload_path)).to be(true)
expect(File.directory?(expected_pages_path)).to be(true)
end
end end
end end
end
   
context 'renaming parent' do context 'hashed storage' do
it 'correctly moves the repository, uploads and pages' do let(:namespace) { create(:namespace) }
expected_repository_path = File.join(TestEnv.repos_path, 'renamed', 'child', 'the-project.git') let!(:project) { create(:project_empty_repo, namespace: namespace) }
expected_upload_path = File.join(uploads_dir, 'renamed', 'child', 'the-project')
expected_pages_path = File.join(pages_dir, 'renamed', 'child', 'the-project')
   
parent.update_attributes!(path: 'renamed') it_behaves_like 'namespace restrictions'
   
expect(File.directory?(expected_repository_path)).to be(true) it "repository directory remains unchanged if path changed" do
expect(File.directory?(expected_upload_path)).to be(true) before_disk_path = project.disk_path
expect(File.directory?(expected_pages_path)).to be(true) namespace.update_attributes(path: namespace.full_path + '_new')
end
expect(before_disk_path).to eq(project.disk_path)
expect(gitlab_shell.exists?(project.repository_storage_path, "#{project.disk_path}.git")).to be_truthy
end end
end end
   
it 'updates project full path in .git/config for each project inside namespace' do it 'updates project full path in .git/config for each project inside namespace' do
parent = create(:group, name: 'mygroup', path: 'mygroup') parent = create(:group, name: 'mygroup', path: 'mygroup')
subgroup = create(:group, name: 'mysubgroup', path: 'mysubgroup', parent: parent) subgroup = create(:group, name: 'mysubgroup', path: 'mysubgroup', parent: parent)
project_in_parent_group = create(:project, :repository, namespace: parent, name: 'foo1') project_in_parent_group = create(:project, :legacy_storage, :repository, namespace: parent, name: 'foo1')
hashed_project_in_subgroup = create(:project, :repository, :hashed, namespace: subgroup, name: 'foo2') hashed_project_in_subgroup = create(:project, :repository, namespace: subgroup, name: 'foo2')
legacy_project_in_subgroup = create(:project, :repository, namespace: subgroup, name: 'foo3') legacy_project_in_subgroup = create(:project, :legacy_storage, :repository, namespace: subgroup, name: 'foo3')
   
parent.update(path: 'mygroup_new') parent.update(path: 'mygroup_new')
   
Loading
@@ -260,38 +281,18 @@ describe Namespace do
Loading
@@ -260,38 +281,18 @@ describe Namespace do
end end
   
describe '#rm_dir', 'callback' do describe '#rm_dir', 'callback' do
let!(:project) { create(:project_empty_repo, namespace: namespace) }
let(:repository_storage_path) { Gitlab.config.repositories.storages.default['path'] } let(:repository_storage_path) { Gitlab.config.repositories.storages.default['path'] }
let(:path_in_dir) { File.join(repository_storage_path, namespace.full_path) } let(:path_in_dir) { File.join(repository_storage_path, namespace.full_path) }
let(:deleted_path) { namespace.full_path.gsub(namespace.path, "#{namespace.full_path}+#{namespace.id}+deleted") } let(:deleted_path) { namespace.full_path.gsub(namespace.path, "#{namespace.full_path}+#{namespace.id}+deleted") }
let(:deleted_path_in_dir) { File.join(repository_storage_path, deleted_path) } let(:deleted_path_in_dir) { File.join(repository_storage_path, deleted_path) }
   
it 'renames its dirs when deleted' do context 'legacy storage' do
allow(GitlabShellWorker).to receive(:perform_in) let!(:project) { create(:project_empty_repo, :legacy_storage, namespace: namespace) }
namespace.destroy
expect(File.exist?(deleted_path_in_dir)).to be(true)
end
it 'schedules the namespace for deletion' do
expect(GitlabShellWorker).to receive(:perform_in).with(5.minutes, :rm_namespace, repository_storage_path, deleted_path)
namespace.destroy
end
context 'in sub-groups' do
let(:parent) { create(:group, path: 'parent') }
let(:child) { create(:group, parent: parent, path: 'child') }
let!(:project) { create(:project_empty_repo, namespace: child) }
let(:path_in_dir) { File.join(repository_storage_path, 'parent', 'child') }
let(:deleted_path) { File.join('parent', "child+#{child.id}+deleted") }
let(:deleted_path_in_dir) { File.join(repository_storage_path, deleted_path) }
   
it 'renames its dirs when deleted' do it 'renames its dirs when deleted' do
allow(GitlabShellWorker).to receive(:perform_in) allow(GitlabShellWorker).to receive(:perform_in)
   
child.destroy namespace.destroy
   
expect(File.exist?(deleted_path_in_dir)).to be(true) expect(File.exist?(deleted_path_in_dir)).to be(true)
end end
Loading
@@ -299,14 +300,57 @@ describe Namespace do
Loading
@@ -299,14 +300,57 @@ describe Namespace do
it 'schedules the namespace for deletion' do it 'schedules the namespace for deletion' do
expect(GitlabShellWorker).to receive(:perform_in).with(5.minutes, :rm_namespace, repository_storage_path, deleted_path) expect(GitlabShellWorker).to receive(:perform_in).with(5.minutes, :rm_namespace, repository_storage_path, deleted_path)
   
child.destroy namespace.destroy
end
context 'in sub-groups' do
let(:parent) { create(:group, path: 'parent') }
let(:child) { create(:group, parent: parent, path: 'child') }
let!(:project) { create(:project_empty_repo, :legacy_storage, namespace: child) }
let(:path_in_dir) { File.join(repository_storage_path, 'parent', 'child') }
let(:deleted_path) { File.join('parent', "child+#{child.id}+deleted") }
let(:deleted_path_in_dir) { File.join(repository_storage_path, deleted_path) }
it 'renames its dirs when deleted' do
allow(GitlabShellWorker).to receive(:perform_in)
child.destroy
expect(File.exist?(deleted_path_in_dir)).to be(true)
end
it 'schedules the namespace for deletion' do
expect(GitlabShellWorker).to receive(:perform_in).with(5.minutes, :rm_namespace, repository_storage_path, deleted_path)
child.destroy
end
end
it 'removes the exports folder' do
expect(namespace).to receive(:remove_exports!)
namespace.destroy
end end
end end
   
it 'removes the exports folder' do context 'hashed storage' do
expect(namespace).to receive(:remove_exports!) let!(:project) { create(:project_empty_repo, namespace: namespace) }
it 'has no repositories base directories to remove' do
allow(GitlabShellWorker).to receive(:perform_in)
expect(File.exist?(path_in_dir)).to be(false)
   
namespace.destroy namespace.destroy
expect(File.exist?(deleted_path_in_dir)).to be(false)
end
it 'removes the exports folder' do
expect(namespace).to receive(:remove_exports!)
namespace.destroy
end
end end
end end
   
Loading
@@ -567,8 +611,8 @@ describe Namespace do
Loading
@@ -567,8 +611,8 @@ describe Namespace do
end end
   
describe '#remove_exports' do describe '#remove_exports' do
let(:legacy_project) { create(:project, :with_export, namespace: namespace) } let(:legacy_project) { create(:project, :with_export, :legacy_storage, namespace: namespace) }
let(:hashed_project) { create(:project, :with_export, :hashed, namespace: namespace) } let(:hashed_project) { create(:project, :with_export, namespace: namespace) }
let(:export_path) { Dir.mktmpdir('namespace_remove_exports_spec') } let(:export_path) { Dir.mktmpdir('namespace_remove_exports_spec') }
let(:legacy_export) { legacy_project.export_project_path } let(:legacy_export) { legacy_project.export_project_path }
let(:hashed_export) { hashed_project.export_project_path } let(:hashed_export) { hashed_project.export_project_path }
Loading
Loading
Loading
@@ -2504,6 +2504,7 @@ describe Project do
Loading
@@ -2504,6 +2504,7 @@ describe Project do
end end
   
describe '#remove_exports' do describe '#remove_exports' do
let(:legacy_project) { create(:project, :legacy_storage, :with_export) }
let(:project) { create(:project, :with_export) } let(:project) { create(:project, :with_export) }
   
it 'removes the exports directory for the project' do it 'removes the exports directory for the project' do
Loading
@@ -2516,15 +2517,29 @@ describe Project do
Loading
@@ -2516,15 +2517,29 @@ describe Project do
expect(File.exist?(project.export_path)).to be_falsy expect(File.exist?(project.export_path)).to be_falsy
end end
   
it 'is a no-op when there is no namespace' do it 'is a no-op on legacy projects when there is no namespace' do
export_path = legacy_project.export_path
legacy_project.update_column(:namespace_id, nil)
expect(FileUtils).not_to receive(:rm_rf).with(export_path)
legacy_project.remove_exports
expect(File.exist?(export_path)).to be_truthy
end
it 'runs on hashed storage projects when there is no namespace' do
export_path = project.export_path export_path = project.export_path
project.update_column(:namespace_id, nil) project.update_column(:namespace_id, nil)
   
expect(FileUtils).not_to receive(:rm_rf).with(export_path) allow(FileUtils).to receive(:rm_rf).and_call_original
expect(FileUtils).to receive(:rm_rf).with(export_path).and_call_original
   
project.remove_exports project.remove_exports
   
expect(File.exist?(export_path)).to be_truthy expect(File.exist?(export_path)).to be_falsy
end end
   
it 'is run when the project is destroyed' do it 'is run when the project is destroyed' do
Loading
@@ -2545,7 +2560,7 @@ describe Project do
Loading
@@ -2545,7 +2560,7 @@ describe Project do
end end
   
context 'legacy storage' do context 'legacy storage' do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository, :legacy_storage) }
let(:gitlab_shell) { Gitlab::Shell.new } let(:gitlab_shell) { Gitlab::Shell.new }
let(:project_storage) { project.send(:storage) } let(:project_storage) { project.send(:storage) }
   
Loading
@@ -2719,6 +2734,8 @@ describe Project do
Loading
@@ -2719,6 +2734,8 @@ describe Project do
let(:project) { create(:project, :repository, skip_disk_validation: true) } let(:project) { create(:project, :repository, skip_disk_validation: true) }
let(:gitlab_shell) { Gitlab::Shell.new } let(:gitlab_shell) { Gitlab::Shell.new }
let(:hash) { Digest::SHA2.hexdigest(project.id.to_s) } let(:hash) { Digest::SHA2.hexdigest(project.id.to_s) }
let(:hashed_prefix) { File.join('@hashed', hash[0..1], hash[2..3]) }
let(:hashed_path) { File.join(hashed_prefix, hash) }
   
before do before do
stub_application_setting(hashed_storage_enabled: true) stub_application_setting(hashed_storage_enabled: true)
Loading
@@ -2744,14 +2761,12 @@ describe Project do
Loading
@@ -2744,14 +2761,12 @@ describe Project do
   
describe '#base_dir' do describe '#base_dir' do
it 'returns base_dir based on hash of project id' do it 'returns base_dir based on hash of project id' do
expect(project.base_dir).to eq("@hashed/#{hash[0..1]}/#{hash[2..3]}") expect(project.base_dir).to eq(hashed_prefix)
end end
end end
   
describe '#disk_path' do describe '#disk_path' do
it 'returns disk_path based on hash of project id' do it 'returns disk_path based on hash of project id' do
hashed_path = "@hashed/#{hash[0..1]}/#{hash[2..3]}/#{hash}"
expect(project.disk_path).to eq(hashed_path) expect(project.disk_path).to eq(hashed_path)
end end
end end
Loading
@@ -2760,7 +2775,7 @@ describe Project do
Loading
@@ -2760,7 +2775,7 @@ describe Project do
it 'delegates to gitlab_shell to ensure namespace is created' do it 'delegates to gitlab_shell to ensure namespace is created' do
allow(project).to receive(:gitlab_shell).and_return(gitlab_shell) allow(project).to receive(:gitlab_shell).and_return(gitlab_shell)
   
expect(gitlab_shell).to receive(:add_namespace).with(project.repository_storage_path, "@hashed/#{hash[0..1]}/#{hash[2..3]}") expect(gitlab_shell).to receive(:add_namespace).with(project.repository_storage_path, hashed_prefix)
   
project.ensure_storage_path_exists project.ensure_storage_path_exists
end end
Loading
Loading
Loading
@@ -366,20 +366,9 @@ describe API::Internal do
Loading
@@ -366,20 +366,9 @@ describe API::Internal do
end end
end end
   
context 'project as /namespace/project' do
it do
push(key, project_with_repo_path('/' + project.full_path))
expect(response).to have_gitlab_http_status(200)
expect(json_response["status"]).to be_truthy
expect(json_response["repository_path"]).to eq(project.repository.path_to_repo)
expect(json_response["gl_repository"]).to eq("project-#{project.id}")
end
end
context 'project as namespace/project' do context 'project as namespace/project' do
it do it do
push(key, project_with_repo_path(project.full_path)) push(key, project)
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
expect(json_response["status"]).to be_truthy expect(json_response["status"]).to be_truthy
Loading
@@ -496,8 +485,10 @@ describe API::Internal do
Loading
@@ -496,8 +485,10 @@ describe API::Internal do
end end
   
context 'project does not exist' do context 'project does not exist' do
it do it 'returns a 200 response with status: false' do
pull(key, project_with_repo_path('gitlab/notexist')) project.destroy
pull(key, project)
   
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
expect(json_response["status"]).to be_falsey expect(json_response["status"]).to be_falsey
Loading
@@ -569,6 +560,7 @@ describe API::Internal do
Loading
@@ -569,6 +560,7 @@ describe API::Internal do
end end
   
context 'the project path was changed' do context 'the project path was changed' do
let(:project) { create(:project, :repository, :legacy_storage) }
let!(:old_path_to_repo) { project.repository.path_to_repo } let!(:old_path_to_repo) { project.repository.path_to_repo }
let!(:repository) { project.repository } let!(:repository) { project.repository }
   
Loading
@@ -858,9 +850,14 @@ describe API::Internal do
Loading
@@ -858,9 +850,14 @@ describe API::Internal do
end end
end end
   
def project_with_repo_path(path) def gl_repository_for(project_or_wiki)
double().tap do |fake_project| case project_or_wiki
allow(fake_project).to receive_message_chain('repository.path_to_repo' => path) when ProjectWiki
project_or_wiki.project.gl_repository(is_wiki: true)
when Project
project_or_wiki.gl_repository(is_wiki: false)
else
nil
end end
end end
   
Loading
@@ -868,18 +865,8 @@ describe API::Internal do
Loading
@@ -868,18 +865,8 @@ describe API::Internal do
post( post(
api("/internal/allowed"), api("/internal/allowed"),
key_id: key.id, key_id: key.id,
project: project.repository.path_to_repo, project: project.full_path,
action: 'git-upload-pack', gl_repository: gl_repository_for(project),
secret_token: secret_token,
protocol: protocol
)
end
def pull_with_path(key, path_to_repo, protocol = 'ssh')
post(
api("/internal/allowed"),
key_id: key.id,
project: path_to_repo,
action: 'git-upload-pack', action: 'git-upload-pack',
secret_token: secret_token, secret_token: secret_token,
protocol: protocol protocol: protocol
Loading
@@ -891,20 +878,8 @@ describe API::Internal do
Loading
@@ -891,20 +878,8 @@ describe API::Internal do
api("/internal/allowed"), api("/internal/allowed"),
changes: 'd14d6c0abdd253381df51a723d58691b2ee1ab08 570e7b2abdd848b95f2f578043fc23bd6f6fd24d refs/heads/master', changes: 'd14d6c0abdd253381df51a723d58691b2ee1ab08 570e7b2abdd848b95f2f578043fc23bd6f6fd24d refs/heads/master',
key_id: key.id, key_id: key.id,
project: project.repository.path_to_repo, project: project.full_path,
action: 'git-receive-pack', gl_repository: gl_repository_for(project),
secret_token: secret_token,
protocol: protocol,
env: env
)
end
def push_with_path(key, path_to_repo, protocol = 'ssh', env: nil)
post(
api("/internal/allowed"),
changes: 'd14d6c0abdd253381df51a723d58691b2ee1ab08 570e7b2abdd848b95f2f578043fc23bd6f6fd24d refs/heads/master',
key_id: key.id,
project: path_to_repo,
action: 'git-receive-pack', action: 'git-receive-pack',
secret_token: secret_token, secret_token: secret_token,
protocol: protocol, protocol: protocol,
Loading
@@ -917,7 +892,8 @@ describe API::Internal do
Loading
@@ -917,7 +892,8 @@ describe API::Internal do
api("/internal/allowed"), api("/internal/allowed"),
ref: 'master', ref: 'master',
key_id: key.id, key_id: key.id,
project: project.repository.path_to_repo, project: project.full_path,
gl_repository: gl_repository_for(project),
action: 'git-upload-archive', action: 'git-upload-archive',
secret_token: secret_token, secret_token: secret_token,
protocol: 'ssh' protocol: 'ssh'
Loading
@@ -929,7 +905,7 @@ describe API::Internal do
Loading
@@ -929,7 +905,7 @@ describe API::Internal do
api("/internal/lfs_authenticate"), api("/internal/lfs_authenticate"),
key_id: key_id, key_id: key_id,
secret_token: secret_token, secret_token: secret_token,
project: project.repository.path_to_repo project: project.full_path
) )
end end
end end
Loading
@@ -460,7 +460,7 @@ describe API::Projects do
Loading
@@ -460,7 +460,7 @@ describe API::Projects do
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(201)
   
project.each_pair do |k, v| project.each_pair do |k, v|
next if %i[has_external_issue_tracker issues_enabled merge_requests_enabled wiki_enabled].include?(k) next if %i[has_external_issue_tracker issues_enabled merge_requests_enabled wiki_enabled storage_version].include?(k)
   
expect(json_response[k.to_s]).to eq(v) expect(json_response[k.to_s]).to eq(v)
end end
Loading
@@ -622,12 +622,8 @@ describe API::Projects do
Loading
@@ -622,12 +622,8 @@ describe API::Projects do
end end
   
describe 'POST /projects/user/:id' do describe 'POST /projects/user/:id' do
before do
expect(project).to be_persisted
end
it 'creates new project without path but with name and return 201' do it 'creates new project without path but with name and return 201' do
expect { post api("/projects/user/#{user.id}", admin), name: 'Foo Project' }.to change {Project.count}.by(1) expect { post api("/projects/user/#{user.id}", admin), name: 'Foo Project' }.to change { Project.count }.by(1)
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(201)
   
project = Project.last project = Project.last
Loading
@@ -666,8 +662,9 @@ describe API::Projects do
Loading
@@ -666,8 +662,9 @@ describe API::Projects do
post api("/projects/user/#{user.id}", admin), project post api("/projects/user/#{user.id}", admin), project
   
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(201)
project.each_pair do |k, v| project.each_pair do |k, v|
next if %i[has_external_issue_tracker path].include?(k) next if %i[has_external_issue_tracker path storage_version].include?(k)
   
expect(json_response[k.to_s]).to eq(v) expect(json_response[k.to_s]).to eq(v)
end end
Loading
Loading
Loading
@@ -401,7 +401,7 @@ describe API::V3::Projects do
Loading
@@ -401,7 +401,7 @@ describe API::V3::Projects do
post v3_api('/projects', user), project post v3_api('/projects', user), project
   
project.each_pair do |k, v| project.each_pair do |k, v|
next if %i[has_external_issue_tracker issues_enabled merge_requests_enabled wiki_enabled].include?(k) next if %i[storage_version has_external_issue_tracker issues_enabled merge_requests_enabled wiki_enabled].include?(k)
   
expect(json_response[k.to_s]).to eq(v) expect(json_response[k.to_s]).to eq(v)
end end
Loading
@@ -545,7 +545,7 @@ describe API::V3::Projects do
Loading
@@ -545,7 +545,7 @@ describe API::V3::Projects do
   
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(201)
project.each_pair do |k, v| project.each_pair do |k, v|
next if %i[has_external_issue_tracker path].include?(k) next if %i[storage_version has_external_issue_tracker path].include?(k)
   
expect(json_response[k.to_s]).to eq(v) expect(json_response[k.to_s]).to eq(v)
end end
Loading
Loading
Loading
@@ -163,7 +163,7 @@ describe 'Git HTTP requests' do
Loading
@@ -163,7 +163,7 @@ describe 'Git HTTP requests' do
download(path) do |response| download(path) do |response|
json_body = ActiveSupport::JSON.decode(response.body) json_body = ActiveSupport::JSON.decode(response.body)
   
expect(json_body['RepoPath']).to include(wiki.repository.full_path) expect(json_body['RepoPath']).to include(wiki.repository.disk_path)
end end
end end
end end
Loading
Loading
Loading
@@ -6,7 +6,7 @@ describe Groups::DestroyService do
Loading
@@ -6,7 +6,7 @@ describe Groups::DestroyService do
let!(:user) { create(:user) } let!(:user) { create(:user) }
let!(:group) { create(:group) } let!(:group) { create(:group) }
let!(:nested_group) { create(:group, parent: group) } let!(:nested_group) { create(:group, parent: group) }
let!(:project) { create(:project, namespace: group) } let!(:project) { create(:project, :legacy_storage, namespace: group) }
let!(:notification_setting) { create(:notification_setting, source: group)} let!(:notification_setting) { create(:notification_setting, source: group)}
let(:gitlab_shell) { Gitlab::Shell.new } let(:gitlab_shell) { Gitlab::Shell.new }
let(:remove_path) { group.path + "+#{group.id}+deleted" } let(:remove_path) { group.path + "+#{group.id}+deleted" }
Loading
@@ -141,7 +141,7 @@ describe Groups::DestroyService do
Loading
@@ -141,7 +141,7 @@ describe Groups::DestroyService do
end end
   
context 'legacy storage' do context 'legacy storage' do
let!(:project) { create(:project, :empty_repo, namespace: group) } let!(:project) { create(:project, :legacy_storage, :empty_repo, namespace: group) }
   
it 'removes repository' do it 'removes repository' do
expect(gitlab_shell.exists?(project.repository_storage_path, "#{project.disk_path}.git")).to be_falsey expect(gitlab_shell.exists?(project.repository_storage_path, "#{project.disk_path}.git")).to be_falsey
Loading
@@ -149,7 +149,7 @@ describe Groups::DestroyService do
Loading
@@ -149,7 +149,7 @@ describe Groups::DestroyService do
end end
   
context 'hashed storage' do context 'hashed storage' do
let!(:project) { create(:project, :hashed, :empty_repo, namespace: group) } let!(:project) { create(:project, :empty_repo, namespace: group) }
   
it 'removes repository' do it 'removes repository' do
expect(gitlab_shell.exists?(project.repository_storage_path, "#{project.disk_path}.git")).to be_falsey expect(gitlab_shell.exists?(project.repository_storage_path, "#{project.disk_path}.git")).to be_falsey
Loading
Loading
Loading
@@ -2,7 +2,7 @@ require 'spec_helper'
Loading
@@ -2,7 +2,7 @@ require 'spec_helper'
   
describe Projects::HashedStorage::MigrateAttachmentsService do describe Projects::HashedStorage::MigrateAttachmentsService do
subject(:service) { described_class.new(project) } subject(:service) { described_class.new(project) }
let(:project) { create(:project) } let(:project) { create(:project, :legacy_storage) }
let(:legacy_storage) { Storage::LegacyProject.new(project) } let(:legacy_storage) { Storage::LegacyProject.new(project) }
let(:hashed_storage) { Storage::HashedProject.new(project) } let(:hashed_storage) { Storage::HashedProject.new(project) }
   
Loading
Loading
Loading
@@ -2,7 +2,7 @@ require 'spec_helper'
Loading
@@ -2,7 +2,7 @@ require 'spec_helper'
   
describe Projects::HashedStorage::MigrateRepositoryService do describe Projects::HashedStorage::MigrateRepositoryService do
let(:gitlab_shell) { Gitlab::Shell.new } let(:gitlab_shell) { Gitlab::Shell.new }
let(:project) { create(:project, :repository, :wiki_repo) } let(:project) { create(:project, :legacy_storage, :repository, :wiki_repo) }
let(:service) { described_class.new(project) } let(:service) { described_class.new(project) }
let(:legacy_storage) { Storage::LegacyProject.new(project) } let(:legacy_storage) { Storage::LegacyProject.new(project) }
let(:hashed_storage) { Storage::HashedProject.new(project) } let(:hashed_storage) { Storage::HashedProject.new(project) }
Loading
Loading
require 'spec_helper' require 'spec_helper'
   
describe Projects::HashedStorageMigrationService do describe Projects::HashedStorageMigrationService do
let(:project) { create(:project, :empty_repo, :wiki_repo) } let(:project) { create(:project, :empty_repo, :wiki_repo, :legacy_storage) }
subject(:service) { described_class.new(project) } subject(:service) { described_class.new(project) }
   
describe '#execute' do describe '#execute' do
Loading
Loading
Loading
@@ -4,7 +4,7 @@ describe Projects::TransferService do
Loading
@@ -4,7 +4,7 @@ describe Projects::TransferService do
let(:gitlab_shell) { Gitlab::Shell.new } let(:gitlab_shell) { Gitlab::Shell.new }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:group) { create(:group) } let(:group) { create(:group) }
let(:project) { create(:project, :repository, namespace: user.namespace) } let(:project) { create(:project, :repository, :legacy_storage, namespace: user.namespace) }
   
context 'namespace -> namespace' do context 'namespace -> namespace' do
before do before do
Loading
@@ -214,7 +214,7 @@ describe Projects::TransferService do
Loading
@@ -214,7 +214,7 @@ describe Projects::TransferService do
end end
   
context 'when hashed storage in use' do context 'when hashed storage in use' do
let(:hashed_project) { create(:project, :repository, :hashed, namespace: user.namespace) } let(:hashed_project) { create(:project, :repository, namespace: user.namespace) }
   
before do before do
group.add_owner(user) group.add_owner(user)
Loading
Loading
Loading
@@ -150,6 +150,8 @@ describe Projects::UpdateService do
Loading
@@ -150,6 +150,8 @@ describe Projects::UpdateService do
let(:repository_storage_path) { Gitlab.config.repositories.storages[repository_storage]['path'] } let(:repository_storage_path) { Gitlab.config.repositories.storages[repository_storage]['path'] }
   
context 'with legacy storage' do context 'with legacy storage' do
let(:project) { create(:project, :legacy_storage, :repository, creator: user, namespace: user.namespace) }
before do before do
gitlab_shell.add_repository(repository_storage, "#{user.namespace.full_path}/existing") gitlab_shell.add_repository(repository_storage, "#{user.namespace.full_path}/existing")
end end
Loading
Loading
Loading
@@ -173,7 +173,7 @@ describe Users::DestroyService do
Loading
@@ -173,7 +173,7 @@ describe Users::DestroyService do
end end
   
context 'legacy storage' do context 'legacy storage' do
let!(:project) { create(:project, :empty_repo, namespace: user.namespace) } let!(:project) { create(:project, :empty_repo, :legacy_storage, namespace: user.namespace) }
   
it 'removes repository' do it 'removes repository' do
expect(gitlab_shell.exists?(project.repository_storage_path, "#{project.disk_path}.git")).to be_falsey expect(gitlab_shell.exists?(project.repository_storage_path, "#{project.disk_path}.git")).to be_falsey
Loading
@@ -181,7 +181,7 @@ describe Users::DestroyService do
Loading
@@ -181,7 +181,7 @@ describe Users::DestroyService do
end end
   
context 'hashed storage' do context 'hashed storage' do
let!(:project) { create(:project, :empty_repo, :hashed, namespace: user.namespace) } let!(:project) { create(:project, :empty_repo, namespace: user.namespace) }
   
it 'removes repository' do it 'removes repository' do
expect(gitlab_shell.exists?(project.repository_storage_path, "#{project.disk_path}.git")).to be_falsey expect(gitlab_shell.exists?(project.repository_storage_path, "#{project.disk_path}.git")).to be_falsey
Loading
Loading
Loading
@@ -2,7 +2,7 @@ require 'spec_helper'
Loading
@@ -2,7 +2,7 @@ require 'spec_helper'
   
describe FileUploader do describe FileUploader do
let(:group) { create(:group, name: 'awesome') } let(:group) { create(:group, name: 'awesome') }
let(:project) { create(:project, namespace: group, name: 'project') } let(:project) { create(:project, :legacy_storage, namespace: group, name: 'project') }
let(:uploader) { described_class.new(project) } let(:uploader) { described_class.new(project) }
let(:upload) { double(model: project, path: 'secret/foo.jpg') } let(:upload) { double(model: project, path: 'secret/foo.jpg') }
   
Loading
@@ -16,12 +16,12 @@ describe FileUploader do
Loading
@@ -16,12 +16,12 @@ describe FileUploader do
   
shared_examples 'uses hashed storage' do shared_examples 'uses hashed storage' do
context 'when rolled out attachments' do context 'when rolled out attachments' do
let(:project) { build_stubbed(:project, namespace: group, name: 'project') }
before do before do
allow(project).to receive(:disk_path).and_return('ca/fe/fe/ed') allow(project).to receive(:disk_path).and_return('ca/fe/fe/ed')
end end
   
let(:project) { build_stubbed(:project, :hashed, namespace: group, name: 'project') }
it_behaves_like 'builds correct paths', it_behaves_like 'builds correct paths',
store_dir: %r{ca/fe/fe/ed/\h+}, store_dir: %r{ca/fe/fe/ed/\h+},
absolute_path: %r{#{described_class.root}/ca/fe/fe/ed/secret/foo.jpg} absolute_path: %r{#{described_class.root}/ca/fe/fe/ed/secret/foo.jpg}
Loading
Loading
Loading
@@ -68,7 +68,7 @@ describe RepositoryForkWorker do
Loading
@@ -68,7 +68,7 @@ describe RepositoryForkWorker do
end end
   
it "handles bad fork" do it "handles bad fork" do
error_message = "Unable to fork project #{fork_project.id} for repository #{project.full_path} -> #{fork_project.full_path}" error_message = "Unable to fork project #{fork_project.id} for repository #{project.disk_path} -> #{fork_project.disk_path}"
   
expect_fork_repository.and_return(false) expect_fork_repository.and_return(false)
   
Loading
Loading
Loading
@@ -2,7 +2,7 @@ require 'spec_helper'
Loading
@@ -2,7 +2,7 @@ require 'spec_helper'
   
describe StorageMigratorWorker do describe StorageMigratorWorker do
subject(:worker) { described_class.new } subject(:worker) { described_class.new }
let(:projects) { create_list(:project, 2) } let(:projects) { create_list(:project, 2, :legacy_storage) }
   
describe '#perform' do describe '#perform' do
let(:ids) { projects.map(&:id) } let(:ids) { projects.map(&:id) }
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment