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:
Diffstat (limited to 'spec/controllers/search_controller_spec.rb')
-rw-r--r--spec/controllers/search_controller_spec.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb
index 14b198dbefe..4131bd148da 100644
--- a/spec/controllers/search_controller_spec.rb
+++ b/spec/controllers/search_controller_spec.rb
@@ -270,6 +270,59 @@ RSpec.describe SearchController do
get(:show, params: { search: 'foo@bar.com', scope: 'users' })
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 :show, params: { scope: 'issues', search: 'hello world' }
+ end
+
+ context 'custom search sli error rate' do
+ context 'when the search is successful' do
+ it 'increments the custom search sli error rate with error: false' do
+ expect(Gitlab::Metrics::GlobalSearchSlis).to receive(:record_error_rate).with(
+ error: false,
+ search_scope: 'issues',
+ search_type: 'basic',
+ search_level: 'global'
+ )
+
+ get :show, params: { scope: 'issues', search: 'hello world' }
+ end
+ end
+
+ context 'when the search raises an error' do
+ before do
+ allow_next_instance_of(SearchService) do |service|
+ allow(service).to receive(:search_results).and_raise(ActiveRecord::QueryCanceled)
+ end
+ end
+
+ it 'increments the custom search sli error rate with error: true' do
+ expect(Gitlab::Metrics::GlobalSearchSlis).to receive(:record_error_rate).with(
+ error: true,
+ search_scope: 'issues',
+ search_type: 'basic',
+ search_level: 'global'
+ )
+
+ get :show, params: { scope: 'issues', search: 'hello world' }
+ end
+ end
+
+ context 'when something goes wrong before a search is done' do
+ it 'does not increment the error rate' do
+ expect(Gitlab::Metrics::GlobalSearchSlis).not_to receive(:record_error_rate)
+
+ get :show, params: { scope: 'issues' } # no search query
+ end
+ end
+ end
end
describe 'GET #count', :aggregate_failures do