blob: 0c562c0758e8976147594015d59a666e52b4562e [file] [log] [blame]
Zane Bitter196c86e2017-10-18 16:46:39 -04001# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13
14import copy
15import time
16
17from heat_integrationtests.common import test
18from heat_integrationtests.functional import functional_base
19
20_test_template = {
21 'heat_template_version': 'pike',
22 'description': 'Test template to create two resources.',
23 'resources': {
24 'test1': {
25 'type': 'OS::Heat::TestResource',
26 'properties': {
27 'value': 'Test1',
28 'fail': False,
29 'update_replace': False,
30 'wait_secs': 0,
31 }
32 },
33 'test2': {
34 'type': 'OS::Heat::TestResource',
35 'properties': {
36 'value': 'Test1',
37 'fail': False,
38 'update_replace': False,
39 'wait_secs': 0,
40 'action_wait_secs': {
41 'create': 30,
42 }
43 },
44 'depends_on': ['test1']
45 }
46 }
47}
48
49
50def get_templates(fail=False, delay_s=None):
51 before = copy.deepcopy(_test_template)
52
53 after = copy.deepcopy(before)
54 for r in after['resources'].values():
55 r['properties']['value'] = 'Test2'
56
57 before_props = before['resources']['test2']['properties']
58 before_props['fail'] = fail
59 if delay_s is not None:
60 before_props['action_wait_secs']['create'] = delay_s
61
62 return before, after
63
64
65class SimultaneousUpdateStackTest(functional_base.FunctionalTestsBase):
66
67 @test.requires_convergence
68 def test_retrigger_success(self):
69 before, after = get_templates()
70 stack_id = self.stack_create(template=before,
71 expected_status='CREATE_IN_PROGRESS')
72 time.sleep(10)
73
74 self.update_stack(stack_id, after)
75
76 @test.requires_convergence
77 def test_retrigger_failure(self):
78 before, after = get_templates(fail=True)
79 stack_id = self.stack_create(template=before,
80 expected_status='CREATE_IN_PROGRESS')
81 time.sleep(10)
82
83 self.update_stack(stack_id, after)
Zane Bitter80b57092017-10-18 16:46:39 -040084
85 @test.requires_convergence
86 def test_retrigger_timeout(self):
87 before, after = get_templates(delay_s=70)
88 stack_id = self.stack_create(template=before,
89 expected_status='CREATE_IN_PROGRESS',
90 timeout=1)
91 time.sleep(50)
92
93 self.update_stack(stack_id, after)