From a1e51a8a5e64bb05842b93ddf22f4ba727fd6cf6 Mon Sep 17 00:00:00 2001 From: Christian Hofstaedtler Date: Thu, 6 Feb 2014 20:22:55 +0100 Subject: [PATCH] API tests: wait for http port The tests were always racy, and when testing the recursor with zone files, the problem becomes visible. --- regression-tests.api/runtests.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 = {} -- 2.50.1