diff options
author | John Cai <jcai@gitlab.com> | 2019-05-06 16:57:44 -0700 |
---|---|---|
committer | John Cai <jcai@gitlab.com> | 2019-05-14 12:13:19 -0500 |
commit | f86797b5a91791875ccd1a02806d4cab236c1ac6 (patch) | |
tree | e48b1e9bcf1e068baf84d4780e65c25b5c9a9110 /spec | |
parent | e1aa7f5074aab8190d16a6f25121d33b99a07238 (diff) | |
download | gitlab-ce-f86797b5a91791875ccd1a02806d4cab236c1ac6.tar.gz |
Omit max-count for diverging_commit_counts behind feature flagjc-omit-count-diverging-commits-max
We want to optimize the query for the CountDivergingCommits rpc by
removing the --max-count argument now that we have commit graphs
enabled for all repositories during housekeeping. However, we want to
test this first behind a feature flag.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/repository_spec.rb | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 9ff0f355fd4..c5ab7e57272 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -2286,12 +2286,45 @@ describe Repository do end describe '#diverging_commit_counts' do + let(:diverged_branch) { repository.find_branch('fix') } + let(:root_ref_sha) { repository.raw_repository.commit(repository.root_ref).id } + let(:diverged_branch_sha) { diverged_branch.dereferenced_target.sha } + it 'returns the commit counts behind and ahead of default branch' do - result = repository.diverging_commit_counts( - repository.find_branch('fix')) + result = repository.diverging_commit_counts(diverged_branch) expect(result).to eq(behind: 29, ahead: 2) end + + context 'when gitaly_count_diverging_commits_no_max is enabled' do + before do + stub_feature_flags(gitaly_count_diverging_commits_no_max: true) + end + + it 'calls diverging_commit_count without max count' do + expect(repository.raw_repository) + .to receive(:diverging_commit_count) + .with(root_ref_sha, diverged_branch_sha) + .and_return([29, 2]) + + repository.diverging_commit_counts(diverged_branch) + end + end + + context 'when gitaly_count_diverging_commits_no_max is disabled' do + before do + stub_feature_flags(gitaly_count_diverging_commits_no_max: false) + end + + it 'calls diverging_commit_count with max count' do + expect(repository.raw_repository) + .to receive(:diverging_commit_count) + .with(root_ref_sha, diverged_branch_sha, max_count: Repository::MAX_DIVERGING_COUNT) + .and_return([29, 2]) + + repository.diverging_commit_counts(diverged_branch) + end + end end describe '#refresh_method_caches' do |