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
|
||||
cryptography==2.7
|
||||
debtcollector==1.2.0
|
||||
decorator==3.4.0
|
||||
deprecation==1.0
|
||||
docutils==0.11
|
||||
dogpile.cache==0.6.2
|
||||
@ -53,7 +52,6 @@ python-mimeparse==1.6.0
|
||||
python-novaclient==9.1.0
|
||||
python-subunit==1.0.0
|
||||
python-swiftclient==3.2.0
|
||||
pytz==2013.6
|
||||
PyYAML==3.13
|
||||
requests==2.18.0
|
||||
requestsexceptions==1.2.0
|
||||
|
@ -43,15 +43,14 @@ class AutoscalingTest(TestCase):
|
||||
nodetemplate = NodeTemplate(name, nodetemplates)
|
||||
toscacompute = ToscaCompute(nodetemplate)
|
||||
toscacompute.handle_properties()
|
||||
policy = Policy(policy_name, tpl, targets,
|
||||
properties, "node_templates")
|
||||
policy = Policy(policy_name, tpl, targets, properties, {})
|
||||
toscascaling = ToscaAutoscaling(
|
||||
policy, hot_template_parameters=hot_template_parameters)
|
||||
parameters = toscascaling.handle_properties([toscacompute])
|
||||
if hot_template_parameters:
|
||||
substack_template = toscascaling.extract_substack_templates(
|
||||
"output.yaml", HOT_TEMPLATE_VERSION)
|
||||
actual_nested_resource = yaml.load(
|
||||
actual_nested_resource = yaml.safe_load(
|
||||
substack_template['SP1_res.yaml'])
|
||||
self.assertEqual(expectedprops,
|
||||
actual_nested_resource)
|
||||
@ -135,50 +134,32 @@ class AutoscalingTest(TestCase):
|
||||
default_instances: 1
|
||||
'''
|
||||
|
||||
expected_nested_resource = {'heat_template_version':
|
||||
datetime.date(2013, 5, 23),
|
||||
'description':
|
||||
'Scaling template',
|
||||
'parameters':
|
||||
{'flavor':
|
||||
{'default': 'm1.tiny',
|
||||
'type': 'string',
|
||||
'description':
|
||||
'Flavor Information'
|
||||
},
|
||||
'image_name':
|
||||
{'default':
|
||||
'cirros-0.3.5-x86_64-disk',
|
||||
'type': 'string',
|
||||
'description': 'Image Name'
|
||||
}
|
||||
},
|
||||
'resources':
|
||||
{'VDU1':
|
||||
{'type':
|
||||
'OS::Nova::Server',
|
||||
'properties':
|
||||
{'flavor': None,
|
||||
'user_data_format':
|
||||
'SOFTWARE_CONFIG'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
expected = {
|
||||
'heat_template_version': datetime.date(2013, 5, 23),
|
||||
'description': 'Scaling template',
|
||||
'parameters': {
|
||||
'flavor': {
|
||||
'default': 'm1.tiny',
|
||||
'type': 'string',
|
||||
'description': 'Flavor Information'},
|
||||
'image_name': {
|
||||
'default': 'cirros-0.3.5-x86_64-disk',
|
||||
'type': 'string',
|
||||
'description': 'Image Name'}},
|
||||
'resources': {
|
||||
'VDU1': {
|
||||
'type': 'OS::Nova::Server',
|
||||
'properties': {
|
||||
'flavor': None,
|
||||
'user_data_format': 'SOFTWARE_CONFIG'}}}}
|
||||
|
||||
flavor = HotParameter('flavor', 'string',
|
||||
label=None,
|
||||
flavor = HotParameter('flavor', 'string', label=None,
|
||||
description='Flavor Information',
|
||||
default='m1.tiny',
|
||||
hidden=None,
|
||||
constraints=[])
|
||||
image = HotParameter('image_name', 'string',
|
||||
label=None,
|
||||
hidden=None, constraints=[])
|
||||
image = HotParameter('image_name', 'string', label=None,
|
||||
description='Image Name',
|
||||
default='cirros-0.3.5-x86_64-disk',
|
||||
hidden=None,
|
||||
constraints=[])
|
||||
hot_template_parameters = [flavor, image]
|
||||
self._tosca_scaling_test(tpl_snippet,
|
||||
expected_nested_resource,
|
||||
hot_template_parameters)
|
||||
hidden=None, constraints=[])
|
||||
hot_tpl_params = [flavor, image]
|
||||
self._tosca_scaling_test(tpl_snippet, expected, hot_tpl_params)
|
||||
|
Loading…
Reference in New Issue
Block a user