Skip to content
代码片段 群组 项目
提交 3208eba6 编辑于 作者: Etienne Baqué's avatar Etienne Baqué
浏览文件

Merge branch 'jv-spec-workhorse' into 'master'

Remove stub for obsolete feature flag

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/105640



Merged-by: default avatarEtienne Baqué <ebaque@gitlab.com>
Approved-by: default avatarIan Anderson <ianderson@gitlab.com>
Approved-by: default avatarEtienne Baqué <ebaque@gitlab.com>
Co-authored-by: default avatarJacob Vosmaer <jacob@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -209,6 +209,16 @@ def call_verify(headers) ...@@ -209,6 +209,16 @@ def call_verify(headers)
describe '.git_http_ok' do describe '.git_http_ok' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:gitaly_params) do
{
GitalyServer: {
call_metadata: call_metadata,
address: Gitlab::GitalyClient.address('default'),
token: Gitlab::GitalyClient.token('default')
}
}
end
let(:repo_path) { 'ignored but not allowed to be empty in gitlab-workhorse' } let(:repo_path) { 'ignored but not allowed to be empty in gitlab-workhorse' }
let(:action) { 'info_refs' } let(:action) { 'info_refs' }
let(:params) do let(:params) do
...@@ -246,100 +256,79 @@ def call_verify(headers) ...@@ -246,100 +256,79 @@ def call_verify(headers)
it { expect(subject).to include(params) } it { expect(subject).to include(params) }
end end
context 'when Gitaly is enabled' do it 'includes a Repository param' do
let(:gitaly_params) do repo_param = {
{ storage_name: 'default',
GitalyServer: { relative_path: project.disk_path + '.git',
call_metadata: call_metadata, gl_repository: "project-#{project.id}"
address: Gitlab::GitalyClient.address('default'), }
token: Gitlab::GitalyClient.token('default')
}
}
end
before do expect(subject[:Repository]).to include(repo_param)
allow(Gitlab.config.gitaly).to receive(:enabled).and_return(true) end
end
it 'includes a Repository param' do context "when git_upload_pack action is passed" do
repo_param = { let(:action) { 'git_upload_pack' }
storage_name: 'default',
relative_path: project.disk_path + '.git',
gl_repository: "project-#{project.id}"
}
expect(subject[:Repository]).to include(repo_param) it { expect(subject).to include(gitaly_params) }
end
context "when git_upload_pack action is passed" do context 'show_all_refs enabled' do
let(:action) { 'git_upload_pack' } subject { described_class.git_http_ok(repository, Gitlab::GlRepository::PROJECT, user, action, show_all_refs: true) }
let(:feature_flag) { :post_upload_pack }
it 'includes Gitaly params in the returned value' do it { is_expected.to include(ShowAllRefs: true) }
allow(Gitlab::GitalyClient).to receive(:feature_enabled?).with(feature_flag).and_return(true) end
expect(subject).to include(gitaly_params) context 'when a feature flag is set for a single project' do
before do
stub_feature_flags(gitaly_mep_mep: project)
end end
context 'show_all_refs enabled' do it 'sets the flag to true for that project' do
subject { described_class.git_http_ok(repository, Gitlab::GlRepository::PROJECT, user, action, show_all_refs: true) } response = described_class.git_http_ok(repository, Gitlab::GlRepository::PROJECT, user, action)
it { is_expected.to include(ShowAllRefs: true) } expect(response.dig(:GitalyServer, :call_metadata)).to include('gitaly-feature-enforce-requests-limits' => 'true',
'gitaly-feature-mep-mep' => 'true')
end end
context 'when a feature flag is set for a single project' do it 'sets the flag to false for other projects' do
before do other_project = create(:project, :public, :repository)
stub_feature_flags(gitaly_mep_mep: project) response = described_class.git_http_ok(other_project.repository, Gitlab::GlRepository::PROJECT, user, action)
end
it 'sets the flag to true for that project' do
response = described_class.git_http_ok(repository, Gitlab::GlRepository::PROJECT, user, action)
expect(response.dig(:GitalyServer, :call_metadata)).to include('gitaly-feature-enforce-requests-limits' => 'true', expect(response.dig(:GitalyServer, :call_metadata)).to include('gitaly-feature-enforce-requests-limits' => 'true',
'gitaly-feature-mep-mep' => 'true') 'gitaly-feature-mep-mep' => 'false')
end end
it 'sets the flag to false for other projects' do
other_project = create(:project, :public, :repository)
response = described_class.git_http_ok(other_project.repository, Gitlab::GlRepository::PROJECT, user, action)
expect(response.dig(:GitalyServer, :call_metadata)).to include('gitaly-feature-enforce-requests-limits' => 'true',
'gitaly-feature-mep-mep' => 'false')
end
it 'sets the flag to false when there is no project' do it 'sets the flag to false when there is no project' do
snippet = create(:personal_snippet, :repository) snippet = create(:personal_snippet, :repository)
response = described_class.git_http_ok(snippet.repository, Gitlab::GlRepository::SNIPPET, user, action) response = described_class.git_http_ok(snippet.repository, Gitlab::GlRepository::SNIPPET, user, action)
expect(response.dig(:GitalyServer, :call_metadata)).to include('gitaly-feature-enforce-requests-limits' => 'true', expect(response.dig(:GitalyServer, :call_metadata)).to include('gitaly-feature-enforce-requests-limits' => 'true',
'gitaly-feature-mep-mep' => 'false') 'gitaly-feature-mep-mep' => 'false')
end
end end
end end
end
context "when git_receive_pack action is passed" do context "when git_receive_pack action is passed" do
let(:action) { 'git_receive_pack' } let(:action) { 'git_receive_pack' }
it { expect(subject).to include(gitaly_params) } it { expect(subject).to include(gitaly_params) }
end end
context "when info_refs action is passed" do context "when info_refs action is passed" do
let(:action) { 'info_refs' } let(:action) { 'info_refs' }
it { expect(subject).to include(gitaly_params) } it { expect(subject).to include(gitaly_params) }
context 'show_all_refs enabled' do context 'show_all_refs enabled' do
subject { described_class.git_http_ok(repository, Gitlab::GlRepository::PROJECT, user, action, show_all_refs: true) } subject { described_class.git_http_ok(repository, Gitlab::GlRepository::PROJECT, user, action, show_all_refs: true) }
it { is_expected.to include(ShowAllRefs: true) } it { is_expected.to include(ShowAllRefs: true) }
end
end end
end
context 'when action passed is not supported by Gitaly' do context 'when action passed is not supported by Gitaly' do
let(:action) { 'download' } let(:action) { 'download' }
it { expect { subject }.to raise_exception('Unsupported action: download') } it { expect { subject }.to raise_exception('Unsupported action: download') }
end
end end
context 'when receive_max_input_size has been updated' do context 'when receive_max_input_size has been updated' do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册