Refactor test_conditions functional test
Use the list_resources() method of the test base class. Change-Id: I7835211c4420f9da44eb2ae2f1d0e1e4b868efc4
This commit is contained in:
parent
28ce9f3ad4
commit
693b82fbd4
@ -307,10 +307,15 @@ resources:
|
|||||||
|
|
||||||
class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
||||||
|
|
||||||
def res_assert_for_prod(self, resources, bj_prod=True, fj_zone=False,
|
def res_assert_for_prod(self, stack_identifier,
|
||||||
|
bj_prod=True, fj_zone=False,
|
||||||
shannxi_provice=False):
|
shannxi_provice=False):
|
||||||
res_names = {res.resource_name for res in resources
|
def is_not_deleted(r):
|
||||||
if res.resource_status != 'DELETE_COMPLETE'}
|
return r.resource_status != 'DELETE_COMPLETE'
|
||||||
|
|
||||||
|
resources = self.list_resources(stack_identifier, is_not_deleted)
|
||||||
|
res_names = set(resources)
|
||||||
|
|
||||||
if bj_prod:
|
if bj_prod:
|
||||||
self.assertEqual(4, len(resources))
|
self.assertEqual(4, len(resources))
|
||||||
self.assertIn('beijing_prod_res', res_names)
|
self.assertIn('beijing_prod_res', res_names)
|
||||||
@ -330,10 +335,13 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
self.assertIn('prod_res', res_names)
|
self.assertIn('prod_res', res_names)
|
||||||
self.assertIn('test_res', res_names)
|
self.assertIn('test_res', res_names)
|
||||||
|
|
||||||
def res_assert_for_test(self, resources, fj_zone=False,
|
def res_assert_for_test(self, stack_identifier, fj_zone=False,
|
||||||
shannxi_provice=False):
|
shannxi_provice=False):
|
||||||
res_names = {res.resource_name for res in resources
|
def is_not_deleted(r):
|
||||||
if res.resource_status != 'DELETE_COMPLETE'}
|
return r.resource_status != 'DELETE_COMPLETE'
|
||||||
|
|
||||||
|
resources = self.list_resources(stack_identifier, is_not_deleted)
|
||||||
|
res_names = set(resources)
|
||||||
|
|
||||||
if fj_zone:
|
if fj_zone:
|
||||||
self.assertEqual(4, len(resources))
|
self.assertEqual(4, len(resources))
|
||||||
@ -399,8 +407,7 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
|
|
||||||
def test_stack_create_update_cfn_template_test_to_prod(self):
|
def test_stack_create_update_cfn_template_test_to_prod(self):
|
||||||
stack_identifier = self.stack_create(template=cfn_template)
|
stack_identifier = self.stack_create(template=cfn_template)
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_test(stack_identifier)
|
||||||
self.res_assert_for_test(resources)
|
|
||||||
self.output_assert_for_test(stack_identifier)
|
self.output_assert_for_test(stack_identifier)
|
||||||
|
|
||||||
parms = {'zone': 'fuzhou'}
|
parms = {'zone': 'fuzhou'}
|
||||||
@ -408,8 +415,7 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
template=cfn_template,
|
template=cfn_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
|
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_test(stack_identifier, fj_zone=True)
|
||||||
self.res_assert_for_test(resources, fj_zone=True)
|
|
||||||
self.output_assert_for_test(stack_identifier)
|
self.output_assert_for_test(stack_identifier)
|
||||||
|
|
||||||
parms = {'zone': 'xianyang'}
|
parms = {'zone': 'xianyang'}
|
||||||
@ -417,8 +423,7 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
template=cfn_template,
|
template=cfn_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
|
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_test(stack_identifier, shannxi_provice=True)
|
||||||
self.res_assert_for_test(resources, shannxi_provice=True)
|
|
||||||
self.output_assert_for_test(stack_identifier)
|
self.output_assert_for_test(stack_identifier)
|
||||||
|
|
||||||
parms = {'env_type': 'prod'}
|
parms = {'env_type': 'prod'}
|
||||||
@ -426,8 +431,7 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
template=cfn_template,
|
template=cfn_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
|
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_prod(stack_identifier)
|
||||||
self.res_assert_for_prod(resources)
|
|
||||||
self.output_assert_for_prod(stack_identifier)
|
self.output_assert_for_prod(stack_identifier)
|
||||||
|
|
||||||
parms = {'env_type': 'prod',
|
parms = {'env_type': 'prod',
|
||||||
@ -436,8 +440,7 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
template=cfn_template,
|
template=cfn_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
|
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_prod(stack_identifier, False)
|
||||||
self.res_assert_for_prod(resources, False)
|
|
||||||
self.output_assert_for_prod(stack_identifier, False)
|
self.output_assert_for_prod(stack_identifier, False)
|
||||||
|
|
||||||
parms = {'env_type': 'prod',
|
parms = {'env_type': 'prod',
|
||||||
@ -446,8 +449,7 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
template=cfn_template,
|
template=cfn_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
|
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_prod(stack_identifier, bj_prod=False, fj_zone=True)
|
||||||
self.res_assert_for_prod(resources, bj_prod=False, fj_zone=True)
|
|
||||||
self.output_assert_for_prod(stack_identifier, False)
|
self.output_assert_for_prod(stack_identifier, False)
|
||||||
|
|
||||||
parms = {'env_type': 'prod',
|
parms = {'env_type': 'prod',
|
||||||
@ -456,17 +458,15 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
template=cfn_template,
|
template=cfn_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
|
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_prod(stack_identifier, bj_prod=False,
|
||||||
self.res_assert_for_prod(resources, bj_prod=False, fj_zone=False,
|
fj_zone=False, shannxi_provice=True)
|
||||||
shannxi_provice=True)
|
|
||||||
self.output_assert_for_prod(stack_identifier, False)
|
self.output_assert_for_prod(stack_identifier, False)
|
||||||
|
|
||||||
def test_stack_create_update_cfn_template_prod_to_test(self):
|
def test_stack_create_update_cfn_template_prod_to_test(self):
|
||||||
parms = {'env_type': 'prod'}
|
parms = {'env_type': 'prod'}
|
||||||
stack_identifier = self.stack_create(template=cfn_template,
|
stack_identifier = self.stack_create(template=cfn_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_prod(stack_identifier)
|
||||||
self.res_assert_for_prod(resources)
|
|
||||||
self.output_assert_for_prod(stack_identifier)
|
self.output_assert_for_prod(stack_identifier)
|
||||||
|
|
||||||
parms = {'zone': 'xiamen',
|
parms = {'zone': 'xiamen',
|
||||||
@ -475,8 +475,7 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
template=cfn_template,
|
template=cfn_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
|
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_prod(stack_identifier, bj_prod=False, fj_zone=True)
|
||||||
self.res_assert_for_prod(resources, bj_prod=False, fj_zone=True)
|
|
||||||
self.output_assert_for_prod(stack_identifier, bj_prod=False)
|
self.output_assert_for_prod(stack_identifier, bj_prod=False)
|
||||||
|
|
||||||
parms = {'zone': 'xianyang',
|
parms = {'zone': 'xianyang',
|
||||||
@ -485,9 +484,8 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
template=cfn_template,
|
template=cfn_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
|
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_prod(stack_identifier, bj_prod=False,
|
||||||
self.res_assert_for_prod(resources, bj_prod=False, fj_zone=False,
|
fj_zone=False, shannxi_provice=True)
|
||||||
shannxi_provice=True)
|
|
||||||
self.output_assert_for_prod(stack_identifier, bj_prod=False)
|
self.output_assert_for_prod(stack_identifier, bj_prod=False)
|
||||||
|
|
||||||
parms = {'zone': 'shanghai',
|
parms = {'zone': 'shanghai',
|
||||||
@ -496,9 +494,8 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
template=cfn_template,
|
template=cfn_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
|
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_prod(stack_identifier, bj_prod=False,
|
||||||
self.res_assert_for_prod(resources, bj_prod=False, fj_zone=False,
|
fj_zone=False, shannxi_provice=False)
|
||||||
shannxi_provice=False)
|
|
||||||
self.output_assert_for_prod(stack_identifier, bj_prod=False)
|
self.output_assert_for_prod(stack_identifier, bj_prod=False)
|
||||||
|
|
||||||
parms = {'env_type': 'test'}
|
parms = {'env_type': 'test'}
|
||||||
@ -506,8 +503,7 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
template=cfn_template,
|
template=cfn_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
|
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_test(stack_identifier)
|
||||||
self.res_assert_for_test(resources)
|
|
||||||
self.output_assert_for_test(stack_identifier)
|
self.output_assert_for_test(stack_identifier)
|
||||||
|
|
||||||
parms = {'env_type': 'test',
|
parms = {'env_type': 'test',
|
||||||
@ -516,8 +512,7 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
template=cfn_template,
|
template=cfn_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
|
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_test(stack_identifier, fj_zone=True)
|
||||||
self.res_assert_for_test(resources, fj_zone=True)
|
|
||||||
self.output_assert_for_test(stack_identifier)
|
self.output_assert_for_test(stack_identifier)
|
||||||
|
|
||||||
parms = {'env_type': 'test',
|
parms = {'env_type': 'test',
|
||||||
@ -526,15 +521,13 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
template=cfn_template,
|
template=cfn_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
|
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_test(stack_identifier, fj_zone=False,
|
||||||
self.res_assert_for_test(resources, fj_zone=False,
|
|
||||||
shannxi_provice=True)
|
shannxi_provice=True)
|
||||||
self.output_assert_for_test(stack_identifier)
|
self.output_assert_for_test(stack_identifier)
|
||||||
|
|
||||||
def test_stack_create_update_hot_template_test_to_prod(self):
|
def test_stack_create_update_hot_template_test_to_prod(self):
|
||||||
stack_identifier = self.stack_create(template=hot_template)
|
stack_identifier = self.stack_create(template=hot_template)
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_test(stack_identifier)
|
||||||
self.res_assert_for_test(resources)
|
|
||||||
self.output_assert_for_test(stack_identifier)
|
self.output_assert_for_test(stack_identifier)
|
||||||
|
|
||||||
parms = {'zone': 'xianyang'}
|
parms = {'zone': 'xianyang'}
|
||||||
@ -542,8 +535,7 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
template=hot_template,
|
template=hot_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
|
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_test(stack_identifier, shannxi_provice=True)
|
||||||
self.res_assert_for_test(resources, shannxi_provice=True)
|
|
||||||
self.output_assert_for_test(stack_identifier)
|
self.output_assert_for_test(stack_identifier)
|
||||||
|
|
||||||
parms = {'env_type': 'prod'}
|
parms = {'env_type': 'prod'}
|
||||||
@ -551,8 +543,7 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
template=hot_template,
|
template=hot_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
|
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_prod(stack_identifier)
|
||||||
self.res_assert_for_prod(resources)
|
|
||||||
self.output_assert_for_prod(stack_identifier)
|
self.output_assert_for_prod(stack_identifier)
|
||||||
|
|
||||||
parms = {'env_type': 'prod',
|
parms = {'env_type': 'prod',
|
||||||
@ -561,8 +552,7 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
template=hot_template,
|
template=hot_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
|
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_prod(stack_identifier, False)
|
||||||
self.res_assert_for_prod(resources, False)
|
|
||||||
self.output_assert_for_prod(stack_identifier, False)
|
self.output_assert_for_prod(stack_identifier, False)
|
||||||
|
|
||||||
parms = {'env_type': 'prod',
|
parms = {'env_type': 'prod',
|
||||||
@ -571,16 +561,14 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
template=hot_template,
|
template=hot_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
|
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_prod(stack_identifier, False, shannxi_provice=True)
|
||||||
self.res_assert_for_prod(resources, False, shannxi_provice=True)
|
|
||||||
self.output_assert_for_prod(stack_identifier, False)
|
self.output_assert_for_prod(stack_identifier, False)
|
||||||
|
|
||||||
def test_stack_create_update_hot_template_prod_to_test(self):
|
def test_stack_create_update_hot_template_prod_to_test(self):
|
||||||
parms = {'env_type': 'prod'}
|
parms = {'env_type': 'prod'}
|
||||||
stack_identifier = self.stack_create(template=hot_template,
|
stack_identifier = self.stack_create(template=hot_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_prod(stack_identifier)
|
||||||
self.res_assert_for_prod(resources)
|
|
||||||
self.output_assert_for_prod(stack_identifier)
|
self.output_assert_for_prod(stack_identifier)
|
||||||
|
|
||||||
parms = {'env_type': 'prod',
|
parms = {'env_type': 'prod',
|
||||||
@ -589,8 +577,7 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
template=hot_template,
|
template=hot_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
|
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_prod(stack_identifier, False, shannxi_provice=True)
|
||||||
self.res_assert_for_prod(resources, False, shannxi_provice=True)
|
|
||||||
self.output_assert_for_prod(stack_identifier, False)
|
self.output_assert_for_prod(stack_identifier, False)
|
||||||
|
|
||||||
parms = {'env_type': 'test'}
|
parms = {'env_type': 'test'}
|
||||||
@ -598,8 +585,7 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
template=hot_template,
|
template=hot_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
|
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_test(stack_identifier)
|
||||||
self.res_assert_for_test(resources)
|
|
||||||
self.output_assert_for_test(stack_identifier)
|
self.output_assert_for_test(stack_identifier)
|
||||||
|
|
||||||
parms = {'env_type': 'test',
|
parms = {'env_type': 'test',
|
||||||
@ -608,8 +594,7 @@ class CreateUpdateResConditionTest(functional_base.FunctionalTestsBase):
|
|||||||
template=hot_template,
|
template=hot_template,
|
||||||
parameters=parms)
|
parameters=parms)
|
||||||
|
|
||||||
resources = self.client.resources.list(stack_identifier)
|
self.res_assert_for_test(stack_identifier, fj_zone=False,
|
||||||
self.res_assert_for_test(resources, fj_zone=False,
|
|
||||||
shannxi_provice=True)
|
shannxi_provice=True)
|
||||||
self.output_assert_for_test(stack_identifier)
|
self.output_assert_for_test(stack_identifier)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user