aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-12-16 12:25:28 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-12-16 12:25:28 +0000
commit4997b98b69d53d14085f0da4d7d4b002f3d59100 (patch)
tree95dc9c487b9a23124f7aae48409d18fa6c20b574 /src
parent17f94e7fc0dfabbbd9868b72f957209549a16b5a (diff)
downloadgnunet-4997b98b69d53d14085f0da4d7d4b002f3d59100.tar.gz
gnunet-4997b98b69d53d14085f0da4d7d4b002f3d59100.zip
added support for interupting a test
Diffstat (limited to 'src')
-rw-r--r--src/integration-tests/gnunet_testing.py.in10
-rwxr-xr-xsrc/integration-tests/test_integration_bootstrap_and_connect.py.in78
-rwxr-xr-xsrc/integration-tests/test_integration_clique.py.in71
-rwxr-xr-xsrc/integration-tests/test_integration_disconnect.py.in65
4 files changed, 146 insertions, 78 deletions
diff --git a/src/integration-tests/gnunet_testing.py.in b/src/integration-tests/gnunet_testing.py.in
index 3fb6221fd..4b667a270 100644
--- a/src/integration-tests/gnunet_testing.py.in
+++ b/src/integration-tests/gnunet_testing.py.in
@@ -134,6 +134,7 @@ class StatisticsCondition (Condition):
134 134
135class Test: 135class Test:
136 def __init__(self, testname, verbose): 136 def __init__(self, testname, verbose):
137 self.peers = list()
137 self.verbose = verbose; 138 self.verbose = verbose;
138 self.name = testname; 139 self.name = testname;
139 srcdir = "../.." 140 srcdir = "../.."
@@ -153,6 +154,8 @@ class Test:
153 shutil.rmtree (os.path.join (os.getenv ("TEMP"), testname), True) 154 shutil.rmtree (os.path.join (os.getenv ("TEMP"), testname), True)
154 else: 155 else:
155 shutil.rmtree ("/tmp/" + testname, True) 156 shutil.rmtree ("/tmp/" + testname, True)
157 def add_peer (peer):
158 self.conditions.append(condition)
156 def p (self, msg): 159 def p (self, msg):
157 if (self.verbose == True): 160 if (self.verbose == True):
158 print msg 161 print msg
@@ -167,9 +170,12 @@ class Peer:
167 def __del__(self): 170 def __del__(self):
168 if (self.started == True): 171 if (self.started == True):
169 print 'ERROR! Peer using cfg ' + self.cfg + ' was not stopped' 172 print 'ERROR! Peer using cfg ' + self.cfg + ' was not stopped'
170 self.started == False 173 if (ret == self.stop ()):
171 if (False == self.stop ()):
172 print 'ERROR! Peer using cfg ' + self.cfg + ' could not be stopped' 174 print 'ERROR! Peer using cfg ' + self.cfg + ' could not be stopped'
175 self.started == False
176 return ret
177 else:
178 return False
173 def start (self): 179 def start (self):
174 self.test.p ("Starting peer using cfg " + self.cfg) 180 self.test.p ("Starting peer using cfg " + self.cfg)
175 try: 181 try:
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 581179f99..a8aff73d7 100755
--- a/src/integration-tests/test_integration_bootstrap_and_connect.py.in
+++ b/src/integration-tests/test_integration_bootstrap_and_connect.py.in
@@ -39,11 +39,18 @@ from gnunet_testing import *
39# Conditions for successful exit: 39# Conditions for successful exit:
40# Both peers have 1 connected peer in transport, core, topology, fs 40# Both peers have 1 connected peer in transport, core, topology, fs
41 41
42#
43# This test tests if a fresh peer bootstraps from a hostlist server and then
44# successfully connects to the server
45#
46# Conditions for successful exit:
47# Both peers have 1 connected peer in transport, core, topology, fs
48
42#definitions 49#definitions
43 50
44testname = "test_integration_bootstrap_and_connect" 51testname = "test_integration_bootstrap_and_connect"
45verbose = False 52verbose = True
46timeout = 100 53check_timeout = 30
47 54
48 55
49def cleanup (): 56def cleanup ():
@@ -64,7 +71,10 @@ def fail_cont (check):
64 check.eval(True) 71 check.eval(True)
65 72
66def check (): 73def check ():
67 74 global test
75 global server
76 global client
77 global success
68 check = Check (test) 78 check = Check (test)
69 check.add (StatisticsCondition (client, 'transport', '# peers connected',1)) 79 check.add (StatisticsCondition (client, 'transport', '# peers connected',1))
70 check.add (StatisticsCondition (client, 'core', '# neighbour entries allocated',1)) 80 check.add (StatisticsCondition (client, 'core', '# neighbour entries allocated',1))
@@ -79,32 +89,50 @@ def check ():
79 check.add (StatisticsCondition (server, 'topology', '# peers connected',1)) 89 check.add (StatisticsCondition (server, 'topology', '# peers connected',1))
80 check.add (StatisticsCondition (server, 'fs', '# peers connected',1)) 90 check.add (StatisticsCondition (server, 'fs', '# peers connected',1))
81 91
82 check.run_blocking (10, success_cont, fail_cont) 92 check.run_blocking (check_timeout, success_cont, fail_cont)
83 93
84# 94#
85# Test execution 95# Test execution
86# 96#
87success = False
88
89test = Test ('test_integration_bootstrap_and_connect.py', verbose)
90 97
91server = Peer(test, './confs/c_bootstrap_server.conf'); 98def run ():
92server.start(); 99 global test
93 100 global server
94client = Peer(test, './confs/c_no_nat_client.conf'); 101 global client
95client.start(); 102 global success
96 103
97if ((client.started == True) and (server.started == True)): 104 success = False
98 test.p ('Peers started, running check') 105 test = Test ('test_integration_bootstrap_and_connect.py', verbose)
99 check () 106
100 107 server = Peer(test, './confs/c_bootstrap_server.conf');
101server.stop () 108 client = Peer(test, './confs/c_no_nat_client.conf');
102client.stop ()
103 109
104cleanup () 110 server.start();
111 client.start();
112
113 if ((client.started == True) and (server.started == True)):
114 test.p ('Peers started, running check')
115 time.sleep(5)
116 check ()
117
118 print 'stop in run'
119 server.stop ()
120 client.stop ()
121
122 cleanup ()
123
124 if (success == False):
125 print ('Test failed')
126 return False
127 else:
128 return True
105 129
106if (success == False): 130try:
107 print ('Test failed') 131 run ()
108 exit (1) 132except (KeyboardInterrupt, SystemExit):
109else: 133 print 'Test interrupted'
110 exit (0) 134 server.stop ()
135 client.stop ()
136 cleanup ()
137sys.exit(success)
138 \ No newline at end of file
diff --git a/src/integration-tests/test_integration_clique.py.in b/src/integration-tests/test_integration_clique.py.in
index ce254ca7b..2c9a569f1 100755
--- a/src/integration-tests/test_integration_clique.py.in
+++ b/src/integration-tests/test_integration_clique.py.in
@@ -144,33 +144,50 @@ def check_connect ():
144# 144#
145# Test execution 145# Test execution
146# 146#
147 147def run ():
148success = False 148 global test
149 149 global server
150test = Test ('test_integration_disconnect', verbose) 150 global client
151 151 global success
152server = Peer(test, './confs/c_bootstrap_server.conf');
153server.start();
154
155client = Peer(test, './confs/c_no_nat_client.conf');
156client.start();
157
158client2 = Peer(test, './confs/c_no_nat_client_2.conf');
159client2.start();
160
161if ((client.started == True) and (client2.started == True) and (server.started == True)):
162 test.p ('Peers started, running check')
163 check_connect ()
164 152
165server.stop () 153 success = False
166client.stop () 154
167client2.stop () 155 test = Test ('test_integration_disconnect', verbose)
156
157 server = Peer(test, './confs/c_bootstrap_server.conf');
158 server.start();
159
160 client = Peer(test, './confs/c_no_nat_client.conf');
161 client.start();
162
163 client2 = Peer(test, './confs/c_no_nat_client_2.conf');
164 client2.start();
165
166 if ((client.started == True) and (client2.started == True) and (server.started == True)):
167 test.p ('Peers started, running check')
168 check_connect ()
169
170 server.stop ()
171 client.stop ()
172 client2.stop ()
173
174 cleanup ()
175
176 if (success == False):
177 print ('Test failed')
178 return False
179 else:
180 return True
168 181
169cleanup () 182
170 183try:
171if (success == False): 184 run ()
172 print ('Test failed') 185except (KeyboardInterrupt, SystemExit):
173 exit (1) 186 print 'Test interrupted'
174else: 187 server.stop ()
175 exit (0) 188 client.stop ()
189 client2.stop ()
190 cleanup ()
191sys.exit(success)
192
176 193
diff --git a/src/integration-tests/test_integration_disconnect.py.in b/src/integration-tests/test_integration_disconnect.py.in
index 0397fafd2..f708aee1d 100755
--- a/src/integration-tests/test_integration_disconnect.py.in
+++ b/src/integration-tests/test_integration_disconnect.py.in
@@ -43,7 +43,7 @@ from gnunet_testing import *
43#definitions 43#definitions
44 44
45testname = "test_integration_disconnect" 45testname = "test_integration_disconnect"
46verbose = False 46verbose = True
47check_timeout = 30 47check_timeout = 30
48 48
49 49
@@ -112,28 +112,45 @@ def check_connect ():
112# 112#
113# Test execution 113# Test execution
114# 114#
115success = False 115def run ():
116 116 global test
117test = Test ('test_integration_disconnect', verbose) 117 global server
118 118 global client
119server = Peer(test, './confs/c_bootstrap_server.conf'); 119 global success
120server.start();
121
122client = Peer(test, './confs/c_no_nat_client.conf');
123client.start();
124
125
126if ((client.started == True) and (server.started == True)):
127 test.p ('Peers started, running check')
128 check_connect ()
129 120
130server.stop () 121 success = False
131client.stop () 122
132 123 test = Test ('test_integration_disconnect', verbose)
133cleanup () 124
125 server = Peer(test, './confs/c_bootstrap_server.conf');
126 server.start();
127
128 client = Peer(test, './confs/c_no_nat_client.conf');
129 client.start();
130
131
132 if ((client.started == True) and (server.started == True)):
133 test.p ('Peers started, running check')
134 check_connect ()
135
136 server.stop ()
137 client.stop ()
138
139 cleanup ()
140
141 if (success == False):
142 print ('Test failed')
143 return True
144 else:
145 return False
134 146
135if (success == False): 147
136 print ('Test failed') 148try:
137 exit (1) 149 run ()
138else: 150except (KeyboardInterrupt, SystemExit):
139 exit (0) 151 print 'Test interrupted'
152 server.stop ()
153 client.stop ()
154 cleanup ()
155sys.exit(success)
156 \ No newline at end of file