summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorMatt Odden <mrodden@us.ibm.com>2012-11-09 00:06:58 +0000
committerMatt Odden <mrodden@us.ibm.com>2012-11-09 00:27:48 +0000
commit321780625993aa685c629995ecccc8bbb64ae4e7 (patch)
tree8c36d65446e8db9700f76150766f03f0816cb94f /nova/tests
parentab9ee3d232e0000dd8b8f1d2623d8ac72a6c9247 (diff)
powervm: failed spawn should raise exception
fixes bug #1065295 On a failed spawn instance, we should run our cleanup on the host and then re-raise the exception to inform ComputeManager of a failure Change-Id: Ia9ce8360117e94d10d53278d4c9a16931dea70f2
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_powervm.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/nova/tests/test_powervm.py b/nova/tests/test_powervm.py
index 8f6f27bb0..b2f752b54 100644
--- a/nova/tests/test_powervm.py
+++ b/nova/tests/test_powervm.py
@@ -18,15 +18,17 @@
Test suite for PowerVMDriver.
"""
-from nova.compute import power_state
from nova import context
from nova import db
from nova import flags
from nova import test
+from nova.compute import power_state
from nova.openstack.common import log as logging
from nova.virt import images
+
from nova.virt.powervm import driver as powervm_driver
+from nova.virt.powervm import exception
from nova.virt.powervm import lpar
from nova.virt.powervm import operator
@@ -153,6 +155,28 @@ class PowerVMDriverTestCase(test.TestCase):
state = self.powervm_connection.get_info(self.instance)['state']
self.assertEqual(state, power_state.RUNNING)
+ def test_spawn_cleanup_on_fail(self):
+ """Verify on a failed spawn, we get the original exception raised"""
+ # helper function
+ def raise_(ex):
+ raise ex
+
+ self.flags(powervm_img_local_path='/images/')
+ self.stubs.Set(images, 'fetch_to_raw', lambda *x, **y: None)
+ self.stubs.Set(
+ self.powervm_connection._powervm._operator,
+ 'copy_image_file',
+ lambda *x, **y: raise_(exception.PowerVMImageCreationFailed()))
+ self.stubs.Set(
+ self.powervm_connection._powervm, '_cleanup',
+ lambda *x, **y: raise_(Exception('This should be logged.')))
+
+ self.assertRaises(exception.PowerVMImageCreationFailed,
+ self.powervm_connection.spawn,
+ context.get_admin_context(),
+ self.instance,
+ {'id': 'ANY_ID'}, 's3cr3t', [])
+
def test_destroy(self):
self.powervm_connection.destroy(self.instance, None)
self.stubs.Set(FakeIVMOperator, 'get_lpar', lambda x, y: None)