2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 10:50:21 +08:00

warmup prior to running tests

This commit is contained in:
Sam 2017-07-19 12:04:03 -04:00
parent bf0d70e820
commit 6e3b2cc860

View file

@ -51,6 +51,25 @@ task "qunit:test", [:timeout] => :environment do |_, args|
cmd += " #{args[:timeout]}"
end
@now = Time.now
def elapsed
Time.now - @now
end
# wait for server to accept connections
require 'net/http'
uri = URI("http://localhost:#{port}/assets/test_helper.js")
puts "Warming up Rails server"
begin
Net::HTTP.get(uri)
rescue Errno::ECONNREFUSED
sleep 1
retry unless elapsed() > 60
puts "Timed out. Can no connect to forked server!"
exit 1
end
puts "Rails server is warmed up"
# wait for server to respond, will exception out on failure
tries = 0
begin