Skip to content
Snippets Groups Projects
Verified Commit a406d7ca authored by Andrejs Cunskis's avatar Andrejs Cunskis :flag_lv:
Browse files

Improve low level network error handling in e2e readiness check

Fix spec
parent cf645c53
No related branches found
No related tags found
3 merge requests!181325Fix ambiguous `created_at` in project.rb,!179611Draft: Rebase CR approach for zoekt assignments,!177020Improve low level network error handling in e2e readiness check
......@@ -85,6 +85,8 @@ def wait_for_login_page_to_load
# @param response [RestClient::Response]
# @return [Boolean]
def cloudflare_response?(response)
return false unless response
response.headers[:server] == "cloudflare" || response.code == 403
end
......@@ -102,6 +104,7 @@ def validate_readiness_via_ui!
# @param response [RestClient::Response]
# @return [void]
def validate_readiness_via_api!(response)
raise "Failed to obtain valid http response from #{sign_in_url}" unless response
raise "Got unsucessfull response code from #{sign_in_url}: #{response.code}" unless ok_response?(response)
raise "Sign in page missing required elements: '#{elements_css}'" unless required_elements_present?(response)
end
......@@ -111,6 +114,9 @@ def validate_readiness_via_api!(response)
# @return [RestClient::Response]
def fetch_sign_in_page
get(sign_in_url)
rescue StandardError => e
debug("Error fetching sign-in page: #{e}")
nil
end
# Validate response code is 200
......
......@@ -64,7 +64,9 @@
end
it "raises an error on validation" do
expect { readiness_check.perform }.to raise_error("#{msg_base} Timed out connecting to server")
expect { readiness_check.perform }.to raise_error(
"#{msg_base} Failed to obtain valid http response from example.com/users/sign_in"
)
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment