diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /spec/requests/api/search_spec.rb | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'spec/requests/api/search_spec.rb')
-rw-r--r-- | spec/requests/api/search_spec.rb | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/spec/requests/api/search_spec.rb b/spec/requests/api/search_spec.rb index 6034d26f1d2..05f38aff6ab 100644 --- a/spec/requests/api/search_spec.rb +++ b/spec/requests/api/search_spec.rb @@ -9,6 +9,7 @@ RSpec.describe API::Search do let_it_be(:repo_project) { create(:project, :public, :repository, group: group) } before do + allow(Gitlab::ApplicationRateLimiter).to receive(:threshold).and_return(0) allow(Gitlab::ApplicationRateLimiter).to receive(:threshold).with(:search_rate_limit).and_return(1000) allow(Gitlab::ApplicationRateLimiter).to receive(:threshold).with(:search_rate_limit_unauthenticated).and_return(1000) end @@ -351,6 +352,43 @@ RSpec.describe API::Search do end end + it 'increments the custom search sli apdex' do + expect(Gitlab::Metrics::GlobalSearchSlis).to receive(:record_apdex).with( + elapsed: a_kind_of(Numeric), + search_scope: 'issues', + search_type: 'basic', + search_level: 'global' + ) + + get api(endpoint, user), params: { scope: 'issues', search: 'john doe' } + end + + it 'increments the custom search sli error rate with error false if no error occurred' do + expect(Gitlab::Metrics::GlobalSearchSlis).to receive(:record_error_rate).with( + error: false, + search_scope: 'issues', + search_type: 'basic', + search_level: 'global' + ) + + get api(endpoint, user), params: { scope: 'issues', search: 'john doe' } + end + + it 'increments the custom search sli error rate with error true if an error occurred' do + allow_next_instance_of(SearchService) do |service| + allow(service).to receive(:search_results).and_raise(ActiveRecord::QueryCanceled) + end + + expect(Gitlab::Metrics::GlobalSearchSlis).to receive(:record_error_rate).with( + error: true, + search_scope: 'issues', + search_type: 'basic', + search_level: 'global' + ) + + get api(endpoint, user), params: { scope: 'issues', search: 'john doe' } + end + it 'sets global search information for logging' do expect(Gitlab::Instrumentation::GlobalSearchApi).to receive(:set_information).with( type: 'basic', @@ -618,7 +656,7 @@ RSpec.describe API::Search do context 'when requesting basic search' do it 'passes the parameter to search service' do - expect(SearchService).to receive(:new).with(user, hash_including(basic_search: 'true')) + expect(SearchService).to receive(:new).with(user, hash_including(basic_search: 'true')).twice get api(endpoint, user), params: { scope: 'issues', search: 'awesome', basic_search: 'true' } end |