Commit edc5b7d3 authored by Walmyr Lima e Silva Filho's avatar Walmyr Lima e Silva Filho

Merge branch '43732-fix-elasticsearch-qa-test' into 'master'

Wait for elasticsearch server before searching

Closes #43732

See merge request gitlab-org/gitlab!21711
parents 4d018fd0 de7b6a47
......@@ -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'
......
# 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
......@@ -17,6 +17,8 @@ module QA
es.api_client = Runtime::API::Client.as_admin
end
Runtime::Search.elasticsearch_responding?
@project = Resource::Project.fabricate_via_api! do |project|
project.add_name_uuid = false
project.name = "es-adv-global-search-#{project_name_suffix}1"
......@@ -50,6 +52,7 @@ module QA
Page::Search::Results.perform do |results|
results.switch_to_projects
expect(results).to have_content("Advanced search functionality is enabled")
expect(results).to have_project(@project.name)
end
end
......
......@@ -14,6 +14,8 @@ module QA
QA::EE::Resource::Settings::Elasticsearch.fabricate_via_browser_ui!
end
Runtime::Search.elasticsearch_responding?
@project = Resource::Project.fabricate_via_api! do |project|
project.name = project_name
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment