summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2013-03-29 17:10:08 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2013-04-02 13:03:00 -0700
commit24aacd2c91c73245d444a2460ded1c5c94382f5f (patch)
tree2084792b58412231f418ca8ee0bcf2aeb6fc92da /nova/tests
parent7bf541cc907bd0e4c881a1bdbd6a14fd7146a5f9 (diff)
Limit the checks for block device becoming available.
Instead of previously looping potentially forever for a block device mapping to become created from the volume api, basically blocking a greenthread until this happens we now will have a number of attempts (defaulting to 10) that we will wait for the volume api to create said block device mapping (or error out). Fixes bug 1162064 Change-Id: I6ff0b42aad48df735d09f91a0a9fe98e6abcf2eb
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/compute/test_compute.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index 3a1526522..fe17421ed 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -248,6 +248,7 @@ class ComputeVolumeTestCase(BaseTestCase):
def setUp(self):
super(ComputeVolumeTestCase, self).setUp()
self.volume_id = 'fake'
+ self.fetched_attempts = 0
self.instance = {
'id': 'fake',
'uuid': 'fake',
@@ -283,6 +284,40 @@ class ComputeVolumeTestCase(BaseTestCase):
'/dev/vdb', self.instance)
self.assertEqual(self.cinfo.get('serial'), self.volume_id)
+ def test_await_block_device_created_to_slow(self):
+
+ def never_get(context, vol_id):
+ return {
+ 'status': 'creating',
+ 'id': 'blah',
+ }
+
+ self.stubs.Set(self.compute.volume_api, 'get', never_get)
+ self.assertRaises(exception.VolumeNotCreated,
+ self.compute._await_block_device_map_created,
+ self.context, '1', max_tries=2, wait_between=0.1)
+
+ def test_await_block_device_created_slow(self):
+ c = self.compute
+
+ def slow_get(context, vol_id):
+ while self.fetched_attempts < 2:
+ self.fetched_attempts += 1
+ return {
+ 'status': 'creating',
+ 'id': 'blah',
+ }
+ return {
+ 'status': 'available',
+ 'id': 'blah',
+ }
+
+ self.stubs.Set(c.volume_api, 'get', slow_get)
+ attempts = c._await_block_device_map_created(self.context, '1',
+ max_tries=4,
+ wait_between=0.1)
+ self.assertEqual(attempts, 3)
+
def test_boot_volume_serial(self):
block_device_mapping = [{
'id': 1,