blob: f3ca787736d39f8d4cd9f0df95c319179e39a29e (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
from chutney.Testing import *
from chutney.TorNet import *
from stem.control import EventType
import time
def hs_instance_stop(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")
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():
logging.error("Error starting node %d" %i)
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()
for i, hs_node in reversed(list(enumerate(hs_nodes))):
logging.info("Stopping node %d" % i)
hs_node.getController().stop()
time.sleep(1)
# Now begin testing
for c_group in range(len(hs_nodes)):
logging.info("Testing with the %d client group" % c_group)
connection_test(client_groups[c_group], i + 1)
check_same_intro_points()
|