aboutsummaryrefslogtreecommitdiff
path: root/lib/chutney/Testing.py
diff options
context:
space:
mode:
authorChristopher Baines <cb15g11@soton.ac.uk>2014-04-13 13:24:17 +0100
committerChristopher Baines <cb15g11@soton.ac.uk>2014-04-13 13:24:17 +0100
commit43024c6735391e3030bfbb0f170b59d00b788728 (patch)
treeaa1bf4ef4606833dd20aa8d2718c3d1005a68a61 /lib/chutney/Testing.py
parent43ad6bc0f94a048cfffe4ec3d22e78e75d4d6795 (diff)
downloadchutney-43024c6735391e3030bfbb0f170b59d00b788728.tar
chutney-43024c6735391e3030bfbb0f170b59d00b788728.tar.gz
Lots of better test stuff
Diffstat (limited to 'lib/chutney/Testing.py')
-rw-r--r--lib/chutney/Testing.py27
1 files changed, 20 insertions, 7 deletions
diff --git a/lib/chutney/Testing.py b/lib/chutney/Testing.py
index 8b1b356..341f519 100644
--- a/lib/chutney/Testing.py
+++ b/lib/chutney/Testing.py
@@ -240,14 +240,23 @@ def create_hidden_service(nodes):
isLeaf = True
numberRequests = 0
- def __init__(self, siteNum):
+ def __init__(self, siteNum, port):
self.siteNum = siteNum
+ self.port = port
def render_GET(self, request):
self.numberRequests += 1
request.setHeader("content-type", "text/plain")
return str(self.siteNum)
+ def listen(self):
+ site = server.Site(self)
+ self.s = reactor.listenTCP(self.port, site)
+
+ def stopListening(self):
+ self.s.stopListening()
+
+
base_port = 10080
for i in range(nodes):
@@ -261,10 +270,7 @@ def create_hidden_service(nodes):
)
hs_nodes.append(node)
- site = server.Site(Site(i))
-
- s = reactor.listenTCP(port, site)
- hs_servers.append(s)
+ hs_servers.append(Site(i, port))
port += 1
@@ -285,13 +291,20 @@ def connection_test(client_nodes, expected_nodes):
test_pass = True
+ nodes_detected = 0
+
for node, responses in sorted(responses.items()):
logging.info(node + ": " + str(responses))
- if responses == 0:
- test_pass = False
+ if responses != 0:
+ nodes_detected += 1
+
+ if nodes_detected != expected_nodes:
+ test_pass = False
if test_pass:
logging.info("Test PASS")
else:
logging.info("Test FAIL")
+
+ return test_pass