Commit 7113c838 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '33754-broken-master-failure-in-ee-geo-e2e-test-scenario' into 'master'

Resolve "Broken master: failure in `ee:geo` E2E test scenario"

Closes #33754

See merge request gitlab-org/gitlab!18374
parents 1b5ba11b e37d18ed
...@@ -102,6 +102,8 @@ module QA ...@@ -102,6 +102,8 @@ module QA
class Secondary class Secondary
include QA::Scenario::Actable include QA::Scenario::Actable
WAIT_FOR_SERVICES_SECS = 120
def initialize def initialize
@address = QA::Runtime::Scenario.geo_secondary_address @address = QA::Runtime::Scenario.geo_secondary_address
@name = QA::Runtime::Scenario.geo_secondary_name @name = QA::Runtime::Scenario.geo_secondary_name
...@@ -135,25 +137,13 @@ module QA ...@@ -135,25 +137,13 @@ module QA
def wait_for_services def wait_for_services
puts 'Waiting until secondary node services are ready ...' puts 'Waiting until secondary node services are ready ...'
Time.new.tap do |start| elapsed = try_for(WAIT_FOR_SERVICES_SECS) do |elapsed|
while Time.new - start < 120 break elapsed if host_ready?
begin
Net::HTTP.get(URI.join(@address, '/-/readiness')).tap do |body|
if JSON.parse(body).all? { |_, service| service['status'] == 'ok' }
return puts "\nSecondary ready after #{Time.now - start} seconds." # rubocop:disable Cop/AvoidReturnFromBlocks
else
print '.'
end
end
rescue StandardError
print 'e'
end
sleep 1
end
raise "Secondary node did not start correctly in #{Time.now - start} seconds!"
end end
puts "\nSecondary ready after #{elapsed} seconds."
rescue TryForExceeded
raise "Secondary node did not start correctly after #{WAIT_FOR_SERVICES_SECS} seconds!"
end end
def authorize def authorize
...@@ -168,6 +158,39 @@ module QA ...@@ -168,6 +158,39 @@ module QA
QA::Page::Main::Menu.perform(&:sign_out) QA::Page::Main::Menu.perform(&:sign_out)
end end
end end
private
TryForExceeded = Class.new(StandardError)
def try_for(secs)
start = Time.new
loop do
elapsed = (Time.new - start).round(2)
break elapsed if elapsed >= secs
yield elapsed
sleep 1
end
raise TryForExceeded
end
def host_ready?
return true if host_status_ok?
print '.'
false
rescue StandardError
print 'e'
false
end
def host_status_ok?
body = Net::HTTP.get(URI.join(@address, '/-/readiness'))
JSON.parse(body)['status'] == 'ok'
end
end end
end end
end 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