Merge lp:~anso/nova/smoketests_fixes into lp:~hudson-openstack/nova/trunk

Proposed by Vish Ishaya
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
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

Description of the change

One last fix to remove extra flag from admin_smoketests.

To post a comment you must log in.
Revision history for this message
Jay Pipes (jaypipes) wrote :

lgtm.

review: Approve
lp:~anso/nova/smoketests_fixes updated
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

Revision history for this message
Soren Hansen (soren) wrote :

This needs a merge with trunk..

review: Needs Fixing
lp:~anso/nova/smoketests_fixes updated
540. By Vish Ishaya

merged trunk

Revision history for this message
Paul Voccio (pvo) wrote :

I got a merge conflict again...

review: Needs Fixing
Revision history for this message
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_image=this_or_that, I can't seem to get this past nose.

review: Needs Information
Revision history for this message
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_image=this_or_that, I can't seem to get this past
> nose.

Ok, fixed in lp:~soren/nova/improve-smoketests which also includes this branch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'nova/tests/api/openstack/test_servers.py'
--- nova/tests/api/openstack/test_servers.py 2011-03-02 17:39:30 +0000
+++ nova/tests/api/openstack/test_servers.py 2011-03-08 20:42:48 +0000
@@ -562,6 +562,3 @@
562562
563 res = req.get_response(fakes.wsgi_app())563 res = req.get_response(fakes.wsgi_app())
564 self.assertEqual(res.status_int, 400)564 self.assertEqual(res.status_int, 400)
565
566if __name__ == "__main__":
567 unittest.main()
568565
=== modified file 'run_tests.py'
--- run_tests.py 2011-02-25 01:04:25 +0000
+++ run_tests.py 2011-03-08 20:42:48 +0000
@@ -60,6 +60,8 @@
60import unittest60import unittest
61import sys61import sys
6262
63gettext.install('nova', unicode=1)
64
63from nose import config65from nose import config
64from nose import core66from nose import core
65from nose import result67from nose import result
6668
=== modified file 'smoketests/base.py'
--- smoketests/base.py 2011-02-23 02:04:08 +0000
+++ smoketests/base.py 2011-03-08 20:42:48 +0000
@@ -31,17 +31,24 @@
31SUITE_NAMES = '[image, instance, volume]'31SUITE_NAMES = '[image, instance, volume]'
32FLAGS = flags.FLAGS32FLAGS = flags.FLAGS
33flags.DEFINE_string('suite', None, 'Specific test suite to run ' + SUITE_NAMES)33flags.DEFINE_string('suite', None, 'Specific test suite to run ' + SUITE_NAMES)
34flags.DEFINE_integer('ssh_tries', 3, 'Numer of times to try ssh')
34boto_v6 = None35boto_v6 = None
3536
3637
37class SmokeTestCase(unittest.TestCase):38class SmokeTestCase(unittest.TestCase):
38 def connect_ssh(self, ip, key_name):39 def connect_ssh(self, ip, key_name):
39 # TODO(devcamcar): set a more reasonable connection timeout time
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)
41 client = paramiko.SSHClient()41 tries = 0
42 client.set_missing_host_key_policy(paramiko.WarningPolicy())42 while(True):
43 client.connect(ip, username='root', pkey=key)43 try:
44 return client44 client = paramiko.SSHClient()
45 client.set_missing_host_key_policy(paramiko.WarningPolicy())
46 client.connect(ip, username='root', pkey=key, timeout=5)
47 return client
48 except (paramiko.AuthenticationException, paramiko.SSHException):
49 tries += 1
50 if tries == FLAGS.ssh_tries:
51 raise
4552
46 def can_ping(self, ip, command="ping"):53 def can_ping(self, ip, command="ping"):
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."""
@@ -147,8 +154,8 @@
147 except:154 except:
148 pass155 pass
149156
150 def bundle_image(self, image, kernel=False):157 def bundle_image(self, image, tempdir='/tmp', kernel=False):
151 cmd = 'euca-bundle-image -i %s' % image158 cmd = 'euca-bundle-image -i %s -d %s' % (image, tempdir)
152 if kernel:159 if kernel:
153 cmd += ' --kernel true'160 cmd += ' --kernel true'
154 status, output = commands.getstatusoutput(cmd)161 status, output = commands.getstatusoutput(cmd)
@@ -157,9 +164,9 @@
157 raise Exception(output)164 raise Exception(output)
158 return True165 return True
159166
160 def upload_image(self, bucket_name, image):167 def upload_image(self, bucket_name, image, tempdir='/tmp'):
161 cmd = 'euca-upload-bundle -b '168 cmd = 'euca-upload-bundle -b '
162 cmd += '%s -m /tmp/%s.manifest.xml' % (bucket_name, image)169 cmd += '%s -m %s/%s.manifest.xml' % (bucket_name, tempdir, image)
163 status, output = commands.getstatusoutput(cmd)170 status, output = commands.getstatusoutput(cmd)
164 if status != 0:171 if status != 0:
165 print '%s -> \n %s' % (cmd, output)172 print '%s -> \n %s' % (cmd, output)
@@ -183,29 +190,3 @@
183 global TEST_DATA190 global TEST_DATA
184 self.conn = self.connection_for_env()191 self.conn = self.connection_for_env()
185 self.data = TEST_DATA192 self.data = TEST_DATA
186
187
188def run_tests(suites):
189 argv = FLAGS(sys.argv)
190 if FLAGS.use_ipv6:
191 global boto_v6
192 boto_v6 = __import__('boto_v6')
193
194 if not os.getenv('EC2_ACCESS_KEY'):
195 print >> sys.stderr, 'Missing EC2 environment variables. Please ' \
196 'source the appropriate novarc file before ' \
197 'running this test.'
198 return 1
199
200 if FLAGS.suite:
201 try:
202 suite = suites[FLAGS.suite]
203 except KeyError:
204 print >> sys.stderr, 'Available test suites:', \
205 ', '.join(suites.keys())
206 return 1
207
208 unittest.TextTestRunner(verbosity=2).run(suite)
209 else:
210 for suite in suites.itervalues():
211 unittest.TextTestRunner(verbosity=2).run(suite)
212193
=== modified file 'smoketests/public_network_smoketests.py'
--- smoketests/public_network_smoketests.py 2011-02-23 02:04:08 +0000
+++ smoketests/public_network_smoketests.py 2011-03-08 20:42:48 +0000
@@ -19,10 +19,8 @@
19import commands19import commands
20import os20import os
21import random21import random
22import socket
23import sys22import sys
24import time23import time
25import unittest
2624
27# If ../nova/__init__.py exists, add ../ to Python search path, so that25# If ../nova/__init__.py exists, add ../ to Python search path, so that
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...
@@ -181,7 +179,3 @@
181 self.conn.delete_security_group(security_group_name)179 self.conn.delete_security_group(security_group_name)
182 if 'instance_id' in self.data:180 if 'instance_id' in self.data:
183 self.conn.terminate_instances([self.data['instance_id']])181 self.conn.terminate_instances([self.data['instance_id']])
184
185if __name__ == "__main__":
186 suites = {'instance': unittest.makeSuite(InstanceTestsFromPublic)}
187 sys.exit(base.run_tests(suites))
188182
=== added file 'smoketests/run_tests.py'
--- smoketests/run_tests.py 1970-01-01 00:00:00 +0000
+++ smoketests/run_tests.py 2011-03-08 20:42:48 +0000
@@ -0,0 +1,297 @@
1#!/usr/bin/env python
2# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
4# Copyright 2010 United States Government as represented by the
5# Administrator of the National Aeronautics and Space Administration.
6# All Rights Reserved.
7#
8# Licensed under the Apache License, Version 2.0 (the "License");
9# you may not use this file except in compliance with the License.
10# You may obtain a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing, software
15# distributed under the License is distributed on an "AS IS" BASIS,
16# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17# See the License for the specific language governing permissions and
18# limitations under the License.
19
20# Colorizer Code is borrowed from Twisted:
21# Copyright (c) 2001-2010 Twisted Matrix Laboratories.
22#
23# Permission is hereby granted, free of charge, to any person obtaining
24# a copy of this software and associated documentation files (the
25# "Software"), to deal in the Software without restriction, including
26# without limitation the rights to use, copy, modify, merge, publish,
27# distribute, sublicense, and/or sell copies of the Software, and to
28# permit persons to whom the Software is furnished to do so, subject to
29# the following conditions:
30#
31# The above copyright notice and this permission notice shall be
32# included in all copies or substantial portions of the Software.
33#
34# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
35# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
36# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
37# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
38# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
39# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
40# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41"""Unittest runner for Nova.
42
43To run all tests
44 python run_tests.py
45
46To run a single test:
47 python run_tests.py test_compute:ComputeTestCase.test_run_terminate
48
49To run a single test module:
50 python run_tests.py test_compute
51
52 or
53
54 python run_tests.py api.test_wsgi
55
56"""
57
58import gettext
59import os
60import unittest
61import sys
62
63gettext.install('nova', unicode=1)
64
65from nose import config
66from nose import core
67from nose import result
68
69
70class _AnsiColorizer(object):
71 """
72 A colorizer is an object that loosely wraps around a stream, allowing
73 callers to write text to the stream in a particular color.
74
75 Colorizer classes must implement C{supported()} and C{write(text, color)}.
76 """
77 _colors = dict(black=30, red=31, green=32, yellow=33,
78 blue=34, magenta=35, cyan=36, white=37)
79
80 def __init__(self, stream):
81 self.stream = stream
82
83 def supported(cls, stream=sys.stdout):
84 """
85 A class method that returns True if the current platform supports
86 coloring terminal output using this method. Returns False otherwise.
87 """
88 if not stream.isatty():
89 return False # auto color only on TTYs
90 try:
91 import curses
92 except ImportError:
93 return False
94 else:
95 try:
96 try:
97 return curses.tigetnum("colors") > 2
98 except curses.error:
99 curses.setupterm()
100 return curses.tigetnum("colors") > 2
101 except:
102 raise
103 # guess false in case of error
104 return False
105 supported = classmethod(supported)
106
107 def write(self, text, color):
108 """
109 Write the given text to the stream in the given color.
110
111 @param text: Text to be written to the stream.
112
113 @param color: A string label for a color. e.g. 'red', 'white'.
114 """
115 color = self._colors[color]
116 self.stream.write('\x1b[%s;1m%s\x1b[0m' % (color, text))
117
118
119class _Win32Colorizer(object):
120 """
121 See _AnsiColorizer docstring.
122 """
123 def __init__(self, stream):
124 from win32console import GetStdHandle, STD_OUT_HANDLE, \
125 FOREGROUND_RED, FOREGROUND_BLUE, FOREGROUND_GREEN, \
126 FOREGROUND_INTENSITY
127 red, green, blue, bold = (FOREGROUND_RED, FOREGROUND_GREEN,
128 FOREGROUND_BLUE, FOREGROUND_INTENSITY)
129 self.stream = stream
130 self.screenBuffer = GetStdHandle(STD_OUT_HANDLE)
131 self._colors = {
132 'normal': red | green | blue,
133 'red': red | bold,
134 'green': green | bold,
135 'blue': blue | bold,
136 'yellow': red | green | bold,
137 'magenta': red | blue | bold,
138 'cyan': green | blue | bold,
139 'white': red | green | blue | bold
140 }
141
142 def supported(cls, stream=sys.stdout):
143 try:
144 import win32console
145 screenBuffer = win32console.GetStdHandle(
146 win32console.STD_OUT_HANDLE)
147 except ImportError:
148 return False
149 import pywintypes
150 try:
151 screenBuffer.SetConsoleTextAttribute(
152 win32console.FOREGROUND_RED |
153 win32console.FOREGROUND_GREEN |
154 win32console.FOREGROUND_BLUE)
155 except pywintypes.error:
156 return False
157 else:
158 return True
159 supported = classmethod(supported)
160
161 def write(self, text, color):
162 color = self._colors[color]
163 self.screenBuffer.SetConsoleTextAttribute(color)
164 self.stream.write(text)
165 self.screenBuffer.SetConsoleTextAttribute(self._colors['normal'])
166
167
168class _NullColorizer(object):
169 """
170 See _AnsiColorizer docstring.
171 """
172 def __init__(self, stream):
173 self.stream = stream
174
175 def supported(cls, stream=sys.stdout):
176 return True
177 supported = classmethod(supported)
178
179 def write(self, text, color):
180 self.stream.write(text)
181
182
183class NovaTestResult(result.TextTestResult):
184 def __init__(self, *args, **kw):
185 result.TextTestResult.__init__(self, *args, **kw)
186 self._last_case = None
187 self.colorizer = None
188 # NOTE(vish): reset stdout for the terminal check
189 stdout = sys.stdout
190 sys.stdout = sys.__stdout__
191 for colorizer in [_Win32Colorizer, _AnsiColorizer, _NullColorizer]:
192 if colorizer.supported():
193 self.colorizer = colorizer(self.stream)
194 break
195 sys.stdout = stdout
196
197 def getDescription(self, test):
198 return str(test)
199
200 # NOTE(vish): copied from unittest with edit to add color
201 def addSuccess(self, test):
202 unittest.TestResult.addSuccess(self, test)
203 if self.showAll:
204 self.colorizer.write("OK", 'green')
205 self.stream.writeln()
206 elif self.dots:
207 self.stream.write('.')
208 self.stream.flush()
209
210 # NOTE(vish): copied from unittest with edit to add color
211 def addFailure(self, test, err):
212 unittest.TestResult.addFailure(self, test, err)
213 if self.showAll:
214 self.colorizer.write("FAIL", 'red')
215 self.stream.writeln()
216 elif self.dots:
217 self.stream.write('F')
218 self.stream.flush()
219
220 # NOTE(vish): copied from nose with edit to add color
221 def addError(self, test, err):
222 """Overrides normal addError to add support for
223 errorClasses. If the exception is a registered class, the
224 error will be added to the list for that class, not errors.
225 """
226 stream = getattr(self, 'stream', None)
227 ec, ev, tb = err
228 try:
229 exc_info = self._exc_info_to_string(err, test)
230 except TypeError:
231 # 2.3 compat
232 exc_info = self._exc_info_to_string(err)
233 for cls, (storage, label, isfail) in self.errorClasses.items():
234 if result.isclass(ec) and issubclass(ec, cls):
235 if isfail:
236 test.passed = False
237 storage.append((test, exc_info))
238 # Might get patched into a streamless result
239 if stream is not None:
240 if self.showAll:
241 message = [label]
242 detail = result._exception_detail(err[1])
243 if detail:
244 message.append(detail)
245 stream.writeln(": ".join(message))
246 elif self.dots:
247 stream.write(label[:1])
248 return
249 self.errors.append((test, exc_info))
250 test.passed = False
251 if stream is not None:
252 if self.showAll:
253 self.colorizer.write("ERROR", 'red')
254 self.stream.writeln()
255 elif self.dots:
256 stream.write('E')
257
258 def startTest(self, test):
259 unittest.TestResult.startTest(self, test)
260 current_case = test.test.__class__.__name__
261
262 if self.showAll:
263 if current_case != self._last_case:
264 self.stream.writeln(current_case)
265 self._last_case = current_case
266
267 self.stream.write(
268 ' %s' % str(test.test._testMethodName).ljust(60))
269 self.stream.flush()
270
271
272class NovaTestRunner(core.TextTestRunner):
273 def _makeResult(self):
274 return NovaTestResult(self.stream,
275 self.descriptions,
276 self.verbosity,
277 self.config)
278
279
280if __name__ == '__main__':
281 if not os.getenv('EC2_ACCESS_KEY'):
282 print _('Missing EC2 environment variables. Please ' \
283 'source the appropriate novarc file before ' \
284 'running this test.')
285 sys.exit(1)
286
287 testdir = os.path.abspath("./")
288 c = config.Config(stream=sys.stdout,
289 env=os.environ,
290 verbosity=3,
291 workingDir=testdir,
292 plugins=core.DefaultPluginManager())
293
294 runner = NovaTestRunner(stream=c.stream,
295 verbosity=c.verbosity,
296 config=c)
297 sys.exit(not core.run(config=c, testRunner=runner, argv=sys.argv))
0298
=== renamed file 'smoketests/admin_smoketests.py' => 'smoketests/test_admin.py'
--- smoketests/admin_smoketests.py 2011-01-12 08:47:54 +0000
+++ smoketests/test_admin.py 2011-03-08 20:42:48 +0000
@@ -35,10 +35,7 @@
35from smoketests import base35from smoketests import base
3636
3737
38SUITE_NAMES = '[user]'
39
40FLAGS = flags.FLAGS38FLAGS = flags.FLAGS
41flags.DEFINE_string('suite', None, 'Specific test suite to run ' + SUITE_NAMES)
4239
43# TODO(devamcar): Use random tempfile40# TODO(devamcar): Use random tempfile
44ZIP_FILENAME = '/tmp/nova-me-x509.zip'41ZIP_FILENAME = '/tmp/nova-me-x509.zip'
@@ -92,7 +89,3 @@
92 os.remove(ZIP_FILENAME)89 os.remove(ZIP_FILENAME)
93 except:90 except:
94 pass91 pass
95
96if __name__ == "__main__":
97 suites = {'user': unittest.makeSuite(UserTests)}
98 sys.exit(base.run_tests(suites))
9992
=== renamed file 'smoketests/netadmin_smoketests.py' => 'smoketests/test_netadmin.py'
--- smoketests/netadmin_smoketests.py 2011-02-23 02:04:32 +0000
+++ smoketests/test_netadmin.py 2011-03-08 20:42:48 +0000
@@ -21,7 +21,6 @@
21import random21import random
22import sys22import sys
23import time23import time
24import unittest
2524
26# If ../nova/__init__.py exists, add ../ to Python search path, so that25# If ../nova/__init__.py exists, add ../ to Python search path, so that
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...
@@ -74,8 +73,10 @@
74 groups = self.conn.get_all_security_groups(['default'])73 groups = self.conn.get_all_security_groups(['default'])
75 for rule in groups[0].rules:74 for rule in groups[0].rules:
76 if (rule.ip_protocol == 'tcp' and75 if (rule.ip_protocol == 'tcp' and
77 rule.from_port <= 22 and rule.to_port >= 22):76 int(rule.from_port) <= 22 and
77 int(rule.to_port) >= 22):
78 ssh_authorized = True78 ssh_authorized = True
79 break
79 if not ssh_authorized:80 if not ssh_authorized:
80 self.conn.authorize_security_group('default',81 self.conn.authorize_security_group('default',
81 ip_protocol='tcp',82 ip_protocol='tcp',
@@ -137,11 +138,6 @@
137 if not self.wait_for_running(self.data['instance']):138 if not self.wait_for_running(self.data['instance']):
138 self.fail('instance failed to start')139 self.fail('instance failed to start')
139 self.data['instance'].update()140 self.data['instance'].update()
140 if not self.wait_for_ping(self.data['instance'].private_dns_name):
141 self.fail('could not ping instance')
142 if not self.wait_for_ssh(self.data['instance'].private_dns_name,
143 TEST_KEY):
144 self.fail('could not ssh to instance')
145141
146 def test_003_can_authorize_security_group_ingress(self):142 def test_003_can_authorize_security_group_ingress(self):
147 self.assertTrue(self.conn.authorize_security_group(TEST_GROUP,143 self.assertTrue(self.conn.authorize_security_group(TEST_GROUP,
@@ -185,10 +181,3 @@
185 self.assertFalse(TEST_GROUP in [group.name for group in groups])181 self.assertFalse(TEST_GROUP in [group.name for group in groups])
186 self.conn.terminate_instances([self.data['instance'].id])182 self.conn.terminate_instances([self.data['instance'].id])
187 self.assertTrue(self.conn.release_address(self.data['public_ip']))183 self.assertTrue(self.conn.release_address(self.data['public_ip']))
188
189
190if __name__ == "__main__":
191 suites = {'address': unittest.makeSuite(AddressTests),
192 'security_group': unittest.makeSuite(SecurityGroupTests)
193 }
194 sys.exit(base.run_tests(suites))
195184
=== renamed file 'smoketests/sysadmin_smoketests.py' => 'smoketests/test_sysadmin.py'
--- smoketests/sysadmin_smoketests.py 2011-02-23 02:04:08 +0000
+++ smoketests/test_sysadmin.py 2011-03-08 20:42:48 +0000
@@ -16,12 +16,12 @@
16# License for the specific language governing permissions and limitations16# License for the specific language governing permissions and limitations
17# under the License.17# under the License.
1818
19import commands
20import os19import os
21import random20import random
22import sys21import sys
23import time22import time
24import unittest23import tempfile
24import shutil
2525
26# If ../nova/__init__.py exists, add ../ to Python search path, so that26# If ../nova/__init__.py exists, add ../ to Python search path, so that
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...
@@ -48,10 +48,18 @@
48TEST_GROUP = '%s_group' % TEST_PREFIX48TEST_GROUP = '%s_group' % TEST_PREFIX
49class ImageTests(base.UserSmokeTestCase):49class ImageTests(base.UserSmokeTestCase):
50 def test_001_can_bundle_image(self):50 def test_001_can_bundle_image(self):
51 self.assertTrue(self.bundle_image(FLAGS.bundle_image))51 self.data['tempdir'] = tempfile.mkdtemp()
52 self.assertTrue(self.bundle_image(FLAGS.bundle_image,
53 self.data['tempdir']))
5254
53 def test_002_can_upload_image(self):55 def test_002_can_upload_image(self):
54 self.assertTrue(self.upload_image(TEST_BUCKET, FLAGS.bundle_image))56 try:
57 self.assertTrue(self.upload_image(TEST_BUCKET,
58 FLAGS.bundle_image,
59 self.data['tempdir']))
60 finally:
61 if os.path.exists(self.data['tempdir']):
62 shutil.rmtree(self.data['tempdir'])
5563
56 def test_003_can_register_image(self):64 def test_003_can_register_image(self):
57 image_id = self.conn.register_image('%s/%s.manifest.xml' %65 image_id = self.conn.register_image('%s/%s.manifest.xml' %
@@ -191,7 +199,7 @@
191 self.assertEqual(volume.size, 1)199 self.assertEqual(volume.size, 1)
192 self.data['volume'] = volume200 self.data['volume'] = volume
193 # Give network time to find volume.201 # Give network time to find volume.
194 time.sleep(10)202 time.sleep(5)
195203
196 def test_002_can_attach_volume(self):204 def test_002_can_attach_volume(self):
197 volume = self.data['volume']205 volume = self.data['volume']
@@ -204,6 +212,8 @@
204 else:212 else:
205 self.fail('cannot attach volume with state %s' % volume.status)213 self.fail('cannot attach volume with state %s' % volume.status)
206214
215 # Give volume some time to be ready.
216 time.sleep(5)
207 volume.attach(self.data['instance'].id, self.device)217 volume.attach(self.data['instance'].id, self.device)
208218
209 # wait219 # wait
@@ -218,7 +228,7 @@
218 self.assertTrue(volume.status.startswith('in-use'))228 self.assertTrue(volume.status.startswith('in-use'))
219229
220 # Give instance time to recognize volume.230 # Give instance time to recognize volume.
221 time.sleep(10)231 time.sleep(5)
222232
223 def test_003_can_mount_volume(self):233 def test_003_can_mount_volume(self):
224 ip = self.data['instance'].private_dns_name234 ip = self.data['instance'].private_dns_name
@@ -283,11 +293,3 @@
283 def test_999_tearDown(self):293 def test_999_tearDown(self):
284 self.conn.terminate_instances([self.data['instance'].id])294 self.conn.terminate_instances([self.data['instance'].id])
285 self.conn.delete_key_pair(TEST_KEY)295 self.conn.delete_key_pair(TEST_KEY)
286
287
288if __name__ == "__main__":
289 suites = {'image': unittest.makeSuite(ImageTests),
290 'instance': unittest.makeSuite(InstanceTests),
291 'volume': unittest.makeSuite(VolumeTests)
292 }
293 sys.exit(base.run_tests(suites))