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:
authorStan Hu <stanhu@gmail.com>2018-12-26 10:34:47 +0300
committerStan Hu <stanhu@gmail.com>2018-12-27 15:24:37 +0300
commite7bd824484636fd4d4d7beb524b6bea3ecef533a (patch)
tree4b435626be5630c408e5ef4323420fe74a82118a /spec/requests/api
parent77909a88460bbc864a5f95f3fa66053eb6cab5a8 (diff)
Fix timeout issues retrieving branches via API
47d4890d changed the order of pagination so that the full list of branches would be passed to Gitaly to determine which ones had been merged, but this operation can timeout for large repositories with many branches. We only need to determine whether the found branches have been merged, so limit the scan to those. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/55724
Diffstat (limited to 'spec/requests/api')
-rw-r--r--spec/requests/api/branches_spec.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/requests/api/branches_spec.rb b/spec/requests/api/branches_spec.rb
index 93c411476bb..b38cd66986f 100644
--- a/spec/requests/api/branches_spec.rb
+++ b/spec/requests/api/branches_spec.rb
@@ -20,6 +20,12 @@ describe API::Branches do
let(:route) { "/projects/#{project_id}/repository/branches" }
shared_examples_for 'repository branches' do
+ RSpec::Matchers.define :has_merged_branch_names_count do |expected|
+ match do |actual|
+ actual[:merged_branch_names].count == expected
+ end
+ end
+
it 'returns the repository branches' do
get api(route, current_user), params: { per_page: 100 }
@@ -30,6 +36,12 @@ describe API::Branches do
expect(branch_names).to match_array(project.repository.branch_names)
end
+ it 'determines only a limited number of merged branch names' do
+ expect(API::Entities::Branch).to receive(:represent).with(anything, has_merged_branch_names_count(2))
+
+ get api(route, current_user), params: { per_page: 2 }
+ end
+
context 'when repository is disabled' do
include_context 'disabled repository'