#!/usr/bin/env python
import base64
-import Queue
import threading
import clientsubnetoption
import dns
-from dnsdisttests import DNSDistTest
+from dnsdisttests import DNSDistTest, Queue
class TestTeeAction(DNSDistTest):
_consoleKey = DNSDistTest.generateConsoleKey()
- _consoleKeyB64 = base64.b64encode(_consoleKey)
+ _consoleKeyB64 = base64.b64encode(_consoleKey).decode('ascii')
_teeServerPort = 5390
- _toTeeQueue = Queue.Queue()
- _fromTeeQueue = Queue.Queue()
+ _toTeeQueue = Queue()
+ _fromTeeQueue = Queue()
_config_template = """
setKey("%s")
controlSocket("127.0.0.1:%s")
newServer{address="127.0.0.1:%d"}
- addAction(QTypeRule(dnsdist.A), TeeAction("127.0.0.1:%d", true))
- addAction(QTypeRule(dnsdist.AAAA), TeeAction("127.0.0.1:%d", false))
+ addAction(QTypeRule(DNSQType.A), TeeAction("127.0.0.1:%d", true))
+ addAction(QTypeRule(DNSQType.AAAA), TeeAction("127.0.0.1:%d", false))
"""
_config_params = ['_consoleKeyB64', '_consolePort', '_testServerPort', '_teeServerPort', '_teeServerPort']
@classmethod
# check the TeeAction stats
stats = self.sendConsoleCommand("getAction(0):printStats()")
- self.assertEquals(stats, """refuseds\t0
+ self.assertEquals(stats, """noerrors\t%d
nxdomains\t0
-noerrors\t%d
-servfails\t0
+other-rcode\t0
+queries\t%d
recv-errors\t0
-tcp-drops\t0
+refuseds\t0
responses\t%d
-other-rcode\t0
send-errors\t0
-queries\t%d
+servfails\t0
+tcp-drops\t0
""" % (numberOfQueries, numberOfQueries, numberOfQueries))
def testTeeWithoutECS(self):
# check the TeeAction stats
stats = self.sendConsoleCommand("getAction(0):printStats()")
- self.assertEquals(stats, """refuseds\t0
+ self.assertEquals(stats, """noerrors\t%d
nxdomains\t0
-noerrors\t%d
-servfails\t0
+other-rcode\t0
+queries\t%d
recv-errors\t0
-tcp-drops\t0
+refuseds\t0
responses\t%d
-other-rcode\t0
send-errors\t0
-queries\t%d
+servfails\t0
+tcp-drops\t0
""" % (numberOfQueries, numberOfQueries, numberOfQueries))