Merge lp:~anso/nova/smoketests_fixes into lp:~hudson-openstack/nova/trunk
- smoketests_fixes
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 835 |
Proposed branch: | lp:~anso/nova/smoketests_fixes |
Merge into: | lp:~hudson-openstack/nova/trunk |
Diff against target: |
584 lines (+334/-79) 8 files modified
nova/tests/api/openstack/test_servers.py (+0/-3) run_tests.py (+2/-0) smoketests/base.py (+16/-35) smoketests/public_network_smoketests.py (+0/-6) smoketests/run_tests.py (+297/-0) smoketests/test_admin.py (+0/-7) smoketests/test_netadmin.py (+3/-14) smoketests/test_sysadmin.py (+16/-14) |
To merge this branch: | bzr merge lp:~anso/nova/smoketests_fixes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Soren Hansen (community) | Needs Information | ||
Paul Voccio (community) | Needs Fixing | ||
Jay Pipes (community) | Approve | ||
Review via email: mp+51057@code.launchpad.net |
Commit message
Description of the change
One last fix to remove extra flag from admin_smoketests.
- 531. By Vish Ishaya
-
more smoketest fixes
- 532. By Vish Ishaya
-
fix check for existing port 22 rule
- 533. By Vish Ishaya
-
merged trunk
- 534. By Vish Ishaya
-
merge clean db
- 535. By Vish Ishaya
-
make smoketests run with nose
- 536. By Vish Ishaya
-
add customizable tempdir and remove extra code
- 537. By Vish Ishaya
-
removed unused references to unittest
- 538. By Vish Ishaya
-
revert a few unnecessary changes to base.py
- 539. By Vish Ishaya
-
add timeout and retry for ssh
Soren Hansen (soren) wrote : | # |
This needs a merge with trunk..
- 540. By Vish Ishaya
-
merged trunk
Paul Voccio (pvo) wrote : | # |
I got a merge conflict again...
Soren Hansen (soren) wrote : | # |
I don't see how I'm supposed to pass flags to the tests anymore? I used to be able to just pass --test_
Soren Hansen (soren) wrote : | # |
> I don't see how I'm supposed to pass flags to the tests anymore? I used to be
> able to just pass --test_
> nose.
Ok, fixed in lp:~soren/nova/improve-smoketests which also includes this branch.
Preview Diff
1 | === modified file 'nova/tests/api/openstack/test_servers.py' | |||
2 | --- nova/tests/api/openstack/test_servers.py 2011-03-02 17:39:30 +0000 | |||
3 | +++ nova/tests/api/openstack/test_servers.py 2011-03-08 20:42:48 +0000 | |||
4 | @@ -562,6 +562,3 @@ | |||
5 | 562 | 562 | ||
6 | 563 | res = req.get_response(fakes.wsgi_app()) | 563 | res = req.get_response(fakes.wsgi_app()) |
7 | 564 | self.assertEqual(res.status_int, 400) | 564 | self.assertEqual(res.status_int, 400) |
8 | 565 | |||
9 | 566 | if __name__ == "__main__": | ||
10 | 567 | unittest.main() | ||
11 | 568 | 565 | ||
12 | === modified file 'run_tests.py' | |||
13 | --- run_tests.py 2011-02-25 01:04:25 +0000 | |||
14 | +++ run_tests.py 2011-03-08 20:42:48 +0000 | |||
15 | @@ -60,6 +60,8 @@ | |||
16 | 60 | import unittest | 60 | import unittest |
17 | 61 | import sys | 61 | import sys |
18 | 62 | 62 | ||
19 | 63 | gettext.install('nova', unicode=1) | ||
20 | 64 | |||
21 | 63 | from nose import config | 65 | from nose import config |
22 | 64 | from nose import core | 66 | from nose import core |
23 | 65 | from nose import result | 67 | from nose import result |
24 | 66 | 68 | ||
25 | === modified file 'smoketests/base.py' | |||
26 | --- smoketests/base.py 2011-02-23 02:04:08 +0000 | |||
27 | +++ smoketests/base.py 2011-03-08 20:42:48 +0000 | |||
28 | @@ -31,17 +31,24 @@ | |||
29 | 31 | SUITE_NAMES = '[image, instance, volume]' | 31 | SUITE_NAMES = '[image, instance, volume]' |
30 | 32 | FLAGS = flags.FLAGS | 32 | FLAGS = flags.FLAGS |
31 | 33 | flags.DEFINE_string('suite', None, 'Specific test suite to run ' + SUITE_NAMES) | 33 | flags.DEFINE_string('suite', None, 'Specific test suite to run ' + SUITE_NAMES) |
32 | 34 | flags.DEFINE_integer('ssh_tries', 3, 'Numer of times to try ssh') | ||
33 | 34 | boto_v6 = None | 35 | boto_v6 = None |
34 | 35 | 36 | ||
35 | 36 | 37 | ||
36 | 37 | class SmokeTestCase(unittest.TestCase): | 38 | class SmokeTestCase(unittest.TestCase): |
37 | 38 | def connect_ssh(self, ip, key_name): | 39 | def connect_ssh(self, ip, key_name): |
38 | 39 | # TODO(devcamcar): set a more reasonable connection timeout time | ||
39 | 40 | key = paramiko.RSAKey.from_private_key_file('/tmp/%s.pem' % key_name) | 40 | key = paramiko.RSAKey.from_private_key_file('/tmp/%s.pem' % key_name) |
44 | 41 | client = paramiko.SSHClient() | 41 | tries = 0 |
45 | 42 | client.set_missing_host_key_policy(paramiko.WarningPolicy()) | 42 | while(True): |
46 | 43 | client.connect(ip, username='root', pkey=key) | 43 | try: |
47 | 44 | return client | 44 | client = paramiko.SSHClient() |
48 | 45 | client.set_missing_host_key_policy(paramiko.WarningPolicy()) | ||
49 | 46 | client.connect(ip, username='root', pkey=key, timeout=5) | ||
50 | 47 | return client | ||
51 | 48 | except (paramiko.AuthenticationException, paramiko.SSHException): | ||
52 | 49 | tries += 1 | ||
53 | 50 | if tries == FLAGS.ssh_tries: | ||
54 | 51 | raise | ||
55 | 45 | 52 | ||
56 | 46 | def can_ping(self, ip, command="ping"): | 53 | def can_ping(self, ip, command="ping"): |
57 | 47 | """Attempt to ping the specified IP, and give up after 1 second.""" | 54 | """Attempt to ping the specified IP, and give up after 1 second.""" |
58 | @@ -147,8 +154,8 @@ | |||
59 | 147 | except: | 154 | except: |
60 | 148 | pass | 155 | pass |
61 | 149 | 156 | ||
64 | 150 | def bundle_image(self, image, kernel=False): | 157 | def bundle_image(self, image, tempdir='/tmp', kernel=False): |
65 | 151 | cmd = 'euca-bundle-image -i %s' % image | 158 | cmd = 'euca-bundle-image -i %s -d %s' % (image, tempdir) |
66 | 152 | if kernel: | 159 | if kernel: |
67 | 153 | cmd += ' --kernel true' | 160 | cmd += ' --kernel true' |
68 | 154 | status, output = commands.getstatusoutput(cmd) | 161 | status, output = commands.getstatusoutput(cmd) |
69 | @@ -157,9 +164,9 @@ | |||
70 | 157 | raise Exception(output) | 164 | raise Exception(output) |
71 | 158 | return True | 165 | return True |
72 | 159 | 166 | ||
74 | 160 | def upload_image(self, bucket_name, image): | 167 | def upload_image(self, bucket_name, image, tempdir='/tmp'): |
75 | 161 | cmd = 'euca-upload-bundle -b ' | 168 | cmd = 'euca-upload-bundle -b ' |
77 | 162 | cmd += '%s -m /tmp/%s.manifest.xml' % (bucket_name, image) | 169 | cmd += '%s -m %s/%s.manifest.xml' % (bucket_name, tempdir, image) |
78 | 163 | status, output = commands.getstatusoutput(cmd) | 170 | status, output = commands.getstatusoutput(cmd) |
79 | 164 | if status != 0: | 171 | if status != 0: |
80 | 165 | print '%s -> \n %s' % (cmd, output) | 172 | print '%s -> \n %s' % (cmd, output) |
81 | @@ -183,29 +190,3 @@ | |||
82 | 183 | global TEST_DATA | 190 | global TEST_DATA |
83 | 184 | self.conn = self.connection_for_env() | 191 | self.conn = self.connection_for_env() |
84 | 185 | self.data = TEST_DATA | 192 | self.data = TEST_DATA |
85 | 186 | |||
86 | 187 | |||
87 | 188 | def run_tests(suites): | ||
88 | 189 | argv = FLAGS(sys.argv) | ||
89 | 190 | if FLAGS.use_ipv6: | ||
90 | 191 | global boto_v6 | ||
91 | 192 | boto_v6 = __import__('boto_v6') | ||
92 | 193 | |||
93 | 194 | if not os.getenv('EC2_ACCESS_KEY'): | ||
94 | 195 | print >> sys.stderr, 'Missing EC2 environment variables. Please ' \ | ||
95 | 196 | 'source the appropriate novarc file before ' \ | ||
96 | 197 | 'running this test.' | ||
97 | 198 | return 1 | ||
98 | 199 | |||
99 | 200 | if FLAGS.suite: | ||
100 | 201 | try: | ||
101 | 202 | suite = suites[FLAGS.suite] | ||
102 | 203 | except KeyError: | ||
103 | 204 | print >> sys.stderr, 'Available test suites:', \ | ||
104 | 205 | ', '.join(suites.keys()) | ||
105 | 206 | return 1 | ||
106 | 207 | |||
107 | 208 | unittest.TextTestRunner(verbosity=2).run(suite) | ||
108 | 209 | else: | ||
109 | 210 | for suite in suites.itervalues(): | ||
110 | 211 | unittest.TextTestRunner(verbosity=2).run(suite) | ||
111 | 212 | 193 | ||
112 | === modified file 'smoketests/public_network_smoketests.py' | |||
113 | --- smoketests/public_network_smoketests.py 2011-02-23 02:04:08 +0000 | |||
114 | +++ smoketests/public_network_smoketests.py 2011-03-08 20:42:48 +0000 | |||
115 | @@ -19,10 +19,8 @@ | |||
116 | 19 | import commands | 19 | import commands |
117 | 20 | import os | 20 | import os |
118 | 21 | import random | 21 | import random |
119 | 22 | import socket | ||
120 | 23 | import sys | 22 | import sys |
121 | 24 | import time | 23 | import time |
122 | 25 | import unittest | ||
123 | 26 | 24 | ||
124 | 27 | # If ../nova/__init__.py exists, add ../ to Python search path, so that | 25 | # If ../nova/__init__.py exists, add ../ to Python search path, so that |
125 | 28 | # it will override what happens to be installed in /usr/(local/)lib/python... | 26 | # it will override what happens to be installed in /usr/(local/)lib/python... |
126 | @@ -181,7 +179,3 @@ | |||
127 | 181 | self.conn.delete_security_group(security_group_name) | 179 | self.conn.delete_security_group(security_group_name) |
128 | 182 | if 'instance_id' in self.data: | 180 | if 'instance_id' in self.data: |
129 | 183 | self.conn.terminate_instances([self.data['instance_id']]) | 181 | self.conn.terminate_instances([self.data['instance_id']]) |
130 | 184 | |||
131 | 185 | if __name__ == "__main__": | ||
132 | 186 | suites = {'instance': unittest.makeSuite(InstanceTestsFromPublic)} | ||
133 | 187 | sys.exit(base.run_tests(suites)) | ||
134 | 188 | 182 | ||
135 | === added file 'smoketests/run_tests.py' | |||
136 | --- smoketests/run_tests.py 1970-01-01 00:00:00 +0000 | |||
137 | +++ smoketests/run_tests.py 2011-03-08 20:42:48 +0000 | |||
138 | @@ -0,0 +1,297 @@ | |||
139 | 1 | #!/usr/bin/env python | ||
140 | 2 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 | ||
141 | 3 | |||
142 | 4 | # Copyright 2010 United States Government as represented by the | ||
143 | 5 | # Administrator of the National Aeronautics and Space Administration. | ||
144 | 6 | # All Rights Reserved. | ||
145 | 7 | # | ||
146 | 8 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
147 | 9 | # you may not use this file except in compliance with the License. | ||
148 | 10 | # You may obtain a copy of the License at | ||
149 | 11 | # | ||
150 | 12 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
151 | 13 | # | ||
152 | 14 | # Unless required by applicable law or agreed to in writing, software | ||
153 | 15 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
154 | 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
155 | 17 | # See the License for the specific language governing permissions and | ||
156 | 18 | # limitations under the License. | ||
157 | 19 | |||
158 | 20 | # Colorizer Code is borrowed from Twisted: | ||
159 | 21 | # Copyright (c) 2001-2010 Twisted Matrix Laboratories. | ||
160 | 22 | # | ||
161 | 23 | # Permission is hereby granted, free of charge, to any person obtaining | ||
162 | 24 | # a copy of this software and associated documentation files (the | ||
163 | 25 | # "Software"), to deal in the Software without restriction, including | ||
164 | 26 | # without limitation the rights to use, copy, modify, merge, publish, | ||
165 | 27 | # distribute, sublicense, and/or sell copies of the Software, and to | ||
166 | 28 | # permit persons to whom the Software is furnished to do so, subject to | ||
167 | 29 | # the following conditions: | ||
168 | 30 | # | ||
169 | 31 | # The above copyright notice and this permission notice shall be | ||
170 | 32 | # included in all copies or substantial portions of the Software. | ||
171 | 33 | # | ||
172 | 34 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
173 | 35 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
174 | 36 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
175 | 37 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
176 | 38 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
177 | 39 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
178 | 40 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
179 | 41 | """Unittest runner for Nova. | ||
180 | 42 | |||
181 | 43 | To run all tests | ||
182 | 44 | python run_tests.py | ||
183 | 45 | |||
184 | 46 | To run a single test: | ||
185 | 47 | python run_tests.py test_compute:ComputeTestCase.test_run_terminate | ||
186 | 48 | |||
187 | 49 | To run a single test module: | ||
188 | 50 | python run_tests.py test_compute | ||
189 | 51 | |||
190 | 52 | or | ||
191 | 53 | |||
192 | 54 | python run_tests.py api.test_wsgi | ||
193 | 55 | |||
194 | 56 | """ | ||
195 | 57 | |||
196 | 58 | import gettext | ||
197 | 59 | import os | ||
198 | 60 | import unittest | ||
199 | 61 | import sys | ||
200 | 62 | |||
201 | 63 | gettext.install('nova', unicode=1) | ||
202 | 64 | |||
203 | 65 | from nose import config | ||
204 | 66 | from nose import core | ||
205 | 67 | from nose import result | ||
206 | 68 | |||
207 | 69 | |||
208 | 70 | class _AnsiColorizer(object): | ||
209 | 71 | """ | ||
210 | 72 | A colorizer is an object that loosely wraps around a stream, allowing | ||
211 | 73 | callers to write text to the stream in a particular color. | ||
212 | 74 | |||
213 | 75 | Colorizer classes must implement C{supported()} and C{write(text, color)}. | ||
214 | 76 | """ | ||
215 | 77 | _colors = dict(black=30, red=31, green=32, yellow=33, | ||
216 | 78 | blue=34, magenta=35, cyan=36, white=37) | ||
217 | 79 | |||
218 | 80 | def __init__(self, stream): | ||
219 | 81 | self.stream = stream | ||
220 | 82 | |||
221 | 83 | def supported(cls, stream=sys.stdout): | ||
222 | 84 | """ | ||
223 | 85 | A class method that returns True if the current platform supports | ||
224 | 86 | coloring terminal output using this method. Returns False otherwise. | ||
225 | 87 | """ | ||
226 | 88 | if not stream.isatty(): | ||
227 | 89 | return False # auto color only on TTYs | ||
228 | 90 | try: | ||
229 | 91 | import curses | ||
230 | 92 | except ImportError: | ||
231 | 93 | return False | ||
232 | 94 | else: | ||
233 | 95 | try: | ||
234 | 96 | try: | ||
235 | 97 | return curses.tigetnum("colors") > 2 | ||
236 | 98 | except curses.error: | ||
237 | 99 | curses.setupterm() | ||
238 | 100 | return curses.tigetnum("colors") > 2 | ||
239 | 101 | except: | ||
240 | 102 | raise | ||
241 | 103 | # guess false in case of error | ||
242 | 104 | return False | ||
243 | 105 | supported = classmethod(supported) | ||
244 | 106 | |||
245 | 107 | def write(self, text, color): | ||
246 | 108 | """ | ||
247 | 109 | Write the given text to the stream in the given color. | ||
248 | 110 | |||
249 | 111 | @param text: Text to be written to the stream. | ||
250 | 112 | |||
251 | 113 | @param color: A string label for a color. e.g. 'red', 'white'. | ||
252 | 114 | """ | ||
253 | 115 | color = self._colors[color] | ||
254 | 116 | self.stream.write('\x1b[%s;1m%s\x1b[0m' % (color, text)) | ||
255 | 117 | |||
256 | 118 | |||
257 | 119 | class _Win32Colorizer(object): | ||
258 | 120 | """ | ||
259 | 121 | See _AnsiColorizer docstring. | ||
260 | 122 | """ | ||
261 | 123 | def __init__(self, stream): | ||
262 | 124 | from win32console import GetStdHandle, STD_OUT_HANDLE, \ | ||
263 | 125 | FOREGROUND_RED, FOREGROUND_BLUE, FOREGROUND_GREEN, \ | ||
264 | 126 | FOREGROUND_INTENSITY | ||
265 | 127 | red, green, blue, bold = (FOREGROUND_RED, FOREGROUND_GREEN, | ||
266 | 128 | FOREGROUND_BLUE, FOREGROUND_INTENSITY) | ||
267 | 129 | self.stream = stream | ||
268 | 130 | self.screenBuffer = GetStdHandle(STD_OUT_HANDLE) | ||
269 | 131 | self._colors = { | ||
270 | 132 | 'normal': red | green | blue, | ||
271 | 133 | 'red': red | bold, | ||
272 | 134 | 'green': green | bold, | ||
273 | 135 | 'blue': blue | bold, | ||
274 | 136 | 'yellow': red | green | bold, | ||
275 | 137 | 'magenta': red | blue | bold, | ||
276 | 138 | 'cyan': green | blue | bold, | ||
277 | 139 | 'white': red | green | blue | bold | ||
278 | 140 | } | ||
279 | 141 | |||
280 | 142 | def supported(cls, stream=sys.stdout): | ||
281 | 143 | try: | ||
282 | 144 | import win32console | ||
283 | 145 | screenBuffer = win32console.GetStdHandle( | ||
284 | 146 | win32console.STD_OUT_HANDLE) | ||
285 | 147 | except ImportError: | ||
286 | 148 | return False | ||
287 | 149 | import pywintypes | ||
288 | 150 | try: | ||
289 | 151 | screenBuffer.SetConsoleTextAttribute( | ||
290 | 152 | win32console.FOREGROUND_RED | | ||
291 | 153 | win32console.FOREGROUND_GREEN | | ||
292 | 154 | win32console.FOREGROUND_BLUE) | ||
293 | 155 | except pywintypes.error: | ||
294 | 156 | return False | ||
295 | 157 | else: | ||
296 | 158 | return True | ||
297 | 159 | supported = classmethod(supported) | ||
298 | 160 | |||
299 | 161 | def write(self, text, color): | ||
300 | 162 | color = self._colors[color] | ||
301 | 163 | self.screenBuffer.SetConsoleTextAttribute(color) | ||
302 | 164 | self.stream.write(text) | ||
303 | 165 | self.screenBuffer.SetConsoleTextAttribute(self._colors['normal']) | ||
304 | 166 | |||
305 | 167 | |||
306 | 168 | class _NullColorizer(object): | ||
307 | 169 | """ | ||
308 | 170 | See _AnsiColorizer docstring. | ||
309 | 171 | """ | ||
310 | 172 | def __init__(self, stream): | ||
311 | 173 | self.stream = stream | ||
312 | 174 | |||
313 | 175 | def supported(cls, stream=sys.stdout): | ||
314 | 176 | return True | ||
315 | 177 | supported = classmethod(supported) | ||
316 | 178 | |||
317 | 179 | def write(self, text, color): | ||
318 | 180 | self.stream.write(text) | ||
319 | 181 | |||
320 | 182 | |||
321 | 183 | class NovaTestResult(result.TextTestResult): | ||
322 | 184 | def __init__(self, *args, **kw): | ||
323 | 185 | result.TextTestResult.__init__(self, *args, **kw) | ||
324 | 186 | self._last_case = None | ||
325 | 187 | self.colorizer = None | ||
326 | 188 | # NOTE(vish): reset stdout for the terminal check | ||
327 | 189 | stdout = sys.stdout | ||
328 | 190 | sys.stdout = sys.__stdout__ | ||
329 | 191 | for colorizer in [_Win32Colorizer, _AnsiColorizer, _NullColorizer]: | ||
330 | 192 | if colorizer.supported(): | ||
331 | 193 | self.colorizer = colorizer(self.stream) | ||
332 | 194 | break | ||
333 | 195 | sys.stdout = stdout | ||
334 | 196 | |||
335 | 197 | def getDescription(self, test): | ||
336 | 198 | return str(test) | ||
337 | 199 | |||
338 | 200 | # NOTE(vish): copied from unittest with edit to add color | ||
339 | 201 | def addSuccess(self, test): | ||
340 | 202 | unittest.TestResult.addSuccess(self, test) | ||
341 | 203 | if self.showAll: | ||
342 | 204 | self.colorizer.write("OK", 'green') | ||
343 | 205 | self.stream.writeln() | ||
344 | 206 | elif self.dots: | ||
345 | 207 | self.stream.write('.') | ||
346 | 208 | self.stream.flush() | ||
347 | 209 | |||
348 | 210 | # NOTE(vish): copied from unittest with edit to add color | ||
349 | 211 | def addFailure(self, test, err): | ||
350 | 212 | unittest.TestResult.addFailure(self, test, err) | ||
351 | 213 | if self.showAll: | ||
352 | 214 | self.colorizer.write("FAIL", 'red') | ||
353 | 215 | self.stream.writeln() | ||
354 | 216 | elif self.dots: | ||
355 | 217 | self.stream.write('F') | ||
356 | 218 | self.stream.flush() | ||
357 | 219 | |||
358 | 220 | # NOTE(vish): copied from nose with edit to add color | ||
359 | 221 | def addError(self, test, err): | ||
360 | 222 | """Overrides normal addError to add support for | ||
361 | 223 | errorClasses. If the exception is a registered class, the | ||
362 | 224 | error will be added to the list for that class, not errors. | ||
363 | 225 | """ | ||
364 | 226 | stream = getattr(self, 'stream', None) | ||
365 | 227 | ec, ev, tb = err | ||
366 | 228 | try: | ||
367 | 229 | exc_info = self._exc_info_to_string(err, test) | ||
368 | 230 | except TypeError: | ||
369 | 231 | # 2.3 compat | ||
370 | 232 | exc_info = self._exc_info_to_string(err) | ||
371 | 233 | for cls, (storage, label, isfail) in self.errorClasses.items(): | ||
372 | 234 | if result.isclass(ec) and issubclass(ec, cls): | ||
373 | 235 | if isfail: | ||
374 | 236 | test.passed = False | ||
375 | 237 | storage.append((test, exc_info)) | ||
376 | 238 | # Might get patched into a streamless result | ||
377 | 239 | if stream is not None: | ||
378 | 240 | if self.showAll: | ||
379 | 241 | message = [label] | ||
380 | 242 | detail = result._exception_detail(err[1]) | ||
381 | 243 | if detail: | ||
382 | 244 | message.append(detail) | ||
383 | 245 | stream.writeln(": ".join(message)) | ||
384 | 246 | elif self.dots: | ||
385 | 247 | stream.write(label[:1]) | ||
386 | 248 | return | ||
387 | 249 | self.errors.append((test, exc_info)) | ||
388 | 250 | test.passed = False | ||
389 | 251 | if stream is not None: | ||
390 | 252 | if self.showAll: | ||
391 | 253 | self.colorizer.write("ERROR", 'red') | ||
392 | 254 | self.stream.writeln() | ||
393 | 255 | elif self.dots: | ||
394 | 256 | stream.write('E') | ||
395 | 257 | |||
396 | 258 | def startTest(self, test): | ||
397 | 259 | unittest.TestResult.startTest(self, test) | ||
398 | 260 | current_case = test.test.__class__.__name__ | ||
399 | 261 | |||
400 | 262 | if self.showAll: | ||
401 | 263 | if current_case != self._last_case: | ||
402 | 264 | self.stream.writeln(current_case) | ||
403 | 265 | self._last_case = current_case | ||
404 | 266 | |||
405 | 267 | self.stream.write( | ||
406 | 268 | ' %s' % str(test.test._testMethodName).ljust(60)) | ||
407 | 269 | self.stream.flush() | ||
408 | 270 | |||
409 | 271 | |||
410 | 272 | class NovaTestRunner(core.TextTestRunner): | ||
411 | 273 | def _makeResult(self): | ||
412 | 274 | return NovaTestResult(self.stream, | ||
413 | 275 | self.descriptions, | ||
414 | 276 | self.verbosity, | ||
415 | 277 | self.config) | ||
416 | 278 | |||
417 | 279 | |||
418 | 280 | if __name__ == '__main__': | ||
419 | 281 | if not os.getenv('EC2_ACCESS_KEY'): | ||
420 | 282 | print _('Missing EC2 environment variables. Please ' \ | ||
421 | 283 | 'source the appropriate novarc file before ' \ | ||
422 | 284 | 'running this test.') | ||
423 | 285 | sys.exit(1) | ||
424 | 286 | |||
425 | 287 | testdir = os.path.abspath("./") | ||
426 | 288 | c = config.Config(stream=sys.stdout, | ||
427 | 289 | env=os.environ, | ||
428 | 290 | verbosity=3, | ||
429 | 291 | workingDir=testdir, | ||
430 | 292 | plugins=core.DefaultPluginManager()) | ||
431 | 293 | |||
432 | 294 | runner = NovaTestRunner(stream=c.stream, | ||
433 | 295 | verbosity=c.verbosity, | ||
434 | 296 | config=c) | ||
435 | 297 | sys.exit(not core.run(config=c, testRunner=runner, argv=sys.argv)) | ||
436 | 0 | 298 | ||
437 | === renamed file 'smoketests/admin_smoketests.py' => 'smoketests/test_admin.py' | |||
438 | --- smoketests/admin_smoketests.py 2011-01-12 08:47:54 +0000 | |||
439 | +++ smoketests/test_admin.py 2011-03-08 20:42:48 +0000 | |||
440 | @@ -35,10 +35,7 @@ | |||
441 | 35 | from smoketests import base | 35 | from smoketests import base |
442 | 36 | 36 | ||
443 | 37 | 37 | ||
444 | 38 | SUITE_NAMES = '[user]' | ||
445 | 39 | |||
446 | 40 | FLAGS = flags.FLAGS | 38 | FLAGS = flags.FLAGS |
447 | 41 | flags.DEFINE_string('suite', None, 'Specific test suite to run ' + SUITE_NAMES) | ||
448 | 42 | 39 | ||
449 | 43 | # TODO(devamcar): Use random tempfile | 40 | # TODO(devamcar): Use random tempfile |
450 | 44 | ZIP_FILENAME = '/tmp/nova-me-x509.zip' | 41 | ZIP_FILENAME = '/tmp/nova-me-x509.zip' |
451 | @@ -92,7 +89,3 @@ | |||
452 | 92 | os.remove(ZIP_FILENAME) | 89 | os.remove(ZIP_FILENAME) |
453 | 93 | except: | 90 | except: |
454 | 94 | pass | 91 | pass |
455 | 95 | |||
456 | 96 | if __name__ == "__main__": | ||
457 | 97 | suites = {'user': unittest.makeSuite(UserTests)} | ||
458 | 98 | sys.exit(base.run_tests(suites)) | ||
459 | 99 | 92 | ||
460 | === renamed file 'smoketests/netadmin_smoketests.py' => 'smoketests/test_netadmin.py' | |||
461 | --- smoketests/netadmin_smoketests.py 2011-02-23 02:04:32 +0000 | |||
462 | +++ smoketests/test_netadmin.py 2011-03-08 20:42:48 +0000 | |||
463 | @@ -21,7 +21,6 @@ | |||
464 | 21 | import random | 21 | import random |
465 | 22 | import sys | 22 | import sys |
466 | 23 | import time | 23 | import time |
467 | 24 | import unittest | ||
468 | 25 | 24 | ||
469 | 26 | # If ../nova/__init__.py exists, add ../ to Python search path, so that | 25 | # If ../nova/__init__.py exists, add ../ to Python search path, so that |
470 | 27 | # it will override what happens to be installed in /usr/(local/)lib/python... | 26 | # it will override what happens to be installed in /usr/(local/)lib/python... |
471 | @@ -74,8 +73,10 @@ | |||
472 | 74 | groups = self.conn.get_all_security_groups(['default']) | 73 | groups = self.conn.get_all_security_groups(['default']) |
473 | 75 | for rule in groups[0].rules: | 74 | for rule in groups[0].rules: |
474 | 76 | if (rule.ip_protocol == 'tcp' and | 75 | if (rule.ip_protocol == 'tcp' and |
476 | 77 | rule.from_port <= 22 and rule.to_port >= 22): | 76 | int(rule.from_port) <= 22 and |
477 | 77 | int(rule.to_port) >= 22): | ||
478 | 78 | ssh_authorized = True | 78 | ssh_authorized = True |
479 | 79 | break | ||
480 | 79 | if not ssh_authorized: | 80 | if not ssh_authorized: |
481 | 80 | self.conn.authorize_security_group('default', | 81 | self.conn.authorize_security_group('default', |
482 | 81 | ip_protocol='tcp', | 82 | ip_protocol='tcp', |
483 | @@ -137,11 +138,6 @@ | |||
484 | 137 | if not self.wait_for_running(self.data['instance']): | 138 | if not self.wait_for_running(self.data['instance']): |
485 | 138 | self.fail('instance failed to start') | 139 | self.fail('instance failed to start') |
486 | 139 | self.data['instance'].update() | 140 | self.data['instance'].update() |
487 | 140 | if not self.wait_for_ping(self.data['instance'].private_dns_name): | ||
488 | 141 | self.fail('could not ping instance') | ||
489 | 142 | if not self.wait_for_ssh(self.data['instance'].private_dns_name, | ||
490 | 143 | TEST_KEY): | ||
491 | 144 | self.fail('could not ssh to instance') | ||
492 | 145 | 141 | ||
493 | 146 | def test_003_can_authorize_security_group_ingress(self): | 142 | def test_003_can_authorize_security_group_ingress(self): |
494 | 147 | self.assertTrue(self.conn.authorize_security_group(TEST_GROUP, | 143 | self.assertTrue(self.conn.authorize_security_group(TEST_GROUP, |
495 | @@ -185,10 +181,3 @@ | |||
496 | 185 | self.assertFalse(TEST_GROUP in [group.name for group in groups]) | 181 | self.assertFalse(TEST_GROUP in [group.name for group in groups]) |
497 | 186 | self.conn.terminate_instances([self.data['instance'].id]) | 182 | self.conn.terminate_instances([self.data['instance'].id]) |
498 | 187 | self.assertTrue(self.conn.release_address(self.data['public_ip'])) | 183 | self.assertTrue(self.conn.release_address(self.data['public_ip'])) |
499 | 188 | |||
500 | 189 | |||
501 | 190 | if __name__ == "__main__": | ||
502 | 191 | suites = {'address': unittest.makeSuite(AddressTests), | ||
503 | 192 | 'security_group': unittest.makeSuite(SecurityGroupTests) | ||
504 | 193 | } | ||
505 | 194 | sys.exit(base.run_tests(suites)) | ||
506 | 195 | 184 | ||
507 | === renamed file 'smoketests/sysadmin_smoketests.py' => 'smoketests/test_sysadmin.py' | |||
508 | --- smoketests/sysadmin_smoketests.py 2011-02-23 02:04:08 +0000 | |||
509 | +++ smoketests/test_sysadmin.py 2011-03-08 20:42:48 +0000 | |||
510 | @@ -16,12 +16,12 @@ | |||
511 | 16 | # License for the specific language governing permissions and limitations | 16 | # License for the specific language governing permissions and limitations |
512 | 17 | # under the License. | 17 | # under the License. |
513 | 18 | 18 | ||
514 | 19 | import commands | ||
515 | 20 | import os | 19 | import os |
516 | 21 | import random | 20 | import random |
517 | 22 | import sys | 21 | import sys |
518 | 23 | import time | 22 | import time |
520 | 24 | import unittest | 23 | import tempfile |
521 | 24 | import shutil | ||
522 | 25 | 25 | ||
523 | 26 | # If ../nova/__init__.py exists, add ../ to Python search path, so that | 26 | # If ../nova/__init__.py exists, add ../ to Python search path, so that |
524 | 27 | # it will override what happens to be installed in /usr/(local/)lib/python... | 27 | # it will override what happens to be installed in /usr/(local/)lib/python... |
525 | @@ -48,10 +48,18 @@ | |||
526 | 48 | TEST_GROUP = '%s_group' % TEST_PREFIX | 48 | TEST_GROUP = '%s_group' % TEST_PREFIX |
527 | 49 | class ImageTests(base.UserSmokeTestCase): | 49 | class ImageTests(base.UserSmokeTestCase): |
528 | 50 | def test_001_can_bundle_image(self): | 50 | def test_001_can_bundle_image(self): |
530 | 51 | self.assertTrue(self.bundle_image(FLAGS.bundle_image)) | 51 | self.data['tempdir'] = tempfile.mkdtemp() |
531 | 52 | self.assertTrue(self.bundle_image(FLAGS.bundle_image, | ||
532 | 53 | self.data['tempdir'])) | ||
533 | 52 | 54 | ||
534 | 53 | def test_002_can_upload_image(self): | 55 | def test_002_can_upload_image(self): |
536 | 54 | self.assertTrue(self.upload_image(TEST_BUCKET, FLAGS.bundle_image)) | 56 | try: |
537 | 57 | self.assertTrue(self.upload_image(TEST_BUCKET, | ||
538 | 58 | FLAGS.bundle_image, | ||
539 | 59 | self.data['tempdir'])) | ||
540 | 60 | finally: | ||
541 | 61 | if os.path.exists(self.data['tempdir']): | ||
542 | 62 | shutil.rmtree(self.data['tempdir']) | ||
543 | 55 | 63 | ||
544 | 56 | def test_003_can_register_image(self): | 64 | def test_003_can_register_image(self): |
545 | 57 | image_id = self.conn.register_image('%s/%s.manifest.xml' % | 65 | image_id = self.conn.register_image('%s/%s.manifest.xml' % |
546 | @@ -191,7 +199,7 @@ | |||
547 | 191 | self.assertEqual(volume.size, 1) | 199 | self.assertEqual(volume.size, 1) |
548 | 192 | self.data['volume'] = volume | 200 | self.data['volume'] = volume |
549 | 193 | # Give network time to find volume. | 201 | # Give network time to find volume. |
551 | 194 | time.sleep(10) | 202 | time.sleep(5) |
552 | 195 | 203 | ||
553 | 196 | def test_002_can_attach_volume(self): | 204 | def test_002_can_attach_volume(self): |
554 | 197 | volume = self.data['volume'] | 205 | volume = self.data['volume'] |
555 | @@ -204,6 +212,8 @@ | |||
556 | 204 | else: | 212 | else: |
557 | 205 | self.fail('cannot attach volume with state %s' % volume.status) | 213 | self.fail('cannot attach volume with state %s' % volume.status) |
558 | 206 | 214 | ||
559 | 215 | # Give volume some time to be ready. | ||
560 | 216 | time.sleep(5) | ||
561 | 207 | volume.attach(self.data['instance'].id, self.device) | 217 | volume.attach(self.data['instance'].id, self.device) |
562 | 208 | 218 | ||
563 | 209 | # wait | 219 | # wait |
564 | @@ -218,7 +228,7 @@ | |||
565 | 218 | self.assertTrue(volume.status.startswith('in-use')) | 228 | self.assertTrue(volume.status.startswith('in-use')) |
566 | 219 | 229 | ||
567 | 220 | # Give instance time to recognize volume. | 230 | # Give instance time to recognize volume. |
569 | 221 | time.sleep(10) | 231 | time.sleep(5) |
570 | 222 | 232 | ||
571 | 223 | def test_003_can_mount_volume(self): | 233 | def test_003_can_mount_volume(self): |
572 | 224 | ip = self.data['instance'].private_dns_name | 234 | ip = self.data['instance'].private_dns_name |
573 | @@ -283,11 +293,3 @@ | |||
574 | 283 | def test_999_tearDown(self): | 293 | def test_999_tearDown(self): |
575 | 284 | self.conn.terminate_instances([self.data['instance'].id]) | 294 | self.conn.terminate_instances([self.data['instance'].id]) |
576 | 285 | self.conn.delete_key_pair(TEST_KEY) | 295 | self.conn.delete_key_pair(TEST_KEY) |
577 | 286 | |||
578 | 287 | |||
579 | 288 | if __name__ == "__main__": | ||
580 | 289 | suites = {'image': unittest.makeSuite(ImageTests), | ||
581 | 290 | 'instance': unittest.makeSuite(InstanceTests), | ||
582 | 291 | 'volume': unittest.makeSuite(VolumeTests) | ||
583 | 292 | } | ||
584 | 293 | sys.exit(base.run_tests(suites)) |
lgtm.