huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 1 | # 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 | from heat_integrationtests.functional import functional_base |
| 14 | |
| 15 | |
| 16 | cfn_template = ''' |
| 17 | AWSTemplateFormatVersion: 2010-09-09 |
| 18 | Parameters: |
| 19 | env_type: |
| 20 | Default: test |
| 21 | Type: String |
| 22 | AllowedValues: [prod, test] |
huangtianhua | 7bdc751 | 2016-06-17 09:25:38 +0800 | [diff] [blame] | 23 | zone: |
| 24 | Type: String |
| 25 | Default: beijing |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 26 | Conditions: |
| 27 | Prod: {"Fn::Equals" : [{Ref: env_type}, "prod"]} |
huangtianhua | bf63fcb | 2016-07-27 13:02:39 +0800 | [diff] [blame] | 28 | Test: |
| 29 | Fn::Not: |
| 30 | - Fn::Equals: |
| 31 | - Ref: env_type |
| 32 | - prod |
huangtianhua | 7bdc751 | 2016-06-17 09:25:38 +0800 | [diff] [blame] | 33 | Beijing_Prod: |
| 34 | Fn::And: |
| 35 | - Fn::Equals: |
| 36 | - Ref: env_type |
| 37 | - prod |
| 38 | - Fn::Equals: |
| 39 | - Ref: zone |
| 40 | - beijing |
huangtianhua | 26da898 | 2016-07-27 18:11:58 +0800 | [diff] [blame] | 41 | Fujian_Zone: |
| 42 | Fn::Or: |
| 43 | - Fn::Equals: |
| 44 | - Ref: zone |
| 45 | - fuzhou |
| 46 | - Fn::Equals: |
| 47 | - Ref: zone |
| 48 | - xiamen |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 49 | Resources: |
| 50 | test_res: |
| 51 | Type: OS::Heat::TestResource |
| 52 | Properties: |
huangtianhua | fb8b51f | 2016-02-23 17:03:10 +0800 | [diff] [blame] | 53 | value: {"Fn::If": ["Prod", "env_is_prod", "env_is_test"]} |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 54 | prod_res: |
| 55 | Type: OS::Heat::TestResource |
| 56 | Properties: |
| 57 | value: prod_res |
| 58 | Condition: Prod |
huangtianhua | bf63fcb | 2016-07-27 13:02:39 +0800 | [diff] [blame] | 59 | test_res1: |
| 60 | Type: OS::Heat::TestResource |
| 61 | Properties: |
| 62 | value: just in test env |
| 63 | Condition: Test |
huangtianhua | 7bdc751 | 2016-06-17 09:25:38 +0800 | [diff] [blame] | 64 | beijing_prod_res: |
| 65 | Type: OS::Heat::TestResource |
| 66 | Properties: |
| 67 | value: beijing_prod_res |
| 68 | Condition: Beijing_Prod |
huangtianhua | 26da898 | 2016-07-27 18:11:58 +0800 | [diff] [blame] | 69 | fujian_res: |
| 70 | Type: OS::Heat::TestResource |
| 71 | Condition: Fujian_Zone |
| 72 | Properties: |
| 73 | value: fujian_res |
huangtianhua | 27075a9 | 2016-07-26 14:32:40 +0800 | [diff] [blame] | 74 | Outputs: |
| 75 | res_value: |
| 76 | Value: {"Fn::GetAtt": [prod_res, output]} |
| 77 | Condition: Prod |
huangtianhua | fb8b51f | 2016-02-23 17:03:10 +0800 | [diff] [blame] | 78 | test_res_value: |
| 79 | Value: {"Fn::GetAtt": [test_res, output]} |
| 80 | prod_resource: |
| 81 | Value: {"Fn::If": [Prod, {Ref: prod_res}, 'no_prod_res']} |
huangtianhua | bf63fcb | 2016-07-27 13:02:39 +0800 | [diff] [blame] | 82 | test_res1_value: |
| 83 | Value: {"Fn::If": [Test, {"Fn::GetAtt": [test_res1, output]}, |
| 84 | 'no_test_res1']} |
huangtianhua | 7bdc751 | 2016-06-17 09:25:38 +0800 | [diff] [blame] | 85 | beijing_prod_res: |
| 86 | Value: {"Fn::If": [Beijing_Prod, {Ref: beijing_prod_res}, 'no_prod_res']} |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 87 | ''' |
| 88 | |
| 89 | hot_template = ''' |
| 90 | heat_template_version: 2016-10-14 |
| 91 | parameters: |
| 92 | env_type: |
| 93 | default: test |
| 94 | type: string |
| 95 | constraints: |
| 96 | - allowed_values: [prod, test] |
huangtianhua | 7bdc751 | 2016-06-17 09:25:38 +0800 | [diff] [blame] | 97 | zone: |
| 98 | type: string |
| 99 | default: beijing |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 100 | conditions: |
| 101 | prod: {equals : [{get_param: env_type}, "prod"]} |
huangtianhua | bf63fcb | 2016-07-27 13:02:39 +0800 | [diff] [blame] | 102 | test: |
| 103 | not: |
| 104 | equals: |
| 105 | - get_param: env_type |
| 106 | - prod |
huangtianhua | 7bdc751 | 2016-06-17 09:25:38 +0800 | [diff] [blame] | 107 | beijing_prod: |
| 108 | and: |
| 109 | - equals: |
| 110 | - get_param: zone |
| 111 | - beijing |
| 112 | - equals: |
| 113 | - get_param: env_type |
| 114 | - prod |
huangtianhua | 26da898 | 2016-07-27 18:11:58 +0800 | [diff] [blame] | 115 | fujian_zone: |
| 116 | or: |
| 117 | - equals: |
| 118 | - get_param: zone |
| 119 | - fuzhou |
| 120 | - equals: |
| 121 | - get_param: zone |
| 122 | - xiamen |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 123 | resources: |
| 124 | test_res: |
| 125 | type: OS::Heat::TestResource |
| 126 | properties: |
huangtianhua | fb8b51f | 2016-02-23 17:03:10 +0800 | [diff] [blame] | 127 | value: {if: ["prod", "env_is_prod", "env_is_test"]} |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 128 | prod_res: |
| 129 | type: OS::Heat::TestResource |
| 130 | properties: |
| 131 | value: prod_res |
| 132 | condition: prod |
huangtianhua | bf63fcb | 2016-07-27 13:02:39 +0800 | [diff] [blame] | 133 | test_res1: |
| 134 | type: OS::Heat::TestResource |
| 135 | properties: |
| 136 | value: just in test env |
| 137 | condition: test |
huangtianhua | 7bdc751 | 2016-06-17 09:25:38 +0800 | [diff] [blame] | 138 | beijing_prod_res: |
| 139 | type: OS::Heat::TestResource |
| 140 | properties: |
| 141 | value: beijing_prod_res |
| 142 | condition: beijing_prod |
huangtianhua | 26da898 | 2016-07-27 18:11:58 +0800 | [diff] [blame] | 143 | fujian_res: |
| 144 | type: OS::Heat::TestResource |
| 145 | condition: fujian_zone |
| 146 | properties: |
| 147 | value: fujian_res |
huangtianhua | 27075a9 | 2016-07-26 14:32:40 +0800 | [diff] [blame] | 148 | outputs: |
| 149 | res_value: |
| 150 | value: {get_attr: [prod_res, output]} |
| 151 | condition: prod |
huangtianhua | fb8b51f | 2016-02-23 17:03:10 +0800 | [diff] [blame] | 152 | test_res_value: |
| 153 | value: {get_attr: [test_res, output]} |
| 154 | prod_resource: |
| 155 | value: {if: [prod, {get_resource: prod_res}, 'no_prod_res']} |
huangtianhua | bf63fcb | 2016-07-27 13:02:39 +0800 | [diff] [blame] | 156 | test_res1_value: |
| 157 | value: {if: [test, {get_attr: [test_res1, output]}, 'no_test_res1']} |
huangtianhua | 7bdc751 | 2016-06-17 09:25:38 +0800 | [diff] [blame] | 158 | beijing_prod_res: |
| 159 | value: {if: [beijing_prod, {get_resource: beijing_prod_res}, |
| 160 | 'no_prod_res']} |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 161 | ''' |
| 162 | |
Zane Bitter | a9b5aaf | 2016-09-12 20:51:52 -0400 | [diff] [blame^] | 163 | before_rename_tmpl = ''' |
| 164 | heat_template_version: 2016-10-14 |
| 165 | parameters: |
| 166 | env_type: |
| 167 | default: test |
| 168 | type: string |
| 169 | conditions: |
| 170 | cd1: {equals : [{get_param: env_type}, "prod"]} |
| 171 | resources: |
| 172 | test: |
| 173 | type: OS::Heat::TestResource |
| 174 | properties: |
| 175 | value: {if: [cd1, 'prod', 'test']} |
| 176 | ''' |
| 177 | |
| 178 | after_rename_tmpl = ''' |
| 179 | heat_template_version: 2016-10-14 |
| 180 | parameters: |
| 181 | env_type: |
| 182 | default: prod |
| 183 | type: string |
| 184 | conditions: |
| 185 | cd2: {equals : [{get_param: env_type}, "prod"]} |
| 186 | resources: |
| 187 | test: |
| 188 | type: OS::Heat::TestResource |
| 189 | properties: |
| 190 | value: {if: [cd2, 'prod', 'test']} |
| 191 | test2: |
| 192 | type: OS::Heat::TestResource |
| 193 | properties: |
| 194 | value: {if: [cd2, 'prod', 'test']} |
| 195 | ''' |
| 196 | |
| 197 | fail_rename_tmpl = ''' |
| 198 | heat_template_version: 2016-10-14 |
| 199 | parameters: |
| 200 | env_type: |
| 201 | default: prod |
| 202 | type: string |
| 203 | conditions: |
| 204 | cd3: {equals : [{get_param: env_type}, "prod"]} |
| 205 | resources: |
| 206 | test: |
| 207 | type: OS::Heat::TestResource |
| 208 | properties: |
| 209 | value: {if: [cd3, 'prod', 'test']} |
| 210 | test2: |
| 211 | type: OS::Heat::TestResource |
| 212 | properties: |
| 213 | value: {if: [cd3, 'prod', 'test']} |
| 214 | test_fail: |
| 215 | type: OS::Heat::TestResource |
| 216 | properties: |
| 217 | fail: True |
| 218 | depends_on: [test, test2] |
| 219 | ''' |
| 220 | |
| 221 | recover_rename_tmpl = ''' |
| 222 | heat_template_version: 2016-10-14 |
| 223 | parameters: |
| 224 | env_type: |
| 225 | default: prod |
| 226 | type: string |
| 227 | conditions: |
| 228 | cd3: {equals : [{get_param: env_type}, "prod"]} |
| 229 | resources: |
| 230 | test2: |
| 231 | type: OS::Heat::TestResource |
| 232 | properties: |
| 233 | value: {if: [cd3, 'prod', 'test']} |
| 234 | test_fail: |
| 235 | type: OS::Heat::TestResource |
| 236 | properties: |
| 237 | fail: False |
| 238 | depends_on: [test2] |
| 239 | ''' |
| 240 | |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 241 | |
| 242 | class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase): |
| 243 | |
| 244 | def setUp(self): |
| 245 | super(CreateUpdateResConditionTest, self).setUp() |
| 246 | |
Zane Bitter | ee582d9 | 2016-09-08 11:33:46 -0400 | [diff] [blame] | 247 | def res_assert_for_prod(self, resources, bj_prod=True, fj_zone=False): |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 248 | res_names = [res.resource_name for res in resources] |
huangtianhua | 7bdc751 | 2016-06-17 09:25:38 +0800 | [diff] [blame] | 249 | if bj_prod: |
Zane Bitter | ee582d9 | 2016-09-08 11:33:46 -0400 | [diff] [blame] | 250 | self.assertEqual(3, len(resources)) |
huangtianhua | 7bdc751 | 2016-06-17 09:25:38 +0800 | [diff] [blame] | 251 | self.assertIn('beijing_prod_res', res_names) |
huangtianhua | 26da898 | 2016-07-27 18:11:58 +0800 | [diff] [blame] | 252 | elif fj_zone: |
Zane Bitter | ee582d9 | 2016-09-08 11:33:46 -0400 | [diff] [blame] | 253 | self.assertEqual(3, len(resources)) |
huangtianhua | 26da898 | 2016-07-27 18:11:58 +0800 | [diff] [blame] | 254 | self.assertIn('fujian_res', res_names) |
| 255 | self.assertNotIn('beijing_prod_res', res_names) |
huangtianhua | 7bdc751 | 2016-06-17 09:25:38 +0800 | [diff] [blame] | 256 | else: |
Zane Bitter | ee582d9 | 2016-09-08 11:33:46 -0400 | [diff] [blame] | 257 | self.assertEqual(2, len(resources)) |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 258 | self.assertIn('prod_res', res_names) |
| 259 | self.assertIn('test_res', res_names) |
| 260 | |
Zane Bitter | ee582d9 | 2016-09-08 11:33:46 -0400 | [diff] [blame] | 261 | def res_assert_for_test(self, resources, fj_zone=False): |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 262 | res_names = [res.resource_name for res in resources] |
huangtianhua | 26da898 | 2016-07-27 18:11:58 +0800 | [diff] [blame] | 263 | |
| 264 | if fj_zone: |
Zane Bitter | ee582d9 | 2016-09-08 11:33:46 -0400 | [diff] [blame] | 265 | self.assertEqual(3, len(resources)) |
huangtianhua | 26da898 | 2016-07-27 18:11:58 +0800 | [diff] [blame] | 266 | self.assertIn('fujian_res', res_names) |
huangtianhua | e436574 | 2016-08-30 10:27:21 +0800 | [diff] [blame] | 267 | else: |
Zane Bitter | ee582d9 | 2016-09-08 11:33:46 -0400 | [diff] [blame] | 268 | self.assertEqual(2, len(resources)) |
| 269 | self.assertNotIn('fujian_res', res_names) |
| 270 | |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 271 | self.assertIn('test_res', res_names) |
huangtianhua | bf63fcb | 2016-07-27 13:02:39 +0800 | [diff] [blame] | 272 | self.assertIn('test_res1', res_names) |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 273 | self.assertNotIn('prod_res', res_names) |
| 274 | |
huangtianhua | 7bdc751 | 2016-06-17 09:25:38 +0800 | [diff] [blame] | 275 | def output_assert_for_prod(self, stack_id, bj_prod=True): |
huangtianhua | 27075a9 | 2016-07-26 14:32:40 +0800 | [diff] [blame] | 276 | output = self.client.stacks.output_show(stack_id, |
| 277 | 'res_value')['output'] |
| 278 | self.assertEqual('prod_res', output['output_value']) |
| 279 | |
huangtianhua | fb8b51f | 2016-02-23 17:03:10 +0800 | [diff] [blame] | 280 | test_res_value = self.client.stacks.output_show( |
| 281 | stack_id, 'test_res_value')['output'] |
| 282 | self.assertEqual('env_is_prod', test_res_value['output_value']) |
| 283 | |
| 284 | prod_resource = self.client.stacks.output_show( |
| 285 | stack_id, 'prod_resource')['output'] |
| 286 | self.assertNotEqual('no_prod_res', prod_resource['output_value']) |
| 287 | |
huangtianhua | bf63fcb | 2016-07-27 13:02:39 +0800 | [diff] [blame] | 288 | test_res_output = self.client.stacks.output_show( |
| 289 | stack_id, 'test_res1_value')['output'] |
| 290 | self.assertEqual('no_test_res1', test_res_output['output_value']) |
| 291 | |
huangtianhua | 7bdc751 | 2016-06-17 09:25:38 +0800 | [diff] [blame] | 292 | beijing_prod_res = self.client.stacks.output_show( |
| 293 | stack_id, 'beijing_prod_res')['output'] |
| 294 | if bj_prod: |
| 295 | self.assertNotEqual('no_prod_res', |
| 296 | beijing_prod_res['output_value']) |
| 297 | else: |
| 298 | self.assertEqual('no_prod_res', beijing_prod_res['output_value']) |
| 299 | |
huangtianhua | 27075a9 | 2016-07-26 14:32:40 +0800 | [diff] [blame] | 300 | def output_assert_for_test(self, stack_id): |
| 301 | output = self.client.stacks.output_show(stack_id, |
| 302 | 'res_value')['output'] |
| 303 | self.assertIsNone(output['output_value']) |
| 304 | |
huangtianhua | fb8b51f | 2016-02-23 17:03:10 +0800 | [diff] [blame] | 305 | test_res_value = self.client.stacks.output_show( |
| 306 | stack_id, 'test_res_value')['output'] |
| 307 | self.assertEqual('env_is_test', test_res_value['output_value']) |
| 308 | |
| 309 | prod_resource = self.client.stacks.output_show( |
| 310 | stack_id, 'prod_resource')['output'] |
| 311 | self.assertEqual('no_prod_res', prod_resource['output_value']) |
| 312 | |
huangtianhua | bf63fcb | 2016-07-27 13:02:39 +0800 | [diff] [blame] | 313 | test_res_output = self.client.stacks.output_show( |
| 314 | stack_id, 'test_res1_value')['output'] |
| 315 | self.assertEqual('just in test env', |
| 316 | test_res_output['output_value']) |
| 317 | |
huangtianhua | 7bdc751 | 2016-06-17 09:25:38 +0800 | [diff] [blame] | 318 | beijing_prod_res = self.client.stacks.output_show( |
| 319 | stack_id, 'beijing_prod_res')['output'] |
| 320 | self.assertEqual('no_prod_res', beijing_prod_res['output_value']) |
| 321 | |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 322 | def test_stack_create_update_cfn_template_test_to_prod(self): |
| 323 | stack_identifier = self.stack_create(template=cfn_template) |
| 324 | resources = self.client.resources.list(stack_identifier) |
| 325 | self.res_assert_for_test(resources) |
huangtianhua | 27075a9 | 2016-07-26 14:32:40 +0800 | [diff] [blame] | 326 | self.output_assert_for_test(stack_identifier) |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 327 | |
huangtianhua | 26da898 | 2016-07-27 18:11:58 +0800 | [diff] [blame] | 328 | parms = {'zone': 'fuzhou'} |
| 329 | self.update_stack(stack_identifier, |
| 330 | template=cfn_template, |
| 331 | parameters=parms) |
| 332 | |
| 333 | resources = self.client.resources.list(stack_identifier) |
| 334 | self.res_assert_for_test(resources, fj_zone=True) |
| 335 | self.output_assert_for_test(stack_identifier) |
| 336 | |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 337 | parms = {'env_type': 'prod'} |
| 338 | self.update_stack(stack_identifier, |
| 339 | template=cfn_template, |
| 340 | parameters=parms) |
| 341 | |
| 342 | resources = self.client.resources.list(stack_identifier) |
| 343 | self.res_assert_for_prod(resources) |
huangtianhua | 27075a9 | 2016-07-26 14:32:40 +0800 | [diff] [blame] | 344 | self.output_assert_for_prod(stack_identifier) |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 345 | |
huangtianhua | 7bdc751 | 2016-06-17 09:25:38 +0800 | [diff] [blame] | 346 | parms = {'env_type': 'prod', |
| 347 | 'zone': 'shanghai'} |
| 348 | self.update_stack(stack_identifier, |
| 349 | template=cfn_template, |
| 350 | parameters=parms) |
| 351 | |
| 352 | resources = self.client.resources.list(stack_identifier) |
| 353 | self.res_assert_for_prod(resources, False) |
| 354 | self.output_assert_for_prod(stack_identifier, False) |
| 355 | |
huangtianhua | 26da898 | 2016-07-27 18:11:58 +0800 | [diff] [blame] | 356 | parms = {'env_type': 'prod', |
| 357 | 'zone': 'xiamen'} |
| 358 | self.update_stack(stack_identifier, |
| 359 | template=cfn_template, |
| 360 | parameters=parms) |
| 361 | |
| 362 | resources = self.client.resources.list(stack_identifier) |
| 363 | self.res_assert_for_prod(resources, bj_prod=False, fj_zone=True) |
| 364 | self.output_assert_for_prod(stack_identifier, False) |
| 365 | |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 366 | def test_stack_create_update_cfn_template_prod_to_test(self): |
| 367 | parms = {'env_type': 'prod'} |
| 368 | stack_identifier = self.stack_create(template=cfn_template, |
| 369 | parameters=parms) |
| 370 | resources = self.client.resources.list(stack_identifier) |
| 371 | self.res_assert_for_prod(resources) |
huangtianhua | 27075a9 | 2016-07-26 14:32:40 +0800 | [diff] [blame] | 372 | self.output_assert_for_prod(stack_identifier) |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 373 | |
huangtianhua | 26da898 | 2016-07-27 18:11:58 +0800 | [diff] [blame] | 374 | parms = {'zone': 'xiamen', |
| 375 | 'env_type': 'prod'} |
| 376 | self.update_stack(stack_identifier, |
| 377 | template=cfn_template, |
| 378 | parameters=parms) |
| 379 | |
| 380 | resources = self.client.resources.list(stack_identifier) |
| 381 | self.res_assert_for_prod(resources, bj_prod=False, fj_zone=True) |
| 382 | self.output_assert_for_prod(stack_identifier, bj_prod=False) |
| 383 | |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 384 | parms = {'env_type': 'test'} |
| 385 | self.update_stack(stack_identifier, |
| 386 | template=cfn_template, |
| 387 | parameters=parms) |
| 388 | |
| 389 | resources = self.client.resources.list(stack_identifier) |
| 390 | self.res_assert_for_test(resources) |
huangtianhua | 27075a9 | 2016-07-26 14:32:40 +0800 | [diff] [blame] | 391 | self.output_assert_for_test(stack_identifier) |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 392 | |
huangtianhua | 26da898 | 2016-07-27 18:11:58 +0800 | [diff] [blame] | 393 | parms = {'env_type': 'test', |
| 394 | 'zone': 'fuzhou'} |
| 395 | self.update_stack(stack_identifier, |
| 396 | template=cfn_template, |
| 397 | parameters=parms) |
| 398 | |
| 399 | resources = self.client.resources.list(stack_identifier) |
| 400 | self.res_assert_for_test(resources, fj_zone=True) |
| 401 | self.output_assert_for_test(stack_identifier) |
| 402 | |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 403 | def test_stack_create_update_hot_template_test_to_prod(self): |
| 404 | stack_identifier = self.stack_create(template=hot_template) |
| 405 | resources = self.client.resources.list(stack_identifier) |
| 406 | self.res_assert_for_test(resources) |
huangtianhua | 27075a9 | 2016-07-26 14:32:40 +0800 | [diff] [blame] | 407 | self.output_assert_for_test(stack_identifier) |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 408 | |
| 409 | parms = {'env_type': 'prod'} |
| 410 | self.update_stack(stack_identifier, |
| 411 | template=hot_template, |
| 412 | parameters=parms) |
| 413 | |
| 414 | resources = self.client.resources.list(stack_identifier) |
| 415 | self.res_assert_for_prod(resources) |
huangtianhua | 27075a9 | 2016-07-26 14:32:40 +0800 | [diff] [blame] | 416 | self.output_assert_for_prod(stack_identifier) |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 417 | |
huangtianhua | 7bdc751 | 2016-06-17 09:25:38 +0800 | [diff] [blame] | 418 | parms = {'env_type': 'prod', |
| 419 | 'zone': 'shanghai'} |
| 420 | self.update_stack(stack_identifier, |
| 421 | template=hot_template, |
| 422 | parameters=parms) |
| 423 | |
| 424 | resources = self.client.resources.list(stack_identifier) |
| 425 | self.res_assert_for_prod(resources, False) |
| 426 | self.output_assert_for_prod(stack_identifier, False) |
| 427 | |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 428 | def test_stack_create_update_hot_template_prod_to_test(self): |
| 429 | parms = {'env_type': 'prod'} |
| 430 | stack_identifier = self.stack_create(template=hot_template, |
| 431 | parameters=parms) |
| 432 | resources = self.client.resources.list(stack_identifier) |
| 433 | self.res_assert_for_prod(resources) |
huangtianhua | 27075a9 | 2016-07-26 14:32:40 +0800 | [diff] [blame] | 434 | self.output_assert_for_prod(stack_identifier) |
huangtianhua | 99a25de | 2016-07-26 10:58:33 +0800 | [diff] [blame] | 435 | |
| 436 | parms = {'env_type': 'test'} |
| 437 | self.update_stack(stack_identifier, |
| 438 | template=hot_template, |
| 439 | parameters=parms) |
| 440 | |
| 441 | resources = self.client.resources.list(stack_identifier) |
| 442 | self.res_assert_for_test(resources) |
huangtianhua | 27075a9 | 2016-07-26 14:32:40 +0800 | [diff] [blame] | 443 | self.output_assert_for_test(stack_identifier) |
Zane Bitter | a9b5aaf | 2016-09-12 20:51:52 -0400 | [diff] [blame^] | 444 | |
| 445 | def test_condition_rename(self): |
| 446 | stack_identifier = self.stack_create(template=before_rename_tmpl) |
| 447 | self.update_stack(stack_identifier, template=after_rename_tmpl) |
| 448 | self.update_stack(stack_identifier, template=fail_rename_tmpl, |
| 449 | expected_status='UPDATE_FAILED') |
| 450 | self.update_stack(stack_identifier, template=recover_rename_tmpl) |