blob: ebb3c0829e84892dfb06201148d30920da3d2b81 [file] [log] [blame]
huangtianhua99a25de2016-07-26 10:58:33 +08001# 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
13from heat_integrationtests.functional import functional_base
14
15
16cfn_template = '''
17AWSTemplateFormatVersion: 2010-09-09
18Parameters:
19 env_type:
20 Default: test
21 Type: String
22 AllowedValues: [prod, test]
huangtianhua7bdc7512016-06-17 09:25:38 +080023 zone:
24 Type: String
25 Default: beijing
huangtianhua99a25de2016-07-26 10:58:33 +080026Conditions:
27 Prod: {"Fn::Equals" : [{Ref: env_type}, "prod"]}
huangtianhuabf63fcb2016-07-27 13:02:39 +080028 Test:
29 Fn::Not:
30 - Fn::Equals:
31 - Ref: env_type
32 - prod
huangtianhua7bdc7512016-06-17 09:25:38 +080033 Beijing_Prod:
34 Fn::And:
35 - Fn::Equals:
36 - Ref: env_type
37 - prod
38 - Fn::Equals:
39 - Ref: zone
40 - beijing
Zane Bitter1a977c62016-09-08 15:37:51 -040041 Xian_Zone:
42 Fn::Equals:
43 - Ref: zone
44 - xian
45 Xianyang_Zone:
46 Fn::Equals:
47 - Ref: zone
48 - xianyang
huangtianhua26da8982016-07-27 18:11:58 +080049 Fujian_Zone:
50 Fn::Or:
51 - Fn::Equals:
52 - Ref: zone
53 - fuzhou
54 - Fn::Equals:
55 - Ref: zone
56 - xiamen
Zane Bitter1a977c62016-09-08 15:37:51 -040057 Fujian_Prod:
58 Fn::And:
59 - Fujian_Zone
60 - Prod
61 Shannxi_Provice:
62 Fn::Or:
63 - Xian_Zone
64 - Xianyang_Zone
65 Not_Shannxi:
66 Fn::Not: [Shannxi_Provice]
huangtianhua99a25de2016-07-26 10:58:33 +080067Resources:
68 test_res:
69 Type: OS::Heat::TestResource
70 Properties:
huangtianhuafb8b51f2016-02-23 17:03:10 +080071 value: {"Fn::If": ["Prod", "env_is_prod", "env_is_test"]}
huangtianhua99a25de2016-07-26 10:58:33 +080072 prod_res:
73 Type: OS::Heat::TestResource
74 Properties:
75 value: prod_res
76 Condition: Prod
huangtianhuabf63fcb2016-07-27 13:02:39 +080077 test_res1:
78 Type: OS::Heat::TestResource
79 Properties:
80 value: just in test env
81 Condition: Test
huangtianhua7bdc7512016-06-17 09:25:38 +080082 beijing_prod_res:
83 Type: OS::Heat::TestResource
84 Properties:
85 value: beijing_prod_res
86 Condition: Beijing_Prod
huangtianhua26da8982016-07-27 18:11:58 +080087 fujian_res:
88 Type: OS::Heat::TestResource
89 Condition: Fujian_Zone
90 Properties:
91 value: fujian_res
Zane Bitter1a977c62016-09-08 15:37:51 -040092 fujian_prod_res:
93 Type: OS::Heat::TestResource
94 Condition: Fujian_Prod
95 Properties:
96 value: fujian_prod_res
97 shannxi_res:
98 Type: OS::Heat::TestResource
99 Condition: Shannxi_Provice
100 Properties:
101 value: shannxi_res
102 not_shannxi_res:
103 Type: OS::Heat::TestResource
104 Condition: Not_Shannxi
105 Properties:
106 value: not_shannxi_res
huangtianhua27075a92016-07-26 14:32:40 +0800107Outputs:
108 res_value:
109 Value: {"Fn::GetAtt": [prod_res, output]}
110 Condition: Prod
huangtianhuafb8b51f2016-02-23 17:03:10 +0800111 test_res_value:
112 Value: {"Fn::GetAtt": [test_res, output]}
113 prod_resource:
114 Value: {"Fn::If": [Prod, {Ref: prod_res}, 'no_prod_res']}
huangtianhuabf63fcb2016-07-27 13:02:39 +0800115 test_res1_value:
116 Value: {"Fn::If": [Test, {"Fn::GetAtt": [test_res1, output]},
117 'no_test_res1']}
huangtianhua7bdc7512016-06-17 09:25:38 +0800118 beijing_prod_res:
119 Value: {"Fn::If": [Beijing_Prod, {Ref: beijing_prod_res}, 'no_prod_res']}
huangtianhua99a25de2016-07-26 10:58:33 +0800120'''
121
122hot_template = '''
123heat_template_version: 2016-10-14
124parameters:
125 env_type:
126 default: test
127 type: string
128 constraints:
129 - allowed_values: [prod, test]
huangtianhua7bdc7512016-06-17 09:25:38 +0800130 zone:
131 type: string
132 default: beijing
huangtianhua99a25de2016-07-26 10:58:33 +0800133conditions:
134 prod: {equals : [{get_param: env_type}, "prod"]}
huangtianhuabf63fcb2016-07-27 13:02:39 +0800135 test:
136 not:
137 equals:
138 - get_param: env_type
139 - prod
huangtianhua7bdc7512016-06-17 09:25:38 +0800140 beijing_prod:
141 and:
142 - equals:
143 - get_param: zone
144 - beijing
145 - equals:
146 - get_param: env_type
147 - prod
Zane Bitter1a977c62016-09-08 15:37:51 -0400148 xian_zone:
149 equals:
150 - get_param: zone
151 - xian
152 xianyang_zone:
153 equals:
154 - get_param: zone
155 - xianyang
huangtianhua26da8982016-07-27 18:11:58 +0800156 fujian_zone:
157 or:
158 - equals:
159 - get_param: zone
160 - fuzhou
161 - equals:
162 - get_param: zone
163 - xiamen
Zane Bitter1a977c62016-09-08 15:37:51 -0400164 fujian_prod:
165 and:
166 - fujian_zone
167 - prod
168 shannxi_provice:
169 or:
170 - xian_zone
171 - xianyang_zone
172 not_shannxi:
173 not: shannxi_provice
huangtianhua99a25de2016-07-26 10:58:33 +0800174resources:
175 test_res:
176 type: OS::Heat::TestResource
177 properties:
huangtianhuafb8b51f2016-02-23 17:03:10 +0800178 value: {if: ["prod", "env_is_prod", "env_is_test"]}
huangtianhua99a25de2016-07-26 10:58:33 +0800179 prod_res:
180 type: OS::Heat::TestResource
181 properties:
182 value: prod_res
183 condition: prod
huangtianhuabf63fcb2016-07-27 13:02:39 +0800184 test_res1:
185 type: OS::Heat::TestResource
186 properties:
187 value: just in test env
188 condition: test
huangtianhua7bdc7512016-06-17 09:25:38 +0800189 beijing_prod_res:
190 type: OS::Heat::TestResource
191 properties:
192 value: beijing_prod_res
193 condition: beijing_prod
huangtianhua26da8982016-07-27 18:11:58 +0800194 fujian_res:
195 type: OS::Heat::TestResource
196 condition: fujian_zone
197 properties:
198 value: fujian_res
Zane Bitter1a977c62016-09-08 15:37:51 -0400199 fujian_prod_res:
200 type: OS::Heat::TestResource
201 condition: fujian_prod
202 properties:
203 value: fujian_prod_res
204 shannxi_res:
205 type: OS::Heat::TestResource
206 condition: shannxi_provice
207 properties:
208 value: shannxi_res
209 not_shannxi_res:
210 type: OS::Heat::TestResource
211 condition: not_shannxi
212 properties:
213 value: not_shannxi_res
huangtianhua27075a92016-07-26 14:32:40 +0800214outputs:
215 res_value:
216 value: {get_attr: [prod_res, output]}
217 condition: prod
huangtianhuafb8b51f2016-02-23 17:03:10 +0800218 test_res_value:
219 value: {get_attr: [test_res, output]}
220 prod_resource:
221 value: {if: [prod, {get_resource: prod_res}, 'no_prod_res']}
huangtianhuabf63fcb2016-07-27 13:02:39 +0800222 test_res1_value:
223 value: {if: [test, {get_attr: [test_res1, output]}, 'no_test_res1']}
huangtianhua7bdc7512016-06-17 09:25:38 +0800224 beijing_prod_res:
225 value: {if: [beijing_prod, {get_resource: beijing_prod_res},
226 'no_prod_res']}
huangtianhua99a25de2016-07-26 10:58:33 +0800227'''
228
Zane Bittera9b5aaf2016-09-12 20:51:52 -0400229before_rename_tmpl = '''
230heat_template_version: 2016-10-14
231parameters:
232 env_type:
233 default: test
234 type: string
235conditions:
236 cd1: {equals : [{get_param: env_type}, "prod"]}
237resources:
238 test:
239 type: OS::Heat::TestResource
240 properties:
241 value: {if: [cd1, 'prod', 'test']}
242'''
243
244after_rename_tmpl = '''
245heat_template_version: 2016-10-14
246parameters:
247 env_type:
248 default: prod
249 type: string
250conditions:
251 cd2: {equals : [{get_param: env_type}, "prod"]}
252resources:
253 test:
254 type: OS::Heat::TestResource
255 properties:
256 value: {if: [cd2, 'prod', 'test']}
257 test2:
258 type: OS::Heat::TestResource
259 properties:
260 value: {if: [cd2, 'prod', 'test']}
261'''
262
263fail_rename_tmpl = '''
264heat_template_version: 2016-10-14
265parameters:
266 env_type:
267 default: prod
268 type: string
269conditions:
270 cd3: {equals : [{get_param: env_type}, "prod"]}
271resources:
272 test:
273 type: OS::Heat::TestResource
274 properties:
275 value: {if: [cd3, 'prod', 'test']}
276 test2:
277 type: OS::Heat::TestResource
278 properties:
279 value: {if: [cd3, 'prod', 'test']}
280 test_fail:
281 type: OS::Heat::TestResource
282 properties:
283 fail: True
284 depends_on: [test, test2]
285'''
286
287recover_rename_tmpl = '''
288heat_template_version: 2016-10-14
289parameters:
290 env_type:
291 default: prod
292 type: string
293conditions:
294 cd3: {equals : [{get_param: env_type}, "prod"]}
295resources:
296 test2:
297 type: OS::Heat::TestResource
298 properties:
299 value: {if: [cd3, 'prod', 'test']}
300 test_fail:
301 type: OS::Heat::TestResource
302 properties:
303 fail: False
304 depends_on: [test2]
305'''
306
huangtianhua99a25de2016-07-26 10:58:33 +0800307
308class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
309
Zane Bitter1a977c62016-09-08 15:37:51 -0400310 def res_assert_for_prod(self, resources, bj_prod=True, fj_zone=False,
311 shannxi_provice=False):
huangtianhua99a25de2016-07-26 10:58:33 +0800312 res_names = [res.resource_name for res in resources]
huangtianhua7bdc7512016-06-17 09:25:38 +0800313 if bj_prod:
Zane Bitter1a977c62016-09-08 15:37:51 -0400314 self.assertEqual(4, len(resources))
huangtianhua7bdc7512016-06-17 09:25:38 +0800315 self.assertIn('beijing_prod_res', res_names)
Zane Bitter1a977c62016-09-08 15:37:51 -0400316 self.assertIn('not_shannxi_res', res_names)
huangtianhua26da8982016-07-27 18:11:58 +0800317 elif fj_zone:
Zane Bitter1a977c62016-09-08 15:37:51 -0400318 self.assertEqual(5, len(resources))
huangtianhua26da8982016-07-27 18:11:58 +0800319 self.assertIn('fujian_res', res_names)
320 self.assertNotIn('beijing_prod_res', res_names)
Zane Bitter1a977c62016-09-08 15:37:51 -0400321 self.assertIn('not_shannxi_res', res_names)
322 self.assertIn('fujian_prod_res', res_names)
323 elif shannxi_provice:
324 self.assertEqual(3, len(resources))
325 self.assertIn('shannxi_res', res_names)
huangtianhua7bdc7512016-06-17 09:25:38 +0800326 else:
Zane Bitter1a977c62016-09-08 15:37:51 -0400327 self.assertEqual(3, len(resources))
328 self.assertIn('not_shannxi_res', res_names)
huangtianhua99a25de2016-07-26 10:58:33 +0800329 self.assertIn('prod_res', res_names)
330 self.assertIn('test_res', res_names)
331
Zane Bitter1a977c62016-09-08 15:37:51 -0400332 def res_assert_for_test(self, resources, fj_zone=False,
333 shannxi_provice=False):
huangtianhua99a25de2016-07-26 10:58:33 +0800334 res_names = [res.resource_name for res in resources]
huangtianhua26da8982016-07-27 18:11:58 +0800335
336 if fj_zone:
Zane Bitter1a977c62016-09-08 15:37:51 -0400337 self.assertEqual(4, len(resources))
huangtianhua26da8982016-07-27 18:11:58 +0800338 self.assertIn('fujian_res', res_names)
Zane Bitter1a977c62016-09-08 15:37:51 -0400339 self.assertIn('not_shannxi_res', res_names)
340 elif shannxi_provice:
341 self.assertEqual(3, len(resources))
Zane Bitteree582d92016-09-08 11:33:46 -0400342 self.assertNotIn('fujian_res', res_names)
Zane Bitter1a977c62016-09-08 15:37:51 -0400343 self.assertIn('shannxi_res', res_names)
344 else:
345 self.assertEqual(3, len(resources))
346 self.assertIn('not_shannxi_res', res_names)
huangtianhua99a25de2016-07-26 10:58:33 +0800347 self.assertIn('test_res', res_names)
huangtianhuabf63fcb2016-07-27 13:02:39 +0800348 self.assertIn('test_res1', res_names)
huangtianhua99a25de2016-07-26 10:58:33 +0800349 self.assertNotIn('prod_res', res_names)
350
huangtianhua7bdc7512016-06-17 09:25:38 +0800351 def output_assert_for_prod(self, stack_id, bj_prod=True):
huangtianhua27075a92016-07-26 14:32:40 +0800352 output = self.client.stacks.output_show(stack_id,
353 'res_value')['output']
354 self.assertEqual('prod_res', output['output_value'])
355
huangtianhuafb8b51f2016-02-23 17:03:10 +0800356 test_res_value = self.client.stacks.output_show(
357 stack_id, 'test_res_value')['output']
358 self.assertEqual('env_is_prod', test_res_value['output_value'])
359
360 prod_resource = self.client.stacks.output_show(
361 stack_id, 'prod_resource')['output']
362 self.assertNotEqual('no_prod_res', prod_resource['output_value'])
363
huangtianhuabf63fcb2016-07-27 13:02:39 +0800364 test_res_output = self.client.stacks.output_show(
365 stack_id, 'test_res1_value')['output']
366 self.assertEqual('no_test_res1', test_res_output['output_value'])
367
huangtianhua7bdc7512016-06-17 09:25:38 +0800368 beijing_prod_res = self.client.stacks.output_show(
369 stack_id, 'beijing_prod_res')['output']
370 if bj_prod:
371 self.assertNotEqual('no_prod_res',
372 beijing_prod_res['output_value'])
373 else:
374 self.assertEqual('no_prod_res', beijing_prod_res['output_value'])
375
huangtianhua27075a92016-07-26 14:32:40 +0800376 def output_assert_for_test(self, stack_id):
377 output = self.client.stacks.output_show(stack_id,
378 'res_value')['output']
379 self.assertIsNone(output['output_value'])
380
huangtianhuafb8b51f2016-02-23 17:03:10 +0800381 test_res_value = self.client.stacks.output_show(
382 stack_id, 'test_res_value')['output']
383 self.assertEqual('env_is_test', test_res_value['output_value'])
384
385 prod_resource = self.client.stacks.output_show(
386 stack_id, 'prod_resource')['output']
387 self.assertEqual('no_prod_res', prod_resource['output_value'])
388
huangtianhuabf63fcb2016-07-27 13:02:39 +0800389 test_res_output = self.client.stacks.output_show(
390 stack_id, 'test_res1_value')['output']
391 self.assertEqual('just in test env',
392 test_res_output['output_value'])
393
huangtianhua7bdc7512016-06-17 09:25:38 +0800394 beijing_prod_res = self.client.stacks.output_show(
395 stack_id, 'beijing_prod_res')['output']
396 self.assertEqual('no_prod_res', beijing_prod_res['output_value'])
397
huangtianhua99a25de2016-07-26 10:58:33 +0800398 def test_stack_create_update_cfn_template_test_to_prod(self):
399 stack_identifier = self.stack_create(template=cfn_template)
400 resources = self.client.resources.list(stack_identifier)
401 self.res_assert_for_test(resources)
huangtianhua27075a92016-07-26 14:32:40 +0800402 self.output_assert_for_test(stack_identifier)
huangtianhua99a25de2016-07-26 10:58:33 +0800403
huangtianhua26da8982016-07-27 18:11:58 +0800404 parms = {'zone': 'fuzhou'}
405 self.update_stack(stack_identifier,
406 template=cfn_template,
407 parameters=parms)
408
409 resources = self.client.resources.list(stack_identifier)
410 self.res_assert_for_test(resources, fj_zone=True)
411 self.output_assert_for_test(stack_identifier)
412
Zane Bitter1a977c62016-09-08 15:37:51 -0400413 parms = {'zone': 'xianyang'}
414 self.update_stack(stack_identifier,
415 template=cfn_template,
416 parameters=parms)
417
418 resources = self.client.resources.list(stack_identifier)
419 self.res_assert_for_test(resources, shannxi_provice=True)
420 self.output_assert_for_test(stack_identifier)
421
huangtianhua99a25de2016-07-26 10:58:33 +0800422 parms = {'env_type': 'prod'}
423 self.update_stack(stack_identifier,
424 template=cfn_template,
425 parameters=parms)
426
427 resources = self.client.resources.list(stack_identifier)
428 self.res_assert_for_prod(resources)
huangtianhua27075a92016-07-26 14:32:40 +0800429 self.output_assert_for_prod(stack_identifier)
huangtianhua99a25de2016-07-26 10:58:33 +0800430
huangtianhua7bdc7512016-06-17 09:25:38 +0800431 parms = {'env_type': 'prod',
432 'zone': 'shanghai'}
433 self.update_stack(stack_identifier,
434 template=cfn_template,
435 parameters=parms)
436
437 resources = self.client.resources.list(stack_identifier)
438 self.res_assert_for_prod(resources, False)
439 self.output_assert_for_prod(stack_identifier, False)
440
huangtianhua26da8982016-07-27 18:11:58 +0800441 parms = {'env_type': 'prod',
442 'zone': 'xiamen'}
443 self.update_stack(stack_identifier,
444 template=cfn_template,
445 parameters=parms)
446
447 resources = self.client.resources.list(stack_identifier)
448 self.res_assert_for_prod(resources, bj_prod=False, fj_zone=True)
449 self.output_assert_for_prod(stack_identifier, False)
450
Zane Bitter1a977c62016-09-08 15:37:51 -0400451 parms = {'env_type': 'prod',
452 'zone': 'xianyang'}
453 self.update_stack(stack_identifier,
454 template=cfn_template,
455 parameters=parms)
456
457 resources = self.client.resources.list(stack_identifier)
458 self.res_assert_for_prod(resources, bj_prod=False, fj_zone=False,
459 shannxi_provice=True)
460 self.output_assert_for_prod(stack_identifier, False)
461
huangtianhua99a25de2016-07-26 10:58:33 +0800462 def test_stack_create_update_cfn_template_prod_to_test(self):
463 parms = {'env_type': 'prod'}
464 stack_identifier = self.stack_create(template=cfn_template,
465 parameters=parms)
466 resources = self.client.resources.list(stack_identifier)
467 self.res_assert_for_prod(resources)
huangtianhua27075a92016-07-26 14:32:40 +0800468 self.output_assert_for_prod(stack_identifier)
huangtianhua99a25de2016-07-26 10:58:33 +0800469
huangtianhua26da8982016-07-27 18:11:58 +0800470 parms = {'zone': 'xiamen',
471 'env_type': 'prod'}
472 self.update_stack(stack_identifier,
473 template=cfn_template,
474 parameters=parms)
475
476 resources = self.client.resources.list(stack_identifier)
477 self.res_assert_for_prod(resources, bj_prod=False, fj_zone=True)
478 self.output_assert_for_prod(stack_identifier, bj_prod=False)
479
Zane Bitter1a977c62016-09-08 15:37:51 -0400480 parms = {'zone': 'xianyang',
481 'env_type': 'prod'}
482 self.update_stack(stack_identifier,
483 template=cfn_template,
484 parameters=parms)
485
486 resources = self.client.resources.list(stack_identifier)
487 self.res_assert_for_prod(resources, bj_prod=False, fj_zone=False,
488 shannxi_provice=True)
489 self.output_assert_for_prod(stack_identifier, bj_prod=False)
490
491 parms = {'zone': 'shanghai',
492 'env_type': 'prod'}
493 self.update_stack(stack_identifier,
494 template=cfn_template,
495 parameters=parms)
496
497 resources = self.client.resources.list(stack_identifier)
498 self.res_assert_for_prod(resources, bj_prod=False, fj_zone=False,
499 shannxi_provice=False)
500 self.output_assert_for_prod(stack_identifier, bj_prod=False)
501
huangtianhua99a25de2016-07-26 10:58:33 +0800502 parms = {'env_type': 'test'}
503 self.update_stack(stack_identifier,
504 template=cfn_template,
505 parameters=parms)
506
507 resources = self.client.resources.list(stack_identifier)
508 self.res_assert_for_test(resources)
huangtianhua27075a92016-07-26 14:32:40 +0800509 self.output_assert_for_test(stack_identifier)
huangtianhua99a25de2016-07-26 10:58:33 +0800510
huangtianhua26da8982016-07-27 18:11:58 +0800511 parms = {'env_type': 'test',
512 'zone': 'fuzhou'}
513 self.update_stack(stack_identifier,
514 template=cfn_template,
515 parameters=parms)
516
517 resources = self.client.resources.list(stack_identifier)
518 self.res_assert_for_test(resources, fj_zone=True)
519 self.output_assert_for_test(stack_identifier)
520
Zane Bitter1a977c62016-09-08 15:37:51 -0400521 parms = {'env_type': 'test',
522 'zone': 'xianyang'}
523 self.update_stack(stack_identifier,
524 template=cfn_template,
525 parameters=parms)
526
527 resources = self.client.resources.list(stack_identifier)
528 self.res_assert_for_test(resources, fj_zone=False,
529 shannxi_provice=True)
530 self.output_assert_for_test(stack_identifier)
531
huangtianhua99a25de2016-07-26 10:58:33 +0800532 def test_stack_create_update_hot_template_test_to_prod(self):
533 stack_identifier = self.stack_create(template=hot_template)
534 resources = self.client.resources.list(stack_identifier)
535 self.res_assert_for_test(resources)
huangtianhua27075a92016-07-26 14:32:40 +0800536 self.output_assert_for_test(stack_identifier)
huangtianhua99a25de2016-07-26 10:58:33 +0800537
Zane Bitter1a977c62016-09-08 15:37:51 -0400538 parms = {'zone': 'xianyang'}
539 self.update_stack(stack_identifier,
540 template=hot_template,
541 parameters=parms)
542
543 resources = self.client.resources.list(stack_identifier)
544 self.res_assert_for_test(resources, shannxi_provice=True)
545 self.output_assert_for_test(stack_identifier)
546
huangtianhua99a25de2016-07-26 10:58:33 +0800547 parms = {'env_type': 'prod'}
548 self.update_stack(stack_identifier,
549 template=hot_template,
550 parameters=parms)
551
552 resources = self.client.resources.list(stack_identifier)
553 self.res_assert_for_prod(resources)
huangtianhua27075a92016-07-26 14:32:40 +0800554 self.output_assert_for_prod(stack_identifier)
huangtianhua99a25de2016-07-26 10:58:33 +0800555
huangtianhua7bdc7512016-06-17 09:25:38 +0800556 parms = {'env_type': 'prod',
557 'zone': 'shanghai'}
558 self.update_stack(stack_identifier,
559 template=hot_template,
560 parameters=parms)
561
562 resources = self.client.resources.list(stack_identifier)
563 self.res_assert_for_prod(resources, False)
564 self.output_assert_for_prod(stack_identifier, False)
565
Zane Bitter1a977c62016-09-08 15:37:51 -0400566 parms = {'env_type': 'prod',
567 'zone': 'xianyang'}
568 self.update_stack(stack_identifier,
569 template=hot_template,
570 parameters=parms)
571
572 resources = self.client.resources.list(stack_identifier)
573 self.res_assert_for_prod(resources, False, shannxi_provice=True)
574 self.output_assert_for_prod(stack_identifier, False)
575
huangtianhua99a25de2016-07-26 10:58:33 +0800576 def test_stack_create_update_hot_template_prod_to_test(self):
577 parms = {'env_type': 'prod'}
578 stack_identifier = self.stack_create(template=hot_template,
579 parameters=parms)
580 resources = self.client.resources.list(stack_identifier)
581 self.res_assert_for_prod(resources)
huangtianhua27075a92016-07-26 14:32:40 +0800582 self.output_assert_for_prod(stack_identifier)
huangtianhua99a25de2016-07-26 10:58:33 +0800583
Zane Bitter1a977c62016-09-08 15:37:51 -0400584 parms = {'env_type': 'prod',
585 'zone': 'xianyang'}
586 self.update_stack(stack_identifier,
587 template=hot_template,
588 parameters=parms)
589
590 resources = self.client.resources.list(stack_identifier)
591 self.res_assert_for_prod(resources, False, shannxi_provice=True)
592 self.output_assert_for_prod(stack_identifier, False)
593
huangtianhua99a25de2016-07-26 10:58:33 +0800594 parms = {'env_type': 'test'}
595 self.update_stack(stack_identifier,
596 template=hot_template,
597 parameters=parms)
598
599 resources = self.client.resources.list(stack_identifier)
600 self.res_assert_for_test(resources)
huangtianhua27075a92016-07-26 14:32:40 +0800601 self.output_assert_for_test(stack_identifier)
Zane Bittera9b5aaf2016-09-12 20:51:52 -0400602
Zane Bitter1a977c62016-09-08 15:37:51 -0400603 parms = {'env_type': 'test',
604 'zone': 'xianyang'}
605 self.update_stack(stack_identifier,
606 template=hot_template,
607 parameters=parms)
608
609 resources = self.client.resources.list(stack_identifier)
610 self.res_assert_for_test(resources, fj_zone=False,
611 shannxi_provice=True)
612 self.output_assert_for_test(stack_identifier)
613
Zane Bittera9b5aaf2016-09-12 20:51:52 -0400614 def test_condition_rename(self):
615 stack_identifier = self.stack_create(template=before_rename_tmpl)
616 self.update_stack(stack_identifier, template=after_rename_tmpl)
617 self.update_stack(stack_identifier, template=fail_rename_tmpl,
618 expected_status='UPDATE_FAILED')
619 self.update_stack(stack_identifier, template=recover_rename_tmpl)