diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-12-16 12:25:28 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-12-16 12:25:28 +0000 |
commit | 4997b98b69d53d14085f0da4d7d4b002f3d59100 (patch) | |
tree | 95dc9c487b9a23124f7aae48409d18fa6c20b574 /src/integration-tests | |
parent | 17f94e7fc0dfabbbd9868b72f957209549a16b5a (diff) | |
download | gnunet-4997b98b69d53d14085f0da4d7d4b002f3d59100.tar.gz gnunet-4997b98b69d53d14085f0da4d7d4b002f3d59100.zip |
added support for interupting a test
Diffstat (limited to 'src/integration-tests')
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 | ||
135 | class Test: | 135 | class 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 | ||
44 | testname = "test_integration_bootstrap_and_connect" | 51 | testname = "test_integration_bootstrap_and_connect" |
45 | verbose = False | 52 | verbose = True |
46 | timeout = 100 | 53 | check_timeout = 30 |
47 | 54 | ||
48 | 55 | ||
49 | def cleanup (): | 56 | def cleanup (): |
@@ -64,7 +71,10 @@ def fail_cont (check): | |||
64 | check.eval(True) | 71 | check.eval(True) |
65 | 72 | ||
66 | def check (): | 73 | def 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 | # |
87 | success = False | ||
88 | |||
89 | test = Test ('test_integration_bootstrap_and_connect.py', verbose) | ||
90 | 97 | ||
91 | server = Peer(test, './confs/c_bootstrap_server.conf'); | 98 | def run (): |
92 | server.start(); | 99 | global test |
93 | 100 | global server | |
94 | client = Peer(test, './confs/c_no_nat_client.conf'); | 101 | global client |
95 | client.start(); | 102 | global success |
96 | 103 | ||
97 | if ((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'); | |
101 | server.stop () | 108 | client = Peer(test, './confs/c_no_nat_client.conf'); |
102 | client.stop () | ||
103 | 109 | ||
104 | cleanup () | 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 | ||
106 | if (success == False): | 130 | try: |
107 | print ('Test failed') | 131 | run () |
108 | exit (1) | 132 | except (KeyboardInterrupt, SystemExit): |
109 | else: | 133 | print 'Test interrupted' |
110 | exit (0) | 134 | server.stop () |
135 | client.stop () | ||
136 | cleanup () | ||
137 | sys.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 | 147 | def run (): | |
148 | success = False | 148 | global test |
149 | 149 | global server | |
150 | test = Test ('test_integration_disconnect', verbose) | 150 | global client |
151 | 151 | global success | |
152 | server = Peer(test, './confs/c_bootstrap_server.conf'); | ||
153 | server.start(); | ||
154 | |||
155 | client = Peer(test, './confs/c_no_nat_client.conf'); | ||
156 | client.start(); | ||
157 | |||
158 | client2 = Peer(test, './confs/c_no_nat_client_2.conf'); | ||
159 | client2.start(); | ||
160 | |||
161 | if ((client.started == True) and (client2.started == True) and (server.started == True)): | ||
162 | test.p ('Peers started, running check') | ||
163 | check_connect () | ||
164 | 152 | ||
165 | server.stop () | 153 | success = False |
166 | client.stop () | 154 | |
167 | client2.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 | ||
169 | cleanup () | 182 | |
170 | 183 | try: | |
171 | if (success == False): | 184 | run () |
172 | print ('Test failed') | 185 | except (KeyboardInterrupt, SystemExit): |
173 | exit (1) | 186 | print 'Test interrupted' |
174 | else: | 187 | server.stop () |
175 | exit (0) | 188 | client.stop () |
189 | client2.stop () | ||
190 | cleanup () | ||
191 | sys.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 | ||
45 | testname = "test_integration_disconnect" | 45 | testname = "test_integration_disconnect" |
46 | verbose = False | 46 | verbose = True |
47 | check_timeout = 30 | 47 | check_timeout = 30 |
48 | 48 | ||
49 | 49 | ||
@@ -112,28 +112,45 @@ def check_connect (): | |||
112 | # | 112 | # |
113 | # Test execution | 113 | # Test execution |
114 | # | 114 | # |
115 | success = False | 115 | def run (): |
116 | 116 | global test | |
117 | test = Test ('test_integration_disconnect', verbose) | 117 | global server |
118 | 118 | global client | |
119 | server = Peer(test, './confs/c_bootstrap_server.conf'); | 119 | global success |
120 | server.start(); | ||
121 | |||
122 | client = Peer(test, './confs/c_no_nat_client.conf'); | ||
123 | client.start(); | ||
124 | |||
125 | |||
126 | if ((client.started == True) and (server.started == True)): | ||
127 | test.p ('Peers started, running check') | ||
128 | check_connect () | ||
129 | 120 | ||
130 | server.stop () | 121 | success = False |
131 | client.stop () | 122 | |
132 | 123 | test = Test ('test_integration_disconnect', verbose) | |
133 | cleanup () | 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 | ||
135 | if (success == False): | 147 | |
136 | print ('Test failed') | 148 | try: |
137 | exit (1) | 149 | run () |
138 | else: | 150 | except (KeyboardInterrupt, SystemExit): |
139 | exit (0) | 151 | print 'Test interrupted' |
152 | server.stop () | ||
153 | client.stop () | ||
154 | cleanup () | ||
155 | sys.exit(success) | ||
156 | \ No newline at end of file | ||