import time
SQLITE_DB = 'pdns.sqlite3'
-WEBPORT = '5556'
+WEBPORT = 5556
+DNSPORT = 5300
APIKEY = '1234567890abcdefghijklmnopq-key'
PDNSUTIL_CMD = ["../pdns/pdnsutil", "--config-dir=."]
os.mkdir(name)
+def format_call_args(cmd):
+ return "$ '%s'" % ("' '".join(cmd))
+
+
+def run_check_call(cmd, *args, **kwargs):
+ print format_call_args(cmd)
+ subprocess.check_call(cmd, *args, **kwargs)
+
+
wait = ('--wait' in sys.argv)
if wait:
sys.argv.remove('--wait')
daemon = sys.argv[1]
+pdns_server = os.environ.get("PDNSSERVER", "../pdns/pdns_server")
pdns_recursor = os.environ.get("PDNSRECURSOR", "../pdns/recursordist/pdns_recursor")
+common_args = [
+ "--daemon=no", "--socket-dir=.", "--config-dir=.",
+ "--local-address=127.0.0.1", "--local-port="+str(DNSPORT),
+ "--webserver=yes", "--webserver-port="+str(WEBPORT), "--webserver-address=127.0.0.1", "--webserver-password=something",
+ "--api-key="+APIKEY
+]
if daemon == 'authoritative':
# Prepare sqlite DB with some zones.
- subprocess.check_call(["rm", "-f", SQLITE_DB])
- subprocess.check_call(["make", "-C", "../pdns", "zone2sql"])
+ run_check_call(["rm", "-f", SQLITE_DB])
+ run_check_call(["make", "-C", "../pdns", "zone2sql"])
with open('../modules/gsqlite3backend/schema.sqlite3.sql', 'r') as schema_file:
- subprocess.check_call(["sqlite3", SQLITE_DB], stdin=schema_file)
+ run_check_call(["sqlite3", SQLITE_DB], stdin=schema_file)
with open('named.conf', 'w') as named_conf:
named_conf.write(NAMED_CONF_TPL)
if p.returncode != 0:
raise Exception("zone2sql failed")
tf.seek(0, os.SEEK_SET) # rewind
- subprocess.check_call(["sqlite3", SQLITE_DB], stdin=tf)
+ run_check_call(["sqlite3", SQLITE_DB], stdin=tf)
with open('bindbackend.conf', 'w') as bindbackend_conf:
bindbackend_conf.write(BINDBACKEND_CONF_TPL)
with open('pdns.conf', 'w') as pdns_conf:
pdns_conf.write(AUTH_CONF_TPL)
- subprocess.check_call(PDNSUTIL_CMD + ["secure-zone", "powerdnssec.org"])
- pdnscmd = ("../pdns/pdns_server --daemon=no --local-address=127.0.0.1 --local-ipv6= --local-port=5300 --socket-dir=./ --no-shuffle --dnsupdate=yes --cache-ttl=0 --config-dir=. --api=yes --webserver-port="+WEBPORT+" --webserver-address=127.0.0.1 --api-key="+APIKEY).split()
+ run_check_call(PDNSUTIL_CMD + ["secure-zone", "powerdnssec.org"])
+ servercmd = [pdns_server] + common_args + ["--local-ipv6=", "--no-shuffle", "--dnsupdate=yes", "--cache-ttl=0", "--api=yes"]
else:
conf_dir = 'rec-conf.d'
with open(conf_dir+'/example.com..conf', 'w') as conf_file:
conf_file.write(REC_EXAMPLE_COM_CONF_TPL)
- pdnscmd = (pdns_recursor + " --daemon=no --socket-dir=. --config-dir=. --allow-from-file=acl.list --local-address=127.0.0.1 --local-port=5555 --webserver=yes --webserver-port="+WEBPORT+" --webserver-address=127.0.0.1 --webserver-password=something --api-key="+APIKEY).split()
+ servercmd = [pdns_recursor] + common_args + ["--allow-from-file=acl.list"]
# Now run pdns and the tests.
-print "Launching pdns..."
-print ' '.join(pdnscmd)
-pdns = subprocess.Popen(pdnscmd, close_fds=True)
+print "Launching server..."
+print format_call_args(servercmd)
+serverproc = subprocess.Popen(servercmd, close_fds=True)
print "Waiting for webserver port to become available..."
available = False
if not available:
print "Webserver port not reachable after 10 tries, giving up."
- pdns.terminate()
- pdns.wait()
+ serverproc.terminate()
+ serverproc.wait()
sys.exit(2)
print "Running tests..."
-rc = 0
+returncode = 0
test_env = {}
test_env.update(os.environ)
test_env.update({
- 'WEBPORT': WEBPORT,
+ 'WEBPORT': str(WEBPORT),
'APIKEY': APIKEY,
'DAEMON': daemon,
'SQLITE_DB': SQLITE_DB,
try:
print ""
- p = subprocess.check_call(["nosetests", "--with-xunit"] + tests, env=test_env)
+ run_check_call(["nosetests", "--with-xunit", "-v"] + tests, env=test_env)
except subprocess.CalledProcessError as ex:
- rc = ex.returncode
+ returncode = ex.returncode
finally:
if wait:
print "Waiting as requested, press ENTER to stop."
raw_input()
- pdns.terminate()
- pdns.wait()
+ serverproc.terminate()
+ serverproc.wait()
-sys.exit(rc)
+sys.exit(returncode)