From: Christian Hofstaedtler Date: Thu, 6 Feb 2014 19:22:55 +0000 (+0100) Subject: API tests: wait for http port X-Git-Tag: rec-3.6.0-rc1~189^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a1e51a8a5e64bb05842b93ddf22f4ba727fd6cf6;p=pdns API tests: wait for http port The tests were always racy, and when testing the recursor with zone files, the problem becomes visible. --- diff --git a/regression-tests.api/runtests.py b/regression-tests.api/runtests.py index 742b75d57..ce9551fb9 100755 --- a/regression-tests.api/runtests.py +++ b/regression-tests.api/runtests.py @@ -3,9 +3,11 @@ # Shell-script style. import os +import requests import subprocess import sys import tempfile +import time SQLITE_DB = 'pdns.sqlite3' WEBPORT = '5556' @@ -66,6 +68,22 @@ print "Launching pdns..." print ' '.join(pdnscmd) pdns = subprocess.Popen(pdnscmd, close_fds=True) +print "Waiting for webserver port to become available..." +available = False +for try_number in range(0, 10): + try: + res = requests.get('http://127.0.0.1:%s/' % WEBPORT) + available = True + break + except: + time.sleep(0.5) + +if not available: + print "Webserver port not reachable after 10 tries, giving up." + pdns.terminate() + pdns.wait() + sys.exit(2) + print "Running tests..." rc = 0 test_env = {}