aboutsummaryrefslogtreecommitdiff
path: root/networks/hs_instance_start.py
diff options
context:
space:
mode:
Diffstat (limited to 'networks/hs_instance_start.py')
-rw-r--r--networks/hs_instance_start.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/networks/hs_instance_start.py b/networks/hs_instance_start.py
new file mode 100644
index 0000000..42a3dbc
--- /dev/null
+++ b/networks/hs_instance_start.py
@@ -0,0 +1,68 @@
+from chutney.Testing import *
+from chutney.TorNet import *
+
+from twisted.internet import reactor
+
+from stem.control import EventType
+
+def hs_instance_start(network):
+ hs_nodes = network.get("h")
+ clients = network.get("c")
+
+ if len(clients) % len(hs_nodes) != 0:
+ logging.error("There must be a equal number of clients per hs_node")
+ return False
+
+ clients_per_node = len(clients) / len(hs_nodes)
+
+ if clients_per_node < 1:
+ logging.error("Not enough clients")
+ return False
+
+ logging.info("Clients per node %d" % clients_per_node)
+
+ # To ensure the ..
+ client_groups = zip(*(iter(clients),) * clients_per_node)
+
+ initial_nodes = network.get("a") + network.get("r") + network.get("c")
+
+ if not all([ n.getController().start() for n in initial_nodes ]):
+ return False
+
+ nodes_by_fingerprint = get_node_fingerprints(network.get("a") + network.get("r"))
+
+ logging.info("All initial nodes running")
+
+ thread.start_new_thread(reactor.run, (), {"installSignalHandlers": 0})
+
+ logging.info("There are %d nodes to start" % len(hs_nodes))
+
+ for i, hs_node in enumerate(hs_nodes):
+ logging.info("Starting node %d" % i)
+
+ if not hs_node.getController().start():
+ return False # Stop on failure
+
+ track_introduction_points(hs_node)
+
+ node_published_descriptor = threading.Event()
+
+ def hs_node_listener(logevent):
+ if "Successfully uploaded v2 rend descriptors" in logevent.message:
+ node_published_descriptor.set()
+
+ hs_node.getStemController().add_event_listener(hs_node_listener, EventType.INFO)
+
+ node_published_descriptor.wait()
+
+ hs_node.getStemController().remove_event_listener(hs_node_listener)
+
+ # Now begin testing
+
+ for c_group in range(i + 1):
+ logging.info("Testing with the %d client group" % c_group)
+ connection_test(client_groups[c_group], i + 1)
+
+ check_same_intro_points()
+
+ reactor.stop()