Fix unittest for auto scaling
This update is to fix failures in unittests below. * `custom_def` in Policy class was changed from str to dict in tosca-parser. This arg isn't interested in the test, so it's replaced with empty dict. * Fix unsafe yaml loader with `yamf.safe_load`. It also removes nouse pip packages which cause failures while resovlving dependencies, and some tiny refactoring. Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com> Change-Id: I8ae60a4ae9f139073f05ec0f99fa82c8bb24ee50
This commit is contained in:
parent
0b8fba577f
commit
65dfa754e2
@ -7,7 +7,6 @@ cmd2==0.8.0
|
|||||||
coverage==4.0
|
coverage==4.0
|
||||||
cryptography==2.7
|
cryptography==2.7
|
||||||
debtcollector==1.2.0
|
debtcollector==1.2.0
|
||||||
decorator==3.4.0
|
|
||||||
deprecation==1.0
|
deprecation==1.0
|
||||||
docutils==0.11
|
docutils==0.11
|
||||||
dogpile.cache==0.6.2
|
dogpile.cache==0.6.2
|
||||||
@ -53,7 +52,6 @@ python-mimeparse==1.6.0
|
|||||||
python-novaclient==9.1.0
|
python-novaclient==9.1.0
|
||||||
python-subunit==1.0.0
|
python-subunit==1.0.0
|
||||||
python-swiftclient==3.2.0
|
python-swiftclient==3.2.0
|
||||||
pytz==2013.6
|
|
||||||
PyYAML==3.13
|
PyYAML==3.13
|
||||||
requests==2.18.0
|
requests==2.18.0
|
||||||
requestsexceptions==1.2.0
|
requestsexceptions==1.2.0
|
||||||
|
@ -43,15 +43,14 @@ class AutoscalingTest(TestCase):
|
|||||||
nodetemplate = NodeTemplate(name, nodetemplates)
|
nodetemplate = NodeTemplate(name, nodetemplates)
|
||||||
toscacompute = ToscaCompute(nodetemplate)
|
toscacompute = ToscaCompute(nodetemplate)
|
||||||
toscacompute.handle_properties()
|
toscacompute.handle_properties()
|
||||||
policy = Policy(policy_name, tpl, targets,
|
policy = Policy(policy_name, tpl, targets, properties, {})
|
||||||
properties, "node_templates")
|
|
||||||
toscascaling = ToscaAutoscaling(
|
toscascaling = ToscaAutoscaling(
|
||||||
policy, hot_template_parameters=hot_template_parameters)
|
policy, hot_template_parameters=hot_template_parameters)
|
||||||
parameters = toscascaling.handle_properties([toscacompute])
|
parameters = toscascaling.handle_properties([toscacompute])
|
||||||
if hot_template_parameters:
|
if hot_template_parameters:
|
||||||
substack_template = toscascaling.extract_substack_templates(
|
substack_template = toscascaling.extract_substack_templates(
|
||||||
"output.yaml", HOT_TEMPLATE_VERSION)
|
"output.yaml", HOT_TEMPLATE_VERSION)
|
||||||
actual_nested_resource = yaml.load(
|
actual_nested_resource = yaml.safe_load(
|
||||||
substack_template['SP1_res.yaml'])
|
substack_template['SP1_res.yaml'])
|
||||||
self.assertEqual(expectedprops,
|
self.assertEqual(expectedprops,
|
||||||
actual_nested_resource)
|
actual_nested_resource)
|
||||||
@ -135,50 +134,32 @@ class AutoscalingTest(TestCase):
|
|||||||
default_instances: 1
|
default_instances: 1
|
||||||
'''
|
'''
|
||||||
|
|
||||||
expected_nested_resource = {'heat_template_version':
|
expected = {
|
||||||
datetime.date(2013, 5, 23),
|
'heat_template_version': datetime.date(2013, 5, 23),
|
||||||
'description':
|
'description': 'Scaling template',
|
||||||
'Scaling template',
|
'parameters': {
|
||||||
'parameters':
|
'flavor': {
|
||||||
{'flavor':
|
'default': 'm1.tiny',
|
||||||
{'default': 'm1.tiny',
|
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'description':
|
'description': 'Flavor Information'},
|
||||||
'Flavor Information'
|
'image_name': {
|
||||||
},
|
'default': 'cirros-0.3.5-x86_64-disk',
|
||||||
'image_name':
|
|
||||||
{'default':
|
|
||||||
'cirros-0.3.5-x86_64-disk',
|
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'description': 'Image Name'
|
'description': 'Image Name'}},
|
||||||
}
|
'resources': {
|
||||||
},
|
'VDU1': {
|
||||||
'resources':
|
'type': 'OS::Nova::Server',
|
||||||
{'VDU1':
|
'properties': {
|
||||||
{'type':
|
'flavor': None,
|
||||||
'OS::Nova::Server',
|
'user_data_format': 'SOFTWARE_CONFIG'}}}}
|
||||||
'properties':
|
|
||||||
{'flavor': None,
|
|
||||||
'user_data_format':
|
|
||||||
'SOFTWARE_CONFIG'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
flavor = HotParameter('flavor', 'string',
|
flavor = HotParameter('flavor', 'string', label=None,
|
||||||
label=None,
|
|
||||||
description='Flavor Information',
|
description='Flavor Information',
|
||||||
default='m1.tiny',
|
default='m1.tiny',
|
||||||
hidden=None,
|
hidden=None, constraints=[])
|
||||||
constraints=[])
|
image = HotParameter('image_name', 'string', label=None,
|
||||||
image = HotParameter('image_name', 'string',
|
|
||||||
label=None,
|
|
||||||
description='Image Name',
|
description='Image Name',
|
||||||
default='cirros-0.3.5-x86_64-disk',
|
default='cirros-0.3.5-x86_64-disk',
|
||||||
hidden=None,
|
hidden=None, constraints=[])
|
||||||
constraints=[])
|
hot_tpl_params = [flavor, image]
|
||||||
hot_template_parameters = [flavor, image]
|
self._tosca_scaling_test(tpl_snippet, expected, hot_tpl_params)
|
||||||
self._tosca_scaling_test(tpl_snippet,
|
|
||||||
expected_nested_resource,
|
|
||||||
hot_template_parameters)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user