mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 00:37:44 +08:00
DEV: add "WAIT_FOR_URL" env to smoke test
This allows you to wait up to N seconds for the smoke test url to come up in some cases you want to kick off the smoke test prior to having the smoke test env ready to accept connections
This commit is contained in:
@ -33,12 +33,31 @@ task "smoke:test" do
|
||||
dir = ENV["SMOKE_TEST_SCREENSHOT_PATH"] || 'tmp/smoke-test-screenshots'
|
||||
FileUtils.mkdir_p(dir) unless Dir.exists?(dir)
|
||||
|
||||
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
||||
http.request(request)
|
||||
wait = ENV["WAIT_FOR_URL"].to_i
|
||||
|
||||
success = false
|
||||
code = nil
|
||||
retries = 0
|
||||
|
||||
loop do
|
||||
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
||||
http.request(request)
|
||||
end
|
||||
|
||||
success = response.code == "200"
|
||||
code = response.code
|
||||
|
||||
if !success && wait > 0
|
||||
sleep 5
|
||||
wait -= 5
|
||||
retries += 1
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if response.code != "200"
|
||||
raise "TRIVIAL GET FAILED WITH #{response.code}"
|
||||
if !success
|
||||
raise "TRIVIAL GET FAILED WITH #{code}: retried #{retries} times"
|
||||
end
|
||||
|
||||
results = +""
|
||||
|
Reference in New Issue
Block a user