From 4eeb6b0d16021ab4a730eec4610eff2606421147 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Fri, 13 Dec 2019 15:08:02 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- qa/qa.rb | 1 + qa/qa/runtime/search.rb | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 qa/qa/runtime/search.rb (limited to 'qa') diff --git a/qa/qa.rb b/qa/qa.rb index 249736fc8b0..509de4af79c 100644 --- a/qa/qa.rb +++ b/qa/qa.rb @@ -36,6 +36,7 @@ module QA autoload :GPG, 'qa/runtime/gpg' autoload :MailHog, 'qa/runtime/mail_hog' autoload :IPAddress, 'qa/runtime/ip_address' + autoload :Search, 'qa/runtime/search' module API autoload :Client, 'qa/runtime/api/client' diff --git a/qa/qa/runtime/search.rb b/qa/qa/runtime/search.rb new file mode 100644 index 00000000000..faa110c96e7 --- /dev/null +++ b/qa/qa/runtime/search.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +module QA + module Runtime + module Search + extend self + extend Support::Api + + ElasticSearchServerError = Class.new(RuntimeError) + + def elasticsearch_responding? + QA::Runtime::Logger.debug("Attempting to search via Elasticsearch...") + + QA::Support::Retrier.retry_on_exception do + # We don't care about the results of the search, we just need + # any search that uses Elasticsearch, not the native search + # The Elasticsearch-only scopes are blobs, wiki_blobs, and commits. + request = Runtime::API::Request.new(api_client, "/search?scope=blobs&search=foo") + response = get(request.url) + + unless response.code == singleton_class::HTTP_STATUS_OK + raise ElasticSearchServerError, "Search attempt failed. Request returned (#{response.code}): `#{response}`." + end + + true + end + end + + private + + def api_client + @api_client ||= Runtime::API::Client.new(:gitlab) + end + end + end +end -- cgit v1.2.1