diff options
author | Angus Salkeld <asalkeld@redhat.com> | 2013-10-16 11:21:08 +1100 |
---|---|---|
committer | Steve Baker <sbaker@redhat.com> | 2014-01-27 16:34:15 +1300 |
commit | ec4ed57627e8127978125bcbed1cf9fc03a991e0 (patch) | |
tree | 29bcae5dcc58ea67a9536704b75c0a4fe8d9cc83 | |
parent | 35cfa39fb1f05ea94a2d244d231b2381783795d7 (diff) | |
download | heat-ec4ed57627e8127978125bcbed1cf9fc03a991e0.tar.gz |
Do not attempt a stack update when it is suspended
And in any state (inprogress, complete, failed).
Closes-bug: #1234242
Change-Id: Ic0bccfa3d3d98cb41d0f5228d8cdc164c5c1fd32
-rw-r--r-- | heat/engine/service.py | 4 | ||||
-rw-r--r-- | heat/tests/test_engine_service.py | 47 |
2 files changed, 51 insertions, 0 deletions
diff --git a/heat/engine/service.py b/heat/engine/service.py index 4462c346e..752becfe8 100644 --- a/heat/engine/service.py +++ b/heat/engine/service.py @@ -307,6 +307,10 @@ class EngineService(service.Service): current_stack = parser.Stack.load(cnxt, stack=db_stack) + if current_stack.action == current_stack.SUSPEND: + msg = _('Updating a stack when it is suspended') + raise exception.NotSupported(feature=msg) + # Now parse the template and any parameters for the updated # stack definition. tmpl = parser.Template(template, files=files) diff --git a/heat/tests/test_engine_service.py b/heat/tests/test_engine_service.py index a617e248f..b8a388179 100644 --- a/heat/tests/test_engine_service.py +++ b/heat/tests/test_engine_service.py @@ -19,6 +19,7 @@ import sys import mox from testtools import matchers +import testscenarios from oslo.config import cfg @@ -45,6 +46,10 @@ from heat.tests.common import HeatTestCase from heat.tests import generic_resource as generic_rsrc from heat.tests import utils + +load_tests = testscenarios.load_tests_apply_scenarios + + wp_template = ''' { "AWSTemplateFormatVersion" : "2010-09-09", @@ -779,6 +784,48 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase): 'Missing required credential: X-Auth-Key', ex.message) +class StackServiceUpdateNotSupportedTest(HeatTestCase): + + scenarios = [ + ('suspend_in_progress', dict(action='SUSPEND', status='IN_PROGRESS')), + ('suspend_complete', dict(action='SUSPEND', status='COMPLETE')), + ('suspend_failed', dict(action='SUSPEND', status='FAILED')), + ] + + def setUp(self): + super(StackServiceUpdateNotSupportedTest, self).setUp() + utils.setup_dummy_db() + utils.reset_dummy_db() + self.ctx = utils.dummy_context() + self.man = service.EngineService('a-host', 'a-topic') + + def test_stack_update_during(self): + stack_name = '%s-%s' % (self.action, self.status) + + old_stack = get_wordpress_stack(stack_name, self.ctx) + old_stack.action = self.action + old_stack.status = self.status + + sid = old_stack.store() + s = db_api.stack_get(self.ctx, sid) + + stack = get_wordpress_stack(stack_name, self.ctx) + + self.m.StubOutWithMock(parser, 'Stack') + self.m.StubOutWithMock(parser.Stack, 'load') + parser.Stack.load(self.ctx, stack=s).AndReturn(old_stack) + + self.m.ReplayAll() + + params = {'foo': 'bar'} + template = '{ "Resources": {} }' + self.assertRaises(exception.NotSupported, + self.man.update_stack, + self.ctx, old_stack.identifier(), template, params, + None, {}) + self.m.VerifyAll() + + class StackServiceSuspendResumeTest(HeatTestCase): def setUp(self): |