diff options
Diffstat (limited to 'src/integration-tests')
-rw-r--r-- | src/integration-tests/Makefile.am | 12 | ||||
-rw-r--r-- | src/integration-tests/gnunet_testing.py.in | 5 | ||||
-rwxr-xr-x | src/integration-tests/test_integration_bootstrap_and_connect.py.in | 218 | ||||
-rwxr-xr-x | src/integration-tests/test_integration_clique.py.in | 4 |
4 files changed, 57 insertions, 182 deletions
diff --git a/src/integration-tests/Makefile.am b/src/integration-tests/Makefile.am index a40fa76e6..e98ba3242 100644 --- a/src/integration-tests/Makefile.am +++ b/src/integration-tests/Makefile.am | |||
@@ -13,6 +13,8 @@ bin_PROGRAMS = | |||
13 | 13 | ||
14 | check_PROGRAMS = | 14 | check_PROGRAMS = |
15 | 15 | ||
16 | noinst_SCRIPTS = \ | ||
17 | gnunet_testing.py | ||
16 | 18 | ||
17 | if HAVE_PYTHON_PEXPECT | 19 | if HAVE_PYTHON_PEXPECT |
18 | check_SCRIPTS = \ | 20 | check_SCRIPTS = \ |
@@ -29,6 +31,10 @@ endif | |||
29 | 31 | ||
30 | do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' | 32 | do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g' |
31 | 33 | ||
34 | %.py: %.py.in Makefile | ||
35 | $(do_subst) < $(srcdir)/$< > $@ | ||
36 | chmod +x $@ | ||
37 | |||
32 | test_integration_bootstrap_and_connect.py: test_integration_bootstrap_and_connect.py.in Makefile | 38 | test_integration_bootstrap_and_connect.py: test_integration_bootstrap_and_connect.py.in Makefile |
33 | $(do_subst) < $(srcdir)/test_integration_bootstrap_and_connect.py.in > test_integration_bootstrap_and_connect.py | 39 | $(do_subst) < $(srcdir)/test_integration_bootstrap_and_connect.py.in > test_integration_bootstrap_and_connect.py |
34 | chmod +x test_integration_bootstrap_and_connect.py | 40 | chmod +x test_integration_bootstrap_and_connect.py |
@@ -42,9 +48,11 @@ test_integration_clique.py: test_integration_clique.py.in Makefile | |||
42 | chmod +x test_integration_clique.py | 48 | chmod +x test_integration_clique.py |
43 | 49 | ||
44 | EXTRA_DIST = \ | 50 | EXTRA_DIST = \ |
51 | gnunet_testing.py.in \ | ||
45 | test_integration_bootstrap_and_connect.py.in \ | 52 | test_integration_bootstrap_and_connect.py.in \ |
46 | test_integration_disconnect.py.in \ | 53 | test_integration_disconnect.py.in \ |
47 | test_integration_clique.py.in | 54 | test_integration_clique.py.in |
48 | 55 | ||
49 | 56 | CLEANFILES = \ | |
50 | CLEANFILES = $(check_SCRIPTS) | 57 | $(check_SCRIPTS) \ |
58 | gnunet_testing.py | ||
diff --git a/src/integration-tests/gnunet_testing.py.in b/src/integration-tests/gnunet_testing.py.in index dccaf43eb..be288ff44 100644 --- a/src/integration-tests/gnunet_testing.py.in +++ b/src/integration-tests/gnunet_testing.py.in | |||
@@ -86,10 +86,11 @@ class StatisticsCondition (Condition): | |||
86 | self.type = 'statistics' | 86 | self.type = 'statistics' |
87 | self.peer = peer; | 87 | self.peer = peer; |
88 | self.subsystem = subsystem; | 88 | self.subsystem = subsystem; |
89 | self.name = value; | 89 | self.name = name; |
90 | self.value = value; | ||
90 | def check(self): | 91 | def check(self): |
91 | if (self.fulfilled == False): | 92 | if (self.fulfilled == False): |
92 | res = self.peer.check (subsystem, name, value); | 93 | res = self.peer.check (self.subsystem, self.name, self.value); |
93 | if (res == True): | 94 | if (res == True): |
94 | self.fulfilled = True | 95 | self.fulfilled = True |
95 | return True | 96 | return True |
diff --git a/src/integration-tests/test_integration_bootstrap_and_connect.py.in b/src/integration-tests/test_integration_bootstrap_and_connect.py.in index 57184fc61..38746544c 100755 --- a/src/integration-tests/test_integration_bootstrap_and_connect.py.in +++ b/src/integration-tests/test_integration_bootstrap_and_connect.py.in | |||
@@ -25,6 +25,12 @@ import re | |||
25 | import shutil | 25 | import shutil |
26 | import time | 26 | import time |
27 | import pexpect | 27 | import pexpect |
28 | from gnunet_testing import Peer | ||
29 | from gnunet_testing import Test | ||
30 | from gnunet_testing import Check | ||
31 | from gnunet_testing import Condition | ||
32 | from gnunet_testing import * | ||
33 | |||
28 | 34 | ||
29 | # | 35 | # |
30 | # This test tests if a fresh peer bootstraps from a hostlist server and then | 36 | # This test tests if a fresh peer bootstraps from a hostlist server and then |
@@ -36,82 +42,10 @@ import pexpect | |||
36 | #definitions | 42 | #definitions |
37 | 43 | ||
38 | testname = "test_integration_bootstrap_and_connect" | 44 | testname = "test_integration_bootstrap_and_connect" |
39 | verbose = False | 45 | verbose = True |
40 | gnunetarm = "" | ||
41 | gnunetstatistics = "" | ||
42 | success = False | 46 | success = False |
43 | timeout = 100 | 47 | timeout = 100 |
44 | 48 | ||
45 | #test conditions | ||
46 | |||
47 | #server | ||
48 | server_transport_connected = False | ||
49 | server_topology_connected = False | ||
50 | server_core_connected = False | ||
51 | server_core_session_map = False | ||
52 | server_fs_connected = False | ||
53 | |||
54 | client_transport_connected = False | ||
55 | client_topology_connected = False | ||
56 | client_core_connected = False | ||
57 | client_core_session_map = False | ||
58 | client_fs_connected = False | ||
59 | |||
60 | def vprintf (msg): | ||
61 | if verbose == True: | ||
62 | print msg | ||
63 | |||
64 | def setup (): | ||
65 | srcdir = "../.." | ||
66 | gnunet_pyexpect_dir = os.path.join (srcdir, "contrib") | ||
67 | if gnunet_pyexpect_dir not in sys.path: | ||
68 | sys.path.append (gnunet_pyexpect_dir) | ||
69 | from gnunet_pyexpect import pexpect | ||
70 | global gnunetarm | ||
71 | global gnunetstatistics | ||
72 | if os.name == 'posix': | ||
73 | gnunetarm = 'gnunet-arm' | ||
74 | gnunetstatistics = 'gnunet-statistics' | ||
75 | elif os.name == 'nt': | ||
76 | gnunetarm = 'gnunet-arm.exe' | ||
77 | gnunetstatistics = 'gnunet-statistics.exe' | ||
78 | if os.name == "nt": | ||
79 | shutil.rmtree (os.path.join (os.getenv ("TEMP"), testname), True) | ||
80 | else: | ||
81 | shutil.rmtree ("/tmp/" + testname, True) | ||
82 | |||
83 | def start (): | ||
84 | vprintf ("Starting bootstrap server & client") | ||
85 | try: | ||
86 | server = subprocess.Popen ([gnunetarm, '-sq', '-c', './confs/c_bootstrap_server.conf']) | ||
87 | server.communicate () | ||
88 | except OSError: | ||
89 | print "Can not start bootstrap server, exiting..." | ||
90 | exit (1) | ||
91 | try: | ||
92 | client = subprocess.Popen ([gnunetarm, '-sq', '-c', 'confs/c_no_nat_client.conf']) | ||
93 | client.communicate () | ||
94 | except OSError: | ||
95 | print "Can not start bootstrap client, exiting..." | ||
96 | exit (1) | ||
97 | vprintf ("Bootstrap server & client started") | ||
98 | |||
99 | def stop (): | ||
100 | vprintf ("Shutting down bootstrap server") | ||
101 | try: | ||
102 | server = subprocess.Popen ([gnunetarm, '-eq', '-c', './confs/c_bootstrap_server.conf']) | ||
103 | server.communicate () | ||
104 | except OSError: | ||
105 | print "Can not stop bootstrap server, exiting..." | ||
106 | exit (1) | ||
107 | try: | ||
108 | client = subprocess.Popen ([gnunetarm, '-eq', '-c', 'confs/c_no_nat_client.conf']) | ||
109 | client.communicate () | ||
110 | except OSError: | ||
111 | print "Can not stop bootstrap client, exiting..." | ||
112 | exit (1) | ||
113 | vprintf ("Bootstrap server & client stopped") | ||
114 | |||
115 | 49 | ||
116 | def cleanup (): | 50 | def cleanup (): |
117 | if os.name == "nt": | 51 | if os.name == "nt": |
@@ -119,120 +53,51 @@ def cleanup (): | |||
119 | shutil.rmtree (os.path.join (os.getenv ("TEMP"), "c_no_nat_client"), True) | 53 | shutil.rmtree (os.path.join (os.getenv ("TEMP"), "c_no_nat_client"), True) |
120 | else: | 54 | else: |
121 | shutil.rmtree ("/tmp/c_bootstrap_server/", True) | 55 | shutil.rmtree ("/tmp/c_bootstrap_server/", True) |
122 | shutil.rmtree ("/tmp/c_no_nat_client/", True) | 56 | shutil.rmtree ("/tmp/c_no_nat_client/", True) |
123 | 57 | ||
124 | def check_statistics (conf, subsystem, name, value): | 58 | def success (): |
125 | from gnunet_pyexpect import pexpect | 59 | global success |
126 | server = pexpect () | 60 | success = True; |
127 | server.spawn (None, [gnunetstatistics, '-c', conf ,'-q','-n', name, '-s', subsystem ], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 61 | def fail (): |
128 | #server.expect ("stdout", re.compile (r"")) | 62 | global success |
129 | test = server.read("stdout", 10240) | 63 | success= False; |
130 | if (test.find(str(value)) == -1): | ||
131 | return False | ||
132 | else: | ||
133 | return True | ||
134 | |||
135 | |||
136 | 64 | ||
137 | def check (): | 65 | def check (): |
138 | global success | ||
139 | global timeout | ||
140 | global publish | ||
141 | global server_transport_connected | ||
142 | global server_topology_connected | ||
143 | global server_core_connected | ||
144 | global server_core_session_map | ||
145 | global server_fs_connected | ||
146 | 66 | ||
147 | global client_transport_connected | 67 | check = Check () |
148 | global client_topology_connected | 68 | check.add (StatisticsCondition (client, 'transport', '# peers connected',1)) |
149 | global client_core_connected | 69 | check.add (StatisticsCondition (client, 'core', '# neighbour entries allocated',1)) |
150 | global client_core_session_map | 70 | check.add (StatisticsCondition (client, 'core', '# entries in session map',1)) |
151 | global client_fs_connected | 71 | check.add (StatisticsCondition (client, 'topology', '# peers connected',1)) |
152 | 72 | check.add (StatisticsCondition (client, 'fs', '# peers connected',1)) | |
153 | count = 1 | 73 | |
154 | while ((success == False) and (count <= timeout)): | ||
155 | # Perform checks | ||
156 | if ((False == server_transport_connected) and (True == check_statistics ('./confs/c_bootstrap_server.conf', 'transport', '# peers connected',1))): | ||
157 | server_transport_connected = True | ||
158 | vprintf ('Server transport services is connected') | ||
159 | |||
160 | if ((False == client_transport_connected) and (True == check_statistics ('./confs/c_no_nat_client.conf', 'transport', '# peers connected',1))): | ||
161 | client_transport_connected = True | ||
162 | vprintf ('Client transport services is connected') | ||
163 | |||
164 | if ((False == server_core_connected) and (True == check_statistics ('./confs/c_bootstrap_server.conf', 'core', '# neighbour entries allocated',1))): | ||
165 | server_core_connected = True | ||
166 | vprintf ('Server core services is connected') | ||
167 | |||
168 | if ((False == client_core_connected) and (True == check_statistics ('./confs/c_no_nat_client.conf', 'core', '# neighbour entries allocated',1))): | ||
169 | client_core_connected = True | ||
170 | vprintf ('Client core services is connected') | ||
171 | |||
172 | if ((False == server_core_session_map) and (True == check_statistics ('./confs/c_bootstrap_server.conf', 'core', '# entries in session map',1))): | ||
173 | server_core_session_map = True | ||
174 | vprintf ('Server core services is connected') | ||
175 | |||
176 | if ((False == client_core_session_map) and (True == check_statistics ('./confs/c_no_nat_client.conf', 'core', '# entries in session map',1))): | ||
177 | client_core_session_map = True | ||
178 | vprintf ('Client core notifies about connected') | ||
179 | 74 | ||
180 | if ((False == server_topology_connected) and (True == check_statistics ('./confs/c_bootstrap_server.conf', 'topology', '# peers connected',1))): | 75 | check.add (StatisticsCondition (server, 'transport', '# peers connected',1)) |
181 | server_topology_connected = True | 76 | check.add (StatisticsCondition (server, 'core', '# neighbour entries allocated',1)) |
182 | vprintf ('Server topology services is connected') | 77 | check.add (StatisticsCondition (server, 'core', '# entries in session map',1)) |
183 | 78 | check.add (StatisticsCondition (server, 'topology', '# peers connected',1)) | |
184 | if ((False == client_topology_connected) and (True == check_statistics ('./confs/c_no_nat_client.conf', 'topology', '# peers connected',1))): | 79 | check.add (StatisticsCondition (server, 'fs', '# peers connected',1)) |
185 | client_topology_connected = True | 80 | |
186 | vprintf ('Client topology services is connected') | 81 | check.run_blocking (10, success, fail) |
187 | |||
188 | if ((False == client_fs_connected) and (True == check_statistics ('./confs/c_no_nat_client.conf', 'fs', '# peers connected',1))): | ||
189 | client_fs_connected = True | ||
190 | vprintf ('Client fs services is connected') | ||
191 | if ((False == server_fs_connected) and (True == check_statistics ('./confs/c_bootstrap_server.conf', 'fs', '# peers connected',1))): | ||
192 | server_fs_connected = True | ||
193 | vprintf ('Server fs services is connected') | ||
194 | |||
195 | # Check if conditions fulfilled | ||
196 | if ((True == client_transport_connected) and (True == server_transport_connected) and | ||
197 | (True == client_topology_connected) and (True == server_topology_connected) and | ||
198 | (True == client_core_connected) and (True == server_core_connected) and | ||
199 | (True == client_core_session_map) and (True == server_core_session_map) and | ||
200 | (True == client_fs_connected) and (True == server_fs_connected)): | ||
201 | success = True | ||
202 | break | ||
203 | print '.', | ||
204 | time.sleep(1) | ||
205 | count += 1 | ||
206 | if (success == False): | ||
207 | print '' | ||
208 | if (client_transport_connected == False): | ||
209 | print ('Client transport was NOT connected') | ||
210 | if (server_transport_connected == False): | ||
211 | print ('Server transport was NOT connected') | ||
212 | if (client_topology_connected == False): | ||
213 | print ('Client topology was NOT connected') | ||
214 | if (server_topology_connected == False): | ||
215 | print ('Server topology was NOT connected') | ||
216 | if (client_core_connected == False): | ||
217 | print ('Client core was NOT connected') | ||
218 | if (server_core_connected == False): | ||
219 | print ('Server core was NOT connected') | ||
220 | if (client_core_session_map == False): | ||
221 | print ('Client core sessions did NOT increase') | ||
222 | if (server_core_session_map == False): | ||
223 | print ('Server core sessions did NOT increase') | ||
224 | 82 | ||
225 | # | 83 | # |
226 | # Test execution | 84 | # Test execution |
227 | # | 85 | # |
228 | 86 | ||
229 | vprintf ("Running " + testname) | 87 | test = Test ('test_integration_bootstrap_and_connect.py', verbose) |
230 | setup () | 88 | |
231 | start () | 89 | server = Peer(test, './confs/c_bootstrap_server.conf'); |
90 | server.start(); | ||
232 | 91 | ||
233 | check () | 92 | client = Peer(test, './confs/c_no_nat_client.conf'); |
93 | client.start(); | ||
94 | |||
95 | if ((client.started == True) and (server.started == True)): | ||
96 | check () | ||
97 | |||
98 | server.stop () | ||
99 | client.stop () | ||
234 | 100 | ||
235 | stop () | ||
236 | cleanup () | 101 | cleanup () |
237 | 102 | ||
238 | if (success == False): | 103 | if (success == False): |
@@ -240,6 +105,3 @@ if (success == False): | |||
240 | exit (1) | 105 | exit (1) |
241 | else: | 106 | else: |
242 | exit (0) | 107 | exit (0) |
243 | |||
244 | |||
245 | |||
diff --git a/src/integration-tests/test_integration_clique.py.in b/src/integration-tests/test_integration_clique.py.in index 0b4a8550a..fbdadae12 100755 --- a/src/integration-tests/test_integration_clique.py.in +++ b/src/integration-tests/test_integration_clique.py.in | |||
@@ -41,6 +41,10 @@ gnunetstatistics = "" | |||
41 | success = False | 41 | success = False |
42 | timeout = 10 | 42 | timeout = 10 |
43 | 43 | ||
44 | s_server = False; | ||
45 | s_c1 = False; | ||
46 | s_c2 = False; | ||
47 | |||
44 | #test conditions | 48 | #test conditions |
45 | 49 | ||
46 | 50 | ||