aboutsummaryrefslogtreecommitdiff
path: root/src/integration-tests
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-12-17 15:00:28 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-12-17 15:00:28 +0000
commit2098bde27ecaa44210d225db9cf45773785e4ba4 (patch)
tree0ef279962408e8c2a39dc9bf8e12849248548d44 /src/integration-tests
parenta0c1ad04a2c5b6994ab7b1cf5e9714d977d413b5 (diff)
downloadgnunet-2098bde27ecaa44210d225db9cf45773785e4ba4.tar.gz
gnunet-2098bde27ecaa44210d225db9cf45773785e4ba4.zip
re-adding disconnect test
Diffstat (limited to 'src/integration-tests')
-rw-r--r--src/integration-tests/Makefile.am5
-rwxr-xr-xsrc/integration-tests/test_integration_disconnect.py.in103
2 files changed, 75 insertions, 33 deletions
diff --git a/src/integration-tests/Makefile.am b/src/integration-tests/Makefile.am
index c986b2c3a..393184181 100644
--- a/src/integration-tests/Makefile.am
+++ b/src/integration-tests/Makefile.am
@@ -16,14 +16,15 @@ noinst_SCRIPTS = \
16if HAVE_PYTHON 16if HAVE_PYTHON
17check_SCRIPTS = \ 17check_SCRIPTS = \
18 test_integration_bootstrap_and_connect.py \ 18 test_integration_bootstrap_and_connect.py \
19 test_integration_restart.py 19 test_integration_disconnect.py \
20 test_integration_restart.py
20# test_integration_bootstrap_and_connect_and_disconnect.py \ 21# test_integration_bootstrap_and_connect_and_disconnect.py \
21# test_integration_bootstrap_and_connect_and_disconnect_nat.py \ 22# test_integration_bootstrap_and_connect_and_disconnect_nat.py \
22# test_integration_clique.py \ 23# test_integration_clique.py \
23# test_integration_clique_nat.py \ 24# test_integration_clique_nat.py \
24# test_integration_connect_on_restart.py 25# test_integration_connect_on_restart.py
25endif 26endif
26# test_integration_disconnect.py 27
27 28
28if HAVE_MHD 29if HAVE_MHD
29if ENABLE_TEST_RUN 30if ENABLE_TEST_RUN
diff --git a/src/integration-tests/test_integration_disconnect.py.in b/src/integration-tests/test_integration_disconnect.py.in
index 2a863f8b2..1de1cf042 100755
--- a/src/integration-tests/test_integration_disconnect.py.in
+++ b/src/integration-tests/test_integration_disconnect.py.in
@@ -19,6 +19,7 @@
19# 19#
20# 20#
21import sys 21import sys
22import signal
22import os 23import os
23import subprocess 24import subprocess
24import re 25import re
@@ -37,7 +38,7 @@ from gnunet_testing import *
37# in transport, core, topology, fs, the server is shutdown 38# in transport, core, topology, fs, the server is shutdown
38# 39#
39# Conditions for successful exit: 40# Conditions for successful exit:
40# Both peers have 0 connected peer in transport, core, topology, fs 41# Client peer has 0 connected peer in transport, core, topology, dht, fs
41 42
42#definitions 43#definitions
43 44
@@ -51,21 +52,22 @@ else:
51 tmp = "/tmp" 52 tmp = "/tmp"
52 53
53def cleanup (): 54def cleanup ():
54 shutil.rmtree (os.path.join (tmp, "c_bootstrap_server"), True) 55 shutil.rmtree (os.path.join (tmp, "c_bootstrap_server"), True)
55 shutil.rmtree (os.path.join (tmp, "c_no_nat_client"), True) 56 shutil.rmtree (os.path.join (tmp, "c_no_nat_client"), True)
56 57
57 58
58def success_disconnect_cont (check): 59def success_disconnect_cont (check):
59 global success 60 print 'Peers disconnected successfully'
60 success = True; 61 global success
62 success = True;
61 63
62 64
63def fail_disconnect_cont (check): 65def fail_disconnect_cont (check):
64 global success 66 global success
65 success = False; 67 success = False;
66 check.evaluate(True) 68 print 'Peers failed to disconnect'
69 check.evaluate(True)
67 70
68
69def check_disconnect (): 71def check_disconnect ():
70 test.p ('Shutting down bootstrap server') 72 test.p ('Shutting down bootstrap server')
71 server.stop () 73 server.stop ()
@@ -74,18 +76,21 @@ def check_disconnect ():
74 check.add (StatisticsCondition (client, 'core', '# neighbour entries allocated',0)) 76 check.add (StatisticsCondition (client, 'core', '# neighbour entries allocated',0))
75 check.add (StatisticsCondition (client, 'core', '# peers connected',0)) 77 check.add (StatisticsCondition (client, 'core', '# peers connected',0))
76 check.add (StatisticsCondition (client, 'topology', '# peers connected',0)) 78 check.add (StatisticsCondition (client, 'topology', '# peers connected',0))
79 check.add (StatisticsCondition (client, 'dht', '# peers connected',0))
77 check.add (StatisticsCondition (client, 'fs', '# peers connected',0)) 80 check.add (StatisticsCondition (client, 'fs', '# peers connected',0))
78 check.run_blocking (check_timeout, success_disconnect_cont, fail_disconnect_cont) 81 check.run_blocking (check_timeout, success_disconnect_cont, fail_disconnect_cont)
79 82
80 83
81def success_connect_cont (check): 84def success_connect_cont (check):
82 check_disconnect () 85 print 'Peers connected successfully'
86 check_disconnect ()
83 87
84 88
85def fail_connect_cont (check): 89def fail_connect_cont (check):
86 global success 90 global success
87 success= False; 91 success= False
88 check.evaluate(True) 92 print 'Peers failed to connected!'
93 check.evaluate(True)
89 94
90 95
91def check_connect (): 96def check_connect ():
@@ -94,12 +99,14 @@ def check_connect ():
94 check.add (StatisticsCondition (client, 'core', '# neighbour entries allocated',1)) 99 check.add (StatisticsCondition (client, 'core', '# neighbour entries allocated',1))
95 check.add (StatisticsCondition (client, 'core', '# peers connected',1)) 100 check.add (StatisticsCondition (client, 'core', '# peers connected',1))
96 check.add (StatisticsCondition (client, 'topology', '# peers connected',1)) 101 check.add (StatisticsCondition (client, 'topology', '# peers connected',1))
102 check.add (StatisticsCondition (client, 'dht', '# peers connected',1))
97 check.add (StatisticsCondition (client, 'fs', '# peers connected',1)) 103 check.add (StatisticsCondition (client, 'fs', '# peers connected',1))
98 104
99 check.add (StatisticsCondition (server, 'transport', '# peers connected',1)) 105 check.add (StatisticsCondition (server, 'transport', '# peers connected',1))
100 check.add (StatisticsCondition (server, 'core', '# neighbour entries allocated',1)) 106 check.add (StatisticsCondition (server, 'core', '# neighbour entries allocated',1))
101 check.add (StatisticsCondition (server, 'core', '# peers connected',1)) 107 check.add (StatisticsCondition (server, 'core', '# peers connected',1))
102 check.add (StatisticsCondition (server, 'topology', '# peers connected',1)) 108 check.add (StatisticsCondition (server, 'topology', '# peers connected',1))
109 check.add (StatisticsCondition (client, 'dht', '# peers connected',1))
103 check.add (StatisticsCondition (server, 'fs', '# peers connected',1)) 110 check.add (StatisticsCondition (server, 'fs', '# peers connected',1))
104 111
105 check.run_blocking (check_timeout, success_connect_cont, fail_connect_cont) 112 check.run_blocking (check_timeout, success_connect_cont, fail_connect_cont)
@@ -108,48 +115,82 @@ def check_connect ():
108# Test execution 115# Test execution
109# 116#
110 117
118def SigHandler(signum = None, frame = None):
119 global success
120 global server
121 global client
122
123 print 'Test was aborted!'
124 if (None != server):
125 server.stop ()
126 if (None != server):
127 client.stop ()
128 cleanup ()
129 sys.exit(success)
130
111def run (): 131def run ():
112 global success 132 global success
113 global test 133 global test
114 global server 134 global server
115 global client 135 global client
116 136
117 success = False 137 server = None
138 client = None
139 success = False
118 140
119 test = Test ('test_integration_disconnect', verbose) 141 for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]:
142 signal.signal(sig, SigHandler)
143
144 test = Test ('test_integration_bootstrap_and_connect.py', verbose)
145 cleanup ()
120 146
121 server = Peer(test, './confs/c_bootstrap_server.conf'); 147 server = Peer(test, './confs/c_bootstrap_server.conf');
122 server.start();
123
124 client = Peer(test, './confs/c_no_nat_client.conf'); 148 client = Peer(test, './confs/c_no_nat_client.conf');
125 client.start();
126 149
150 if (True != server.start()):
151 print 'Failed to start server'
152 if (None != server):
153 server.stop ()
154 if (None != server):
155 client.stop ()
156 cleanup ()
157 sys.exit(success)
158 if (True != client.start()):
159 print 'Failed to start client'
160 if (None != server):
161 server.stop ()
162 if (None != server):
163 client.stop ()
164 cleanup ()
165 sys.exit(success)
127 166
128 if ((client.started == True) and (server.started == True)): 167 if ((client.started == True) and (server.started == True)):
129 test.p ('Peers started, running check') 168 test.p ('Peers started, running check')
130 check_connect () 169 time.sleep(5)
131 170 check_connect ()
132 server.stop () 171 server.stop ()
133 client.stop () 172 client.stop ()
134 173
135 cleanup () 174 cleanup ()
136 175
137 if (success == False): 176 if (success == False):
138 print ('Test failed') 177 print ('Test failed')
139 return True 178 return False
140 else: 179 else:
141 return False 180 return True
142 181
143
144try: 182try:
145 run () 183 run ()
146except (KeyboardInterrupt, SystemExit): 184except (KeyboardInterrupt, SystemExit):
147 print 'Test interrupted' 185 print 'Test interrupted'
148 server.stop () 186 server.stop ()
149 client.stop () 187 client.stop ()
150 cleanup () 188 cleanup ()
151if (success == False): 189if (success == False):
152 sys.exit(1) 190 sys.exit(1)
153else: 191else:
154 sys.exit(0) 192 sys.exit(0)
193
194
195
155 \ No newline at end of file 196 \ No newline at end of file