blob: 478cfae5a89ae2e220f19fcd767d5020b4dead3d [file] [log] [blame]
Angus Salkeld2bd63a42015-01-07 11:11:29 +10001# 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
13import json
Pavlo Shchelokovskyy60e0ecd2014-12-14 22:17:21 +020014
Angus Salkeld2bd63a42015-01-07 11:11:29 +100015import yaml
16
17from heat_integrationtests.common import test
18
19
Angus Salkeld2bd63a42015-01-07 11:11:29 +100020class TemplateResourceTest(test.HeatIntegrationTest):
21 """Prove that we can use the registry in a nested provider."""
Angus Salkeld95403d82015-02-12 14:06:01 +100022
23 template = '''
24heat_template_version: 2013-05-23
25resources:
26 secret1:
27 type: OS::Heat::RandomString
28outputs:
29 secret-out:
30 value: { get_attr: [secret1, value] }
31'''
32 nested_templ = '''
33heat_template_version: 2013-05-23
34resources:
35 secret2:
36 type: OS::Heat::RandomString
37outputs:
38 value:
39 value: { get_attr: [secret2, value] }
40'''
41
42 env_templ = '''
43resource_registry:
44 "OS::Heat::RandomString": nested.yaml
45'''
46
Angus Salkeld2bd63a42015-01-07 11:11:29 +100047 def setUp(self):
48 super(TemplateResourceTest, self).setUp()
49 self.client = self.orchestration_client
50
51 def test_nested_env(self):
52 main_templ = '''
53heat_template_version: 2013-05-23
54resources:
55 secret1:
56 type: My::NestedSecret
57outputs:
58 secret-out:
59 value: { get_attr: [secret1, value] }
60'''
61
62 nested_templ = '''
63heat_template_version: 2013-05-23
64resources:
65 secret2:
66 type: My::Secret
67outputs:
68 value:
69 value: { get_attr: [secret2, value] }
70'''
71
72 env_templ = '''
73resource_registry:
74 "My::Secret": "OS::Heat::RandomString"
75 "My::NestedSecret": nested.yaml
76'''
77
78 stack_identifier = self.stack_create(
79 template=main_templ,
80 files={'nested.yaml': nested_templ},
81 environment=env_templ)
Angus Salkeld2e61f9f2015-04-07 09:25:50 +100082 nested_ident = self.assert_resource_is_a_stack(stack_identifier,
83 'secret1')
84 # prove that resource.parent_resource is populated.
85 sec2 = self.client.resources.get(nested_ident, 'secret2')
86 self.assertEqual('secret1', sec2.parent_resource)
Angus Salkeld2bd63a42015-01-07 11:11:29 +100087
88 def test_no_infinite_recursion(self):
89 """Prove that we can override a python resource.
90
91 And use that resource within the template resource.
92 """
Angus Salkeld2bd63a42015-01-07 11:11:29 +100093 stack_identifier = self.stack_create(
Angus Salkeld95403d82015-02-12 14:06:01 +100094 template=self.template,
95 files={'nested.yaml': self.nested_templ},
96 environment=self.env_templ)
Angus Salkeld2bd63a42015-01-07 11:11:29 +100097 self.assert_resource_is_a_stack(stack_identifier, 'secret1')
98
Angus Salkeld95403d82015-02-12 14:06:01 +100099 def test_nested_stack_delete_then_delete_parent_stack(self):
100 """Check the robustness of stack deletion.
101
102 This tests that if you manually delete a nested
103 stack, the parent stack is still deletable.
104 """
Sergey Kraynevbf67ce32015-04-17 10:54:20 -0400105 # disable cleanup so we can call _stack_delete() directly.
106 stack_identifier = self.stack_create(
Angus Salkeld95403d82015-02-12 14:06:01 +1000107 template=self.template,
108 files={'nested.yaml': self.nested_templ},
109 environment=self.env_templ,
Sergey Kraynevbf67ce32015-04-17 10:54:20 -0400110 enable_cleanup=False)
Angus Salkeld95403d82015-02-12 14:06:01 +1000111
112 nested_ident = self.assert_resource_is_a_stack(stack_identifier,
113 'secret1')
114
115 self._stack_delete(nested_ident)
116 self._stack_delete(stack_identifier)
117
Angus Salkeld19b9e1d2015-05-08 11:02:38 +1000118 def test_change_in_file_path(self):
119 stack_identifier = self.stack_create(
120 template=self.template,
121 files={'nested.yaml': self.nested_templ},
122 environment=self.env_templ)
123 stack = self.client.stacks.get(stack_identifier)
124 secret_out1 = self._stack_output(stack, 'secret-out')
125
126 nested_templ_2 = '''
127heat_template_version: 2013-05-23
128resources:
129 secret2:
130 type: OS::Heat::RandomString
131outputs:
132 value:
133 value: freddy
134'''
135 env_templ_2 = '''
136resource_registry:
137 "OS::Heat::RandomString": new/nested.yaml
138'''
139 self.update_stack(stack_identifier,
140 template=self.template,
141 files={'new/nested.yaml': nested_templ_2},
142 environment=env_templ_2)
143 stack = self.client.stacks.get(stack_identifier)
144 secret_out2 = self._stack_output(stack, 'secret-out')
145 self.assertNotEqual(secret_out1, secret_out2)
146 self.assertEqual('freddy', secret_out2)
147
Angus Salkeld2bd63a42015-01-07 11:11:29 +1000148
149class NestedAttributesTest(test.HeatIntegrationTest):
150 """Prove that we can use the template resource references."""
151
152 main_templ = '''
153heat_template_version: 2014-10-16
154resources:
155 secret2:
156 type: My::NestedSecret
157outputs:
158 old_way:
159 value: { get_attr: [secret2, nested_str]}
160 test_attr1:
161 value: { get_attr: [secret2, resource.secret1, value]}
162 test_attr2:
163 value: { get_attr: [secret2, resource.secret1.value]}
164 test_ref:
165 value: { get_resource: secret2 }
166'''
167
168 env_templ = '''
169resource_registry:
170 "My::NestedSecret": nested.yaml
171'''
172
173 def setUp(self):
174 super(NestedAttributesTest, self).setUp()
175 self.client = self.orchestration_client
176
177 def test_stack_ref(self):
178 nested_templ = '''
179heat_template_version: 2014-10-16
180resources:
181 secret1:
182 type: OS::Heat::RandomString
Angus Salkelda89a0282015-07-24 15:47:38 +1000183outputs:
184 nested_str:
185 value: {get_attr: [secret1, value]}
Angus Salkeld2bd63a42015-01-07 11:11:29 +1000186'''
187 stack_identifier = self.stack_create(
188 template=self.main_templ,
189 files={'nested.yaml': nested_templ},
190 environment=self.env_templ)
191 self.assert_resource_is_a_stack(stack_identifier, 'secret2')
192 stack = self.client.stacks.get(stack_identifier)
193 test_ref = self._stack_output(stack, 'test_ref')
194 self.assertIn('arn:openstack:heat:', test_ref)
195
196 def test_transparent_ref(self):
197 """With the addition of OS::stack_id we can now use the nested resource
198 more transparently.
199 """
200 nested_templ = '''
201heat_template_version: 2014-10-16
202resources:
203 secret1:
204 type: OS::Heat::RandomString
205outputs:
206 OS::stack_id:
207 value: {get_resource: secret1}
208 nested_str:
209 value: {get_attr: [secret1, value]}
210'''
211 stack_identifier = self.stack_create(
212 template=self.main_templ,
213 files={'nested.yaml': nested_templ},
214 environment=self.env_templ)
215 self.assert_resource_is_a_stack(stack_identifier, 'secret2')
216 stack = self.client.stacks.get(stack_identifier)
217 test_ref = self._stack_output(stack, 'test_ref')
218 test_attr = self._stack_output(stack, 'old_way')
219
220 self.assertNotIn('arn:openstack:heat', test_ref)
221 self.assertEqual(test_attr, test_ref)
222
223 def test_nested_attributes(self):
224 nested_templ = '''
225heat_template_version: 2014-10-16
226resources:
227 secret1:
228 type: OS::Heat::RandomString
229outputs:
230 nested_str:
231 value: {get_attr: [secret1, value]}
232'''
233 stack_identifier = self.stack_create(
234 template=self.main_templ,
235 files={'nested.yaml': nested_templ},
236 environment=self.env_templ)
237 self.assert_resource_is_a_stack(stack_identifier, 'secret2')
238 stack = self.client.stacks.get(stack_identifier)
239 old_way = self._stack_output(stack, 'old_way')
240 test_attr1 = self._stack_output(stack, 'test_attr1')
241 test_attr2 = self._stack_output(stack, 'test_attr2')
242
243 self.assertEqual(old_way, test_attr1)
244 self.assertEqual(old_way, test_attr2)
245
246
247class TemplateResourceUpdateTest(test.HeatIntegrationTest):
248 """Prove that we can do template resource updates."""
249
250 main_template = '''
251HeatTemplateFormatVersion: '2012-12-12'
252Resources:
253 the_nested:
254 Type: the.yaml
255 Properties:
256 one: my_name
Rabi Mishrab1293ae2015-05-13 16:39:04 +0530257 two: your_name
258Outputs:
259 identifier:
260 Value: {Ref: the_nested}
261 value:
262 Value: {'Fn::GetAtt': [the_nested, the_str]}
263'''
264
265 main_template_change_prop = '''
266HeatTemplateFormatVersion: '2012-12-12'
267Resources:
268 the_nested:
269 Type: the.yaml
270 Properties:
271 one: updated_name
272 two: your_name
Angus Salkeld2bd63a42015-01-07 11:11:29 +1000273
274Outputs:
275 identifier:
276 Value: {Ref: the_nested}
277 value:
278 Value: {'Fn::GetAtt': [the_nested, the_str]}
279'''
280
Rabi Mishrab1293ae2015-05-13 16:39:04 +0530281 main_template_add_prop = '''
Angus Salkeld2bd63a42015-01-07 11:11:29 +1000282HeatTemplateFormatVersion: '2012-12-12'
283Resources:
284 the_nested:
285 Type: the.yaml
286 Properties:
Rabi Mishrab1293ae2015-05-13 16:39:04 +0530287 one: my_name
288 two: your_name
289 three: third_name
290
291Outputs:
292 identifier:
293 Value: {Ref: the_nested}
294 value:
295 Value: {'Fn::GetAtt': [the_nested, the_str]}
296'''
297
298 main_template_remove_prop = '''
299HeatTemplateFormatVersion: '2012-12-12'
300Resources:
301 the_nested:
302 Type: the.yaml
303 Properties:
304 one: my_name
Angus Salkeld2bd63a42015-01-07 11:11:29 +1000305
306Outputs:
307 identifier:
308 Value: {Ref: the_nested}
309 value:
310 Value: {'Fn::GetAtt': [the_nested, the_str]}
311'''
312
313 initial_tmpl = '''
314HeatTemplateFormatVersion: '2012-12-12'
315Parameters:
316 one:
317 Default: foo
318 Type: String
Rabi Mishrab1293ae2015-05-13 16:39:04 +0530319 two:
320 Default: bar
321 Type: String
322
Angus Salkeld2bd63a42015-01-07 11:11:29 +1000323Resources:
324 NestedResource:
325 Type: OS::Heat::RandomString
326 Properties:
327 salt: {Ref: one}
328Outputs:
329 the_str:
330 Value: {'Fn::GetAtt': [NestedResource, value]}
331'''
Rabi Mishrab1293ae2015-05-13 16:39:04 +0530332
Angus Salkeld2bd63a42015-01-07 11:11:29 +1000333 prop_change_tmpl = '''
334HeatTemplateFormatVersion: '2012-12-12'
335Parameters:
336 one:
337 Default: yikes
338 Type: String
339 two:
340 Default: foo
341 Type: String
342Resources:
343 NestedResource:
344 Type: OS::Heat::RandomString
345 Properties:
Rabi Mishrab1293ae2015-05-13 16:39:04 +0530346 salt: {Ref: two}
347Outputs:
348 the_str:
349 Value: {'Fn::GetAtt': [NestedResource, value]}
350'''
351
352 prop_add_tmpl = '''
353HeatTemplateFormatVersion: '2012-12-12'
354Parameters:
355 one:
356 Default: yikes
357 Type: String
358 two:
359 Default: foo
360 Type: String
361 three:
362 Default: bar
363 Type: String
364
365Resources:
366 NestedResource:
367 Type: OS::Heat::RandomString
368 Properties:
369 salt: {Ref: three}
370Outputs:
371 the_str:
372 Value: {'Fn::GetAtt': [NestedResource, value]}
373'''
374
375 prop_remove_tmpl = '''
376HeatTemplateFormatVersion: '2012-12-12'
377Parameters:
378 one:
379 Default: yikes
380 Type: String
381
382Resources:
383 NestedResource:
384 Type: OS::Heat::RandomString
385 Properties:
Angus Salkeld2bd63a42015-01-07 11:11:29 +1000386 salt: {Ref: one}
387Outputs:
388 the_str:
389 Value: {'Fn::GetAtt': [NestedResource, value]}
390'''
Rabi Mishrab1293ae2015-05-13 16:39:04 +0530391
Angus Salkeld2bd63a42015-01-07 11:11:29 +1000392 attr_change_tmpl = '''
393HeatTemplateFormatVersion: '2012-12-12'
394Parameters:
395 one:
396 Default: foo
397 Type: String
Rabi Mishrab1293ae2015-05-13 16:39:04 +0530398 two:
399 Default: bar
400 Type: String
401
Angus Salkeld2bd63a42015-01-07 11:11:29 +1000402Resources:
403 NestedResource:
404 Type: OS::Heat::RandomString
405 Properties:
406 salt: {Ref: one}
407Outputs:
408 the_str:
409 Value: {'Fn::GetAtt': [NestedResource, value]}
410 something_else:
411 Value: just_a_string
412'''
Rabi Mishrab1293ae2015-05-13 16:39:04 +0530413
Angus Salkeld2bd63a42015-01-07 11:11:29 +1000414 content_change_tmpl = '''
415HeatTemplateFormatVersion: '2012-12-12'
416Parameters:
417 one:
418 Default: foo
419 Type: String
Rabi Mishrab1293ae2015-05-13 16:39:04 +0530420 two:
421 Default: bar
422 Type: String
423
Angus Salkeld2bd63a42015-01-07 11:11:29 +1000424Resources:
425 NestedResource:
426 Type: OS::Heat::RandomString
427 Properties:
428 salt: yum
429Outputs:
430 the_str:
431 Value: {'Fn::GetAtt': [NestedResource, value]}
432'''
433
434 EXPECTED = (UPDATE, NOCHANGE) = ('update', 'nochange')
435 scenarios = [
436 ('no_changes', dict(template=main_template,
437 provider=initial_tmpl,
438 expect=NOCHANGE)),
Rabi Mishrab1293ae2015-05-13 16:39:04 +0530439 ('main_tmpl_change', dict(template=main_template_change_prop,
Angus Salkeld2bd63a42015-01-07 11:11:29 +1000440 provider=initial_tmpl,
441 expect=UPDATE)),
442 ('provider_change', dict(template=main_template,
443 provider=content_change_tmpl,
444 expect=UPDATE)),
445 ('provider_props_change', dict(template=main_template,
446 provider=prop_change_tmpl,
Rabi Mishrab1293ae2015-05-13 16:39:04 +0530447 expect=UPDATE)),
448 ('provider_props_add', dict(template=main_template_add_prop,
449 provider=prop_add_tmpl,
450 expect=UPDATE)),
451 ('provider_props_remove', dict(template=main_template_remove_prop,
452 provider=prop_remove_tmpl,
Angus Salkeld2bd63a42015-01-07 11:11:29 +1000453 expect=NOCHANGE)),
454 ('provider_attr_change', dict(template=main_template,
455 provider=attr_change_tmpl,
456 expect=NOCHANGE)),
457 ]
458
459 def setUp(self):
460 super(TemplateResourceUpdateTest, self).setUp()
461 self.client = self.orchestration_client
462
463 def test_template_resource_update_template_schema(self):
464 stack_identifier = self.stack_create(
465 template=self.main_template,
466 files={'the.yaml': self.initial_tmpl})
467 stack = self.client.stacks.get(stack_identifier)
468 initial_id = self._stack_output(stack, 'identifier')
469 initial_val = self._stack_output(stack, 'value')
470
471 self.update_stack(stack_identifier,
472 self.template,
473 files={'the.yaml': self.provider})
474 stack = self.client.stacks.get(stack_identifier)
475 self.assertEqual(initial_id,
476 self._stack_output(stack, 'identifier'))
477 if self.expect == self.NOCHANGE:
478 self.assertEqual(initial_val,
479 self._stack_output(stack, 'value'))
480 else:
481 self.assertNotEqual(initial_val,
482 self._stack_output(stack, 'value'))
483
484
Angus Salkeld5a3e1dd2015-02-03 15:31:47 +1000485class TemplateResourceUpdateFailedTest(test.HeatIntegrationTest):
486 """Prove that we can do updates on a nested stack to fix a stack."""
487 main_template = '''
488HeatTemplateFormatVersion: '2012-12-12'
489Resources:
490 keypair:
491 Type: OS::Nova::KeyPair
492 Properties:
493 name: replace-this
494 save_private_key: false
495 server:
496 Type: server_fail.yaml
497 DependsOn: keypair
498'''
499 nested_templ = '''
500HeatTemplateFormatVersion: '2012-12-12'
501Resources:
502 RealRandom:
503 Type: OS::Heat::RandomString
504'''
505
506 def setUp(self):
507 super(TemplateResourceUpdateFailedTest, self).setUp()
508 self.client = self.orchestration_client
Sergey Krayneva265c132015-02-13 03:51:03 -0500509 self.assign_keypair()
Angus Salkeld5a3e1dd2015-02-03 15:31:47 +1000510
511 def test_update_on_failed_create(self):
Vikas Jainac6b02f2015-02-11 11:31:46 -0800512 # create a stack with "server" dependent on "keypair", but
Angus Salkeld5a3e1dd2015-02-03 15:31:47 +1000513 # keypair fails, so "server" is not created properly.
514 # We then fix the template and it should succeed.
515 broken_templ = self.main_template.replace('replace-this',
516 self.keypair_name)
517 stack_identifier = self.stack_create(
518 template=broken_templ,
519 files={'server_fail.yaml': self.nested_templ},
520 expected_status='CREATE_FAILED')
521
522 fixed_templ = self.main_template.replace('replace-this',
523 test.rand_name())
524 self.update_stack(stack_identifier,
525 fixed_templ,
526 files={'server_fail.yaml': self.nested_templ})
527
528
Angus Salkeld2bd63a42015-01-07 11:11:29 +1000529class TemplateResourceAdoptTest(test.HeatIntegrationTest):
530 """Prove that we can do template resource adopt/abandon."""
531
532 main_template = '''
533HeatTemplateFormatVersion: '2012-12-12'
534Resources:
535 the_nested:
536 Type: the.yaml
537 Properties:
538 one: my_name
539Outputs:
540 identifier:
541 Value: {Ref: the_nested}
542 value:
543 Value: {'Fn::GetAtt': [the_nested, the_str]}
544'''
545
546 nested_templ = '''
547HeatTemplateFormatVersion: '2012-12-12'
548Parameters:
549 one:
550 Default: foo
551 Type: String
552Resources:
553 RealRandom:
554 Type: OS::Heat::RandomString
555 Properties:
556 salt: {Ref: one}
557Outputs:
558 the_str:
559 Value: {'Fn::GetAtt': [RealRandom, value]}
560'''
561
562 def setUp(self):
563 super(TemplateResourceAdoptTest, self).setUp()
564 self.client = self.orchestration_client
565
566 def _yaml_to_json(self, yaml_templ):
567 return yaml.load(yaml_templ)
568
569 def test_abandon(self):
Sergey Kraynevbf67ce32015-04-17 10:54:20 -0400570 stack_identifier = self.stack_create(
Angus Salkeld2bd63a42015-01-07 11:11:29 +1000571 template=self.main_template,
572 files={'the.yaml': self.nested_templ},
Sergey Kraynevbf67ce32015-04-17 10:54:20 -0400573 enable_cleanup=False
Angus Salkeld2bd63a42015-01-07 11:11:29 +1000574 )
Angus Salkeld2bd63a42015-01-07 11:11:29 +1000575
Sirushti Murugesan04ee8022015-02-02 23:00:23 +0530576 info = self.stack_abandon(stack_id=stack_identifier)
Angus Salkeld2bd63a42015-01-07 11:11:29 +1000577 self.assertEqual(self._yaml_to_json(self.main_template),
578 info['template'])
579 self.assertEqual(self._yaml_to_json(self.nested_templ),
580 info['resources']['the_nested']['template'])
581
582 def test_adopt(self):
583 data = {
584 'resources': {
585 'the_nested': {
586 "type": "the.yaml",
587 "resources": {
588 "RealRandom": {
589 "type": "OS::Heat::RandomString",
590 'resource_data': {'value': 'goopie'},
591 'resource_id': 'froggy'
592 }
593 }
594 }
595 },
596 "environment": {"parameters": {}},
597 "template": yaml.load(self.main_template)
598 }
599
600 stack_identifier = self.stack_adopt(
601 adopt_data=json.dumps(data),
602 files={'the.yaml': self.nested_templ})
603
604 self.assert_resource_is_a_stack(stack_identifier, 'the_nested')
605 stack = self.client.stacks.get(stack_identifier)
606 self.assertEqual('goopie', self._stack_output(stack, 'value'))
Angus Salkeld87601722015-01-05 14:57:27 +1000607
608
609class TemplateResourceCheckTest(test.HeatIntegrationTest):
610 """Prove that we can do template resource check."""
611
612 main_template = '''
613HeatTemplateFormatVersion: '2012-12-12'
614Resources:
615 the_nested:
616 Type: the.yaml
617 Properties:
618 one: my_name
619Outputs:
620 identifier:
621 Value: {Ref: the_nested}
622 value:
623 Value: {'Fn::GetAtt': [the_nested, the_str]}
624'''
625
626 nested_templ = '''
627HeatTemplateFormatVersion: '2012-12-12'
628Parameters:
629 one:
630 Default: foo
631 Type: String
632Resources:
633 RealRandom:
634 Type: OS::Heat::RandomString
635 Properties:
636 salt: {Ref: one}
637Outputs:
638 the_str:
639 Value: {'Fn::GetAtt': [RealRandom, value]}
640'''
641
642 def setUp(self):
643 super(TemplateResourceCheckTest, self).setUp()
644 self.client = self.orchestration_client
645
646 def test_check(self):
Sergey Kraynevbf67ce32015-04-17 10:54:20 -0400647 stack_identifier = self.stack_create(
Angus Salkeld87601722015-01-05 14:57:27 +1000648 template=self.main_template,
Sergey Kraynevbf67ce32015-04-17 10:54:20 -0400649 files={'the.yaml': self.nested_templ}
Angus Salkeld87601722015-01-05 14:57:27 +1000650 )
Angus Salkeld87601722015-01-05 14:57:27 +1000651
652 self.client.actions.check(stack_id=stack_identifier)
653 self._wait_for_stack_status(stack_identifier, 'CHECK_COMPLETE')
Angus Salkeld793b0fc2015-06-24 08:52:08 +1000654
655
656class TemplateResourceErrorMessageTest(test.HeatIntegrationTest):
657 """Prove that nested stack errors don't suck."""
658 template = '''
659HeatTemplateFormatVersion: '2012-12-12'
660Resources:
661 victim:
662 Type: fail.yaml
663'''
664 nested_templ = '''
665HeatTemplateFormatVersion: '2012-12-12'
666Resources:
667 oops:
668 Type: OS::Heat::TestResource
669 Properties:
670 fail: true
671 wait_secs: 2
672'''
673
674 def setUp(self):
675 super(TemplateResourceErrorMessageTest, self).setUp()
676 self.client = self.orchestration_client
677
678 def test_fail(self):
679 stack_identifier = self.stack_create(
680 template=self.template,
681 files={'fail.yaml': self.nested_templ},
682 expected_status='CREATE_FAILED')
683 stack = self.client.stacks.get(stack_identifier)
684
685 exp_path = 'resources.victim.resources.oops'
686 exp_msg = 'Test Resource failed oops'
687 exp = 'Resource CREATE failed: ValueError: %s: %s' % (exp_path,
688 exp_msg)
689 self.assertEqual(exp, stack.stack_status_reason)
kairat_kushaev61a99e12015-07-31 16:22:45 +0300690
691
692class TemplateResourceSuspendResumeTest(test.HeatIntegrationTest):
693 """Prove that we can do template resource suspend/resume."""
694
695 main_template = '''
696heat_template_version: 2014-10-16
697parameters:
698resources:
699 the_nested:
700 type: the.yaml
701'''
702
703 nested_templ = '''
704heat_template_version: 2014-10-16
705resources:
706 test_random_string:
707 type: OS::Heat::RandomString
708'''
709
710 def setUp(self):
711 super(TemplateResourceSuspendResumeTest, self).setUp()
712 self.client = self.orchestration_client
713
714 def test_suspend_resume(self):
715 """Basic test for template resource suspend resume"""
716 stack_identifier = self.stack_create(
717 template=self.main_template,
718 files={'the.yaml': self.nested_templ}
719 )
720
721 self.stack_suspend(stack_identifier=stack_identifier)
722 self.stack_resume(stack_identifier=stack_identifier)