Commit b38cf7cc authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent 08f4ce10
......@@ -405,7 +405,7 @@ group :test do
gem 'webmock', '~> 3.5.1'
gem 'rails-controller-testing'
gem 'concurrent-ruby', '~> 1.1'
gem 'test-prof', '~> 0.2.5'
gem 'test-prof', '~> 0.10.0'
gem 'rspec_junit_formatter'
end
......
......@@ -994,7 +994,7 @@ GEM
temple (0.8.1)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
test-prof (0.2.5)
test-prof (0.10.0)
text (1.3.1)
thin (1.7.2)
daemons (~> 1.0, >= 1.0.9)
......@@ -1314,7 +1314,7 @@ DEPENDENCIES
stackprof (~> 0.2.10)
state_machines-activerecord (~> 0.5.1)
sys-filesystem (~> 1.1.6)
test-prof (~> 0.2.5)
test-prof (~> 0.10.0)
thin (~> 1.7.0)
timecop (~> 0.8.0)
toml-rb (~> 1.0.0)
......
......@@ -41,6 +41,10 @@ class HealthController < ActionController::Base
info[:labels] = r.labels if r.labels
[name, info]
end
# disable static error pages at the gitlab-workhorse level, we want to see this error response even in production
headers["X-GitLab-Custom-Error"] = 1 unless success
render json: response.to_h, status: success ? :ok : :service_unavailable
end
end
......@@ -11,6 +11,7 @@ class Projects::BranchesController < Projects::ApplicationController
# Support legacy URLs
before_action :redirect_for_legacy_index_sort_or_search, only: [:index]
before_action :limit_diverging_commit_counts!, only: [:diverging_commit_counts]
def index
respond_to do |format|
......@@ -125,6 +126,24 @@ class Projects::BranchesController < Projects::ApplicationController
private
# It can be expensive to calculate the diverging counts for each
# branch. Normally the frontend should be specifying a set of branch
# names, but prior to
# https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/32496, the
# frontend could omit this set. To prevent excessive I/O, we require
# that a list of names be specified.
def limit_diverging_commit_counts!
return unless Feature.enabled?(:limit_diverging_commit_counts, default_enabled: true)
limit = Kaminari.config.default_per_page
# If we don't have many branches in the repository, then go ahead.
return if project.repository.branch_count <= limit
return if params[:names].present? && Array(params[:names]).length <= limit
render json: { error: "Specify at least one and at most #{limit} branch names" }, status: :unprocessable_entity
end
def ref
if params[:ref]
ref_escaped = strip_tags(sanitize(params[:ref]))
......
---
title: Disable gitlab-workhorse static error page on health endpoints
merge_request: 17770
author:
type: fixed
---
title: Limit diverging commit counts requests
merge_request: 16737
author:
type: performance
......@@ -222,6 +222,7 @@ group.
| Edit epic comments (posted by any user) **(ULTIMATE)** | | | | ✓ (2) | ✓ (2) |
| View group Audit Events | | | | | ✓ |
| Disable notification emails | | | | | ✓ |
| View/manage group-level Kubernetes cluster | | | | ✓ | ✓ |
- (1): Groups can be set to [allow either Owners or Owners and
Maintainers to create subgroups](group/subgroups/index.md#creating-a-subgroup)
......
......@@ -35,6 +35,10 @@ module QA
element :more_assignees_link
end
view 'app/assets/javascripts/vue_shared/components/issue/related_issuable_item.vue' do
element :remove_issue_button
end
view 'app/helpers/dropdowns_helper.rb' do
element :dropdown_input_field
end
......@@ -76,6 +80,10 @@ module QA
click_element(:milestone_link)
end
def click_remove_issue_button
click_element(:remove_issue_button)
end
# Adds a comment to an issue
# attachment option should be an absolute path
def comment(text, attachment: nil, filter: :all_activities)
......
......@@ -15,6 +15,7 @@ module QA
end
attribute :id
attribute :iid
attribute :assignee_ids
attribute :labels
attribute :title
......
......@@ -30,6 +30,19 @@ describe HealthController do
expect(json_response['shared_state_check']['status']).to eq('ok')
expect(json_response['gitaly_check']['status']).to eq('ok')
end
it 'responds with readiness checks data when a failure happens' do
allow(Gitlab::HealthChecks::Redis::RedisCheck).to receive(:readiness).and_return(Gitlab::HealthChecks::Result.new(false, "check error"))
subject
expect(json_response['redis_check']['status']).to eq('failed')
expect(json_response['redis_check']['message']).to eq('check error')
expect(json_response['cache_check']['status']).to eq('ok')
expect(response.status).to eq(503)
expect(response.headers['X-GitLab-Custom-Error']).to eq(1)
end
end
context 'accessed from whitelisted ip' do
......
......@@ -578,7 +578,9 @@ describe Projects::BranchesController do
describe 'GET diverging_commit_counts' do
before do
sign_in(user)
end
it 'returns the commit counts behind and ahead of default branch' do
get :diverging_commit_counts,
format: :json,
params: {
......@@ -586,14 +588,58 @@ describe Projects::BranchesController do
project_id: project,
names: ['fix', 'add-pdf-file', 'branch-merged']
}
end
it 'returns the commit counts behind and ahead of default branch' do
expect(response).to have_gitlab_http_status(200)
expect(json_response).to eq(
"fix" => { "behind" => 29, "ahead" => 2 },
"branch-merged" => { "behind" => 1, "ahead" => 0 },
"add-pdf-file" => { "behind" => 0, "ahead" => 3 }
)
end
it 'returns the commits counts with no names provided' do
allow_any_instance_of(Repository).to receive(:branch_count).and_return(Kaminari.config.default_per_page)
get :diverging_commit_counts,
format: :json,
params: {
namespace_id: project.namespace,
project_id: project
}
expect(response).to have_gitlab_http_status(200)
expect(json_response.count).to be > 1
end
describe 'with many branches' do
before do
allow_any_instance_of(Repository).to receive(:branch_count).and_return(Kaminari.config.default_per_page + 1)
end
it 'returns 422 if no names are specified' do
get :diverging_commit_counts,
format: :json,
params: {
namespace_id: project.namespace,
project_id: project
}
expect(response).to have_gitlab_http_status(422)
expect(json_response['error']).to eq("Specify at least one and at most #{Kaminari.config.default_per_page} branch names")
end
it 'returns the list of counts' do
get :diverging_commit_counts,
format: :json,
params: {
namespace_id: project.namespace,
project_id: project,
names: ['fix', 'add-pdf-file', 'branch-merged']
}
expect(response).to have_gitlab_http_status(200)
expect(json_response.count).to be > 1
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment