mirror of
https://github.com/discourse/discourse.git
synced 2025-04-19 06:49:04 +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:
parent
ce89f19250
commit
50e6ee55a9
@ -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 = +""
|
||||
|
@ -1,3 +1,5 @@
|
||||
/*eslint no-console: "off"*/
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
if (args.length < 1 || args.length > 2) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user