diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-13 18:08:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-13 18:08:02 +0300 |
commit | 4eeb6b0d16021ab4a730eec4610eff2606421147 (patch) | |
tree | 488db828fe58f1e80dc5415970e4c929db7e4c4b /qa | |
parent | 8cc5f2790908ba9bb8eecba2b78a3c5a88c77b90 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
-rw-r--r-- | qa/qa.rb | 1 | ||||
-rw-r--r-- | qa/qa/runtime/search.rb | 36 |
2 files changed, 37 insertions, 0 deletions
@@ -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 |