2 # This file is part of GNUnet.
3 # (C) 2010 Christian Grothoff (and other contributing authors)
5 # GNUnet is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published
7 # by the Free Software Foundation; either version 2, or (at your
8 # option) any later version.
10 # GNUnet is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with GNUnet; see the file COPYING. If not, write to the
17 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 # Boston, MA 02111-1307, USA.
22 # This test starts 3 peers and expects bootstrap and a connected clique
23 # After a successful clique it shuts down all peers and starts the non-bootstrap
24 # peers, expecting them to reconnect
26 # Conditions for successful exit:
27 # Both peers have 1 connected peer in transport, core, topology, fs
35 from gnunet_testing import Peer
36 from gnunet_testing import Test
37 from gnunet_testing import Check
38 from gnunet_testing import Condition
39 from gnunet_testing import *
44 testname = "test_integration_clique"
49 tmp = os.getenv ("TEMP")
55 path = os.path.join (tmp, "c_bootstrap_server")
56 test.p ("Removing " + path)
57 while ((os.path.exists(path)) and (retries > 0)):
58 shutil.rmtree ((path), False)
61 if (os.path.exists(path)):
62 test.p ("Failed to remove " + path)
65 path = os.path.join (tmp, "c_no_nat_client")
66 test.p ("Removing " + path)
67 while ((os.path.exists(path)) and (retries > 0)):
68 shutil.rmtree ((path), False)
71 if (os.path.exists(path)):
72 test.p ("Failed to remove " + path)
75 path = os.path.join (tmp, "c_no_nat_client_2")
76 test.p ("Removing " + path)
77 while ((os.path.exists(path)) and (retries > 0)):
78 shutil.rmtree ((path), False)
81 if (os.path.exists(path)):
82 test.p ("Failed to remove " + path)
83 shutil.rmtree (os.path.join (tmp, "c_no_nat_client_2"), True)
86 def success_cont (check):
91 def fail_cont (check):
97 def success_connect_cont (check):
99 print "Connected clique, shutdown"
108 check.add (StatisticsCondition (client, 'transport', '# peers connected',1))
109 check.add (StatisticsCondition (client, 'core', '# neighbour entries allocated',1))
110 check.add (StatisticsCondition (client, 'core', '# peers connected',1))
111 check.add (StatisticsCondition (client, 'topology', '# peers connected',1))
112 check.add (StatisticsCondition (client, 'fs', '# peers connected',1))
114 check.add (StatisticsCondition (client2, 'transport', '# peers connected',1))
115 check.add (StatisticsCondition (client2, 'core', '# neighbour entries allocated',1))
116 check.add (StatisticsCondition (client2, 'core', '# peers connected',1))
117 check.add (StatisticsCondition (client2, 'topology', '# peers connected',1))
118 check.add (StatisticsCondition (client2, 'fs', '# peers connected',1))
120 check.run_blocking (check_timeout, success_cont, fail_cont)
123 def fail_connect_cont (check):
125 print "Failed to connect clique, shutdown"
127 check.evaluate(False)
130 def check_connect ():
132 check.add (StatisticsCondition (client, 'transport', '# peers connected',2))
133 check.add (StatisticsCondition (client, 'core', '# neighbour entries allocated',2))
134 check.add (StatisticsCondition (client, 'core', '# peers connected',2))
135 check.add (StatisticsCondition (client, 'topology', '# peers connected',2))
136 check.add (StatisticsCondition (client, 'fs', '# peers connected',2))
138 check.add (StatisticsCondition (client2, 'transport', '# peers connected',2))
139 check.add (StatisticsCondition (client2, 'core', '# neighbour entries allocated',2))
140 check.add (StatisticsCondition (client2, 'core', '# peers connected',2))
141 check.add (StatisticsCondition (client2, 'topology', '# peers connected',2))
142 check.add (StatisticsCondition (client2, 'fs', '# peers connected',2))
144 check.add (StatisticsCondition (server, 'transport', '# peers connected',2))
145 check.add (StatisticsCondition (server, 'core', '# neighbour entries allocated',2))
146 check.add (StatisticsCondition (server, 'core', '# peers connected',2))
147 check.add (StatisticsCondition (server, 'topology', '# peers connected',2))
148 check.add (StatisticsCondition (server, 'fs', '# peers connected',2))
150 check.run_blocking (check_timeout, success_connect_cont, fail_connect_cont)
164 test = Test ('test_integration_disconnect', verbose)
166 server = Peer(test, './confs/c_bootstrap_server.conf');
169 client = Peer(test, './confs/c_no_nat_client.conf');
172 client2 = Peer(test, './confs/c_no_nat_client_2.conf');
175 if ((client.started == True) and (client2.started == True) and (server.started == True)):
176 test.p ('Peers started, running check')
185 if (success == False):
186 print ('Test failed')
194 except (KeyboardInterrupt, SystemExit):
195 print 'Test interrupted'
200 if (success == False):