]> granicus.if.org Git - pdns/commitdiff
API tests: wait for http port
authorChristian Hofstaedtler <christian@hofstaedtler.name>
Thu, 6 Feb 2014 19:22:55 +0000 (20:22 +0100)
committerChristian Hofstaedtler <christian@hofstaedtler.name>
Fri, 7 Feb 2014 14:11:03 +0000 (15:11 +0100)
The tests were always racy, and when testing the recursor with zone
files, the problem becomes visible.

regression-tests.api/runtests.py

index 742b75d5745787130bfe65b7e22503f1f928f434..ce9551fb993d50a847668bed2417ccb226c154eb 100755 (executable)
@@ -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 = {}