heat/heat_integrationtests/functional/test_stack_cancel.py

70 lines
2.2 KiB
Python

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import copy
import eventlet
from heat_integrationtests.common import test
from heat_integrationtests.functional import functional_base
template = {
'heat_template_version': 'pike',
'resources': {
'test1': {
'type': 'OS::Heat::TestResource',
'properties': {
'value': 'Test1',
'action_wait_secs': {
'update': 30,
}
}
},
'test2': {
'type': 'OS::Heat::TestResource',
'properties': {
'value': 'Test1',
},
'depends_on': ['test1']
},
}
}
def get_templates(delay_s=None):
before = copy.deepcopy(template)
after = copy.deepcopy(before)
for r in after['resources'].values():
r['properties']['value'] = 'Test2'
if delay_s:
before_props = before['resources']['test1']['properties']
before_props['action_wait_secs']['create'] = delay_s
return before, after
class StackCancelTest(functional_base.FunctionalTestsBase):
def _test_cancel_update(self, rollback=True,
expected_status='ROLLBACK_COMPLETE'):
before, after = get_templates()
stack_id = self.stack_create(template=before)
self.update_stack(stack_id, template=after,
expected_status='UPDATE_IN_PROGRESS')
self._wait_for_resource_status(stack_id, 'test1', 'UPDATE_IN_PROGRESS')
self.cancel_update_stack(stack_id, rollback, expected_status)
return stack_id
def test_cancel_update_with_rollback(self):
self._test_cancel_update()