Fix [H405] pep rule in heat/tests
Implements bp docstring-improvements Change-Id: I2fd82d698f42aca3b34822875cf4d706fedbf5f2
This commit is contained in:
parent
34f32eef0e
commit
c4b0ced813
|
@ -18,9 +18,8 @@ from heat.tests import common
|
||||||
|
|
||||||
|
|
||||||
class AWSCommonTest(common.HeatTestCase):
|
class AWSCommonTest(common.HeatTestCase):
|
||||||
'''
|
"""Tests the api/aws common components."""
|
||||||
Tests the api/aws common components
|
|
||||||
'''
|
|
||||||
# The tests
|
# The tests
|
||||||
def test_format_response(self):
|
def test_format_response(self):
|
||||||
response = api_utils.format_response("Foo", "Bar")
|
response = api_utils.format_response("Foo", "Bar")
|
||||||
|
|
|
@ -28,9 +28,7 @@ from heat.tests import utils
|
||||||
|
|
||||||
|
|
||||||
class Ec2TokenTest(common.HeatTestCase):
|
class Ec2TokenTest(common.HeatTestCase):
|
||||||
"""
|
"""Tests the Ec2Token middleware."""
|
||||||
Tests the Ec2Token middleware
|
|
||||||
"""
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(Ec2TokenTest, self).setUp()
|
super(Ec2TokenTest, self).setUp()
|
||||||
|
|
|
@ -33,7 +33,8 @@ policy_path = os.path.dirname(os.path.realpath(__file__)) + "/../../policy/"
|
||||||
|
|
||||||
|
|
||||||
class CfnStackControllerTest(common.HeatTestCase):
|
class CfnStackControllerTest(common.HeatTestCase):
|
||||||
"""
|
"""Tests the API class CfnStackController.
|
||||||
|
|
||||||
Tests the API class which acts as the WSGI controller,
|
Tests the API class which acts as the WSGI controller,
|
||||||
the endpoint processing API requests after they are routed
|
the endpoint processing API requests after they are routed
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -27,10 +27,11 @@ from heat.tests import utils
|
||||||
|
|
||||||
|
|
||||||
class WatchControllerTest(common.HeatTestCase):
|
class WatchControllerTest(common.HeatTestCase):
|
||||||
'''
|
"""Tests the API class WatchController.
|
||||||
|
|
||||||
Tests the API class which acts as the WSGI controller,
|
Tests the API class which acts as the WSGI controller,
|
||||||
the endpoint processing API requests after they are routed
|
the endpoint processing API requests after they are routed
|
||||||
'''
|
"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(WatchControllerTest, self).setUp()
|
super(WatchControllerTest, self).setUp()
|
||||||
|
|
|
@ -28,10 +28,11 @@ from heat.tests import common
|
||||||
|
|
||||||
@mock.patch.object(policy.Enforcer, 'enforce')
|
@mock.patch.object(policy.Enforcer, 'enforce')
|
||||||
class ActionControllerTest(tools.ControllerTest, common.HeatTestCase):
|
class ActionControllerTest(tools.ControllerTest, common.HeatTestCase):
|
||||||
'''
|
"""Tests the API class ActionController.
|
||||||
|
|
||||||
Tests the API class which acts as the WSGI controller,
|
Tests the API class which acts as the WSGI controller,
|
||||||
the endpoint processing API requests after they are routed
|
the endpoint processing API requests after they are routed
|
||||||
'''
|
"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ActionControllerTest, self).setUp()
|
super(ActionControllerTest, self).setUp()
|
||||||
|
|
|
@ -27,10 +27,11 @@ from heat.tests import common
|
||||||
|
|
||||||
@mock.patch.object(policy.Enforcer, 'enforce')
|
@mock.patch.object(policy.Enforcer, 'enforce')
|
||||||
class EventControllerTest(tools.ControllerTest, common.HeatTestCase):
|
class EventControllerTest(tools.ControllerTest, common.HeatTestCase):
|
||||||
'''
|
"""Tests the API class EventController.
|
||||||
|
|
||||||
Tests the API class which acts as the WSGI controller,
|
Tests the API class which acts as the WSGI controller,
|
||||||
the endpoint processing API requests after they are routed
|
the endpoint processing API requests after they are routed
|
||||||
'''
|
"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(EventControllerTest, self).setUp()
|
super(EventControllerTest, self).setUp()
|
||||||
|
|
|
@ -28,10 +28,11 @@ from heat.tests import common
|
||||||
|
|
||||||
@mock.patch.object(policy.Enforcer, 'enforce')
|
@mock.patch.object(policy.Enforcer, 'enforce')
|
||||||
class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase):
|
class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase):
|
||||||
'''
|
"""Tests the API class ResourceController.
|
||||||
|
|
||||||
Tests the API class which acts as the WSGI controller,
|
Tests the API class which acts as the WSGI controller,
|
||||||
the endpoint processing API requests after they are routed
|
the endpoint processing API requests after they are routed
|
||||||
'''
|
"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ResourceControllerTest, self).setUp()
|
super(ResourceControllerTest, self).setUp()
|
||||||
|
|
|
@ -201,10 +201,11 @@ blarg: wibble
|
||||||
|
|
||||||
@mock.patch.object(policy.Enforcer, 'enforce')
|
@mock.patch.object(policy.Enforcer, 'enforce')
|
||||||
class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
|
class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
|
||||||
'''
|
"""Tests the API class StackController.
|
||||||
|
|
||||||
Tests the API class which acts as the WSGI controller,
|
Tests the API class which acts as the WSGI controller,
|
||||||
the endpoint processing API requests after they are routed
|
the endpoint processing API requests after they are routed
|
||||||
'''
|
"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(StackControllerTest, self).setUp()
|
super(StackControllerTest, self).setUp()
|
||||||
|
|
|
@ -33,8 +33,7 @@ def request_with_middleware(middleware, func, req, *args, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
def to_remote_error(error):
|
def to_remote_error(error):
|
||||||
"""Converts the given exception to the one with the _Remote suffix.
|
"""Converts the given exception to the one with the _Remote suffix."""
|
||||||
"""
|
|
||||||
exc_info = (type(error), error, None)
|
exc_info = (type(error), error, None)
|
||||||
serialized = rpc_common.serialize_remote_exception(exc_info)
|
serialized = rpc_common.serialize_remote_exception(exc_info)
|
||||||
remote_error = rpc_common.deserialize_remote_exception(
|
remote_error = rpc_common.deserialize_remote_exception(
|
||||||
|
@ -43,9 +42,7 @@ def to_remote_error(error):
|
||||||
|
|
||||||
|
|
||||||
class ControllerTest(object):
|
class ControllerTest(object):
|
||||||
"""
|
"""Common utilities for testing API Controllers."""
|
||||||
Common utilities for testing API Controllers.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(ControllerTest, self).__init__(*args, **kwargs)
|
super(ControllerTest, self).__init__(*args, **kwargs)
|
||||||
|
|
|
@ -397,7 +397,9 @@ class HeatScalingGroupAttrTest(common.HeatTestCase):
|
||||||
self.assertIsNone(self.group.validate())
|
self.assertIsNone(self.group.validate())
|
||||||
|
|
||||||
def test_no_instance_list(self):
|
def test_no_instance_list(self):
|
||||||
"""The InstanceList attribute is not inherited from
|
"""Tests inheritance of InstanceList attribute.
|
||||||
|
|
||||||
|
The InstanceList attribute is not inherited from
|
||||||
AutoScalingResourceGroup's superclasses.
|
AutoScalingResourceGroup's superclasses.
|
||||||
"""
|
"""
|
||||||
self.assertRaises(exception.InvalidTemplateAttribute,
|
self.assertRaises(exception.InvalidTemplateAttribute,
|
||||||
|
|
|
@ -25,7 +25,8 @@ class ResourceTemplatesTest(common.HeatTestCase):
|
||||||
self.next_id = lambda: next(ids)
|
self.next_id = lambda: next(ids)
|
||||||
|
|
||||||
def test_create_template(self):
|
def test_create_template(self):
|
||||||
"""
|
"""Test case for creating template.
|
||||||
|
|
||||||
When creating a template from scratch, an empty list is accepted as
|
When creating a template from scratch, an empty list is accepted as
|
||||||
the "old" resources and new resources are created up to num_resource.
|
the "old" resources and new resources are created up to num_resource.
|
||||||
"""
|
"""
|
||||||
|
@ -37,7 +38,8 @@ class ResourceTemplatesTest(common.HeatTestCase):
|
||||||
self.assertEqual(expected, list(templates))
|
self.assertEqual(expected, list(templates))
|
||||||
|
|
||||||
def test_replace_template(self):
|
def test_replace_template(self):
|
||||||
"""
|
"""Test case for replacing template.
|
||||||
|
|
||||||
If num_replace is the number of old resources, then all of the
|
If num_replace is the number of old resources, then all of the
|
||||||
resources will be replaced.
|
resources will be replaced.
|
||||||
"""
|
"""
|
||||||
|
@ -50,7 +52,8 @@ class ResourceTemplatesTest(common.HeatTestCase):
|
||||||
self.assertEqual(expected, list(templates))
|
self.assertEqual(expected, list(templates))
|
||||||
|
|
||||||
def test_replace_some_units(self):
|
def test_replace_some_units(self):
|
||||||
"""
|
"""Test case for making only the number of replacements specified.
|
||||||
|
|
||||||
If the resource definition changes, only the number of replacements
|
If the resource definition changes, only the number of replacements
|
||||||
specified will be made; beyond that, the original templates are used.
|
specified will be made; beyond that, the original templates are used.
|
||||||
"""
|
"""
|
||||||
|
@ -66,7 +69,8 @@ class ResourceTemplatesTest(common.HeatTestCase):
|
||||||
self.assertEqual(expected, list(templates))
|
self.assertEqual(expected, list(templates))
|
||||||
|
|
||||||
def test_growth_counts_as_replacement(self):
|
def test_growth_counts_as_replacement(self):
|
||||||
"""
|
"""Test case for growing template.
|
||||||
|
|
||||||
If we grow the template and replace some elements at the same time, the
|
If we grow the template and replace some elements at the same time, the
|
||||||
number of replacements to perform is reduced by the number of new
|
number of replacements to perform is reduced by the number of new
|
||||||
resources to be created.
|
resources to be created.
|
||||||
|
@ -86,7 +90,8 @@ class ResourceTemplatesTest(common.HeatTestCase):
|
||||||
self.assertEqual(expected, list(templates))
|
self.assertEqual(expected, list(templates))
|
||||||
|
|
||||||
def test_replace_units_some_already_up_to_date(self):
|
def test_replace_units_some_already_up_to_date(self):
|
||||||
"""
|
"""Test case for up-to-date resources in template.
|
||||||
|
|
||||||
If some of the old resources already have the new resource definition,
|
If some of the old resources already have the new resource definition,
|
||||||
then they won't be considered for replacement, and the next resource
|
then they won't be considered for replacement, and the next resource
|
||||||
that is out-of-date will be replaced.
|
that is out-of-date will be replaced.
|
||||||
|
|
|
@ -714,7 +714,8 @@ class InstancesTest(common.HeatTestCase):
|
||||||
self.assertEqual({'test': 123}, instance.metadata_get())
|
self.assertEqual({'test': 123}, instance.metadata_get())
|
||||||
|
|
||||||
def test_instance_update_instance_type(self):
|
def test_instance_update_instance_type(self):
|
||||||
"""
|
"""Test case for updating InstanceType.
|
||||||
|
|
||||||
Instance.handle_update supports changing the InstanceType, and makes
|
Instance.handle_update supports changing the InstanceType, and makes
|
||||||
the change making a resize API call against Nova.
|
the change making a resize API call against Nova.
|
||||||
"""
|
"""
|
||||||
|
@ -761,7 +762,8 @@ class InstancesTest(common.HeatTestCase):
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_instance_update_instance_type_failed(self):
|
def test_instance_update_instance_type_failed(self):
|
||||||
"""
|
"""Test case for raising exception due to resize call failed.
|
||||||
|
|
||||||
If the status after a resize is not VERIFY_RESIZE, it means the resize
|
If the status after a resize is not VERIFY_RESIZE, it means the resize
|
||||||
call failed, so we raise an explicit error.
|
call failed, so we raise an explicit error.
|
||||||
"""
|
"""
|
||||||
|
@ -812,7 +814,8 @@ class InstancesTest(common.HeatTestCase):
|
||||||
return fake_interface(port, net, ip)
|
return fake_interface(port, net, ip)
|
||||||
|
|
||||||
def test_instance_update_network_interfaces(self):
|
def test_instance_update_network_interfaces(self):
|
||||||
"""
|
"""Test case for updating NetworkInterfaces.
|
||||||
|
|
||||||
Instance.handle_update supports changing the NetworkInterfaces,
|
Instance.handle_update supports changing the NetworkInterfaces,
|
||||||
and makes the change making a resize API call against Nova.
|
and makes the change making a resize API call against Nova.
|
||||||
"""
|
"""
|
||||||
|
@ -853,7 +856,8 @@ class InstancesTest(common.HeatTestCase):
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_instance_update_network_interfaces_old_include_new(self):
|
def test_instance_update_network_interfaces_old_include_new(self):
|
||||||
"""
|
"""Test case for updating NetworkInterfaces when old prop includes new.
|
||||||
|
|
||||||
Instance.handle_update supports changing the NetworkInterfaces,
|
Instance.handle_update supports changing the NetworkInterfaces,
|
||||||
and makes the change making a resize API call against Nova.
|
and makes the change making a resize API call against Nova.
|
||||||
"""
|
"""
|
||||||
|
@ -888,7 +892,8 @@ class InstancesTest(common.HeatTestCase):
|
||||||
self.assertEqual((instance.UPDATE, instance.COMPLETE), instance.state)
|
self.assertEqual((instance.UPDATE, instance.COMPLETE), instance.state)
|
||||||
|
|
||||||
def test_instance_update_network_interfaces_new_include_old(self):
|
def test_instance_update_network_interfaces_new_include_old(self):
|
||||||
"""
|
"""Test case for updating NetworkInterfaces when new prop includes old.
|
||||||
|
|
||||||
Instance.handle_update supports changing the NetworkInterfaces,
|
Instance.handle_update supports changing the NetworkInterfaces,
|
||||||
and makes the change making a resize API call against Nova.
|
and makes the change making a resize API call against Nova.
|
||||||
"""
|
"""
|
||||||
|
@ -923,7 +928,8 @@ class InstancesTest(common.HeatTestCase):
|
||||||
self.assertEqual((instance.UPDATE, instance.COMPLETE), instance.state)
|
self.assertEqual((instance.UPDATE, instance.COMPLETE), instance.state)
|
||||||
|
|
||||||
def test_instance_update_network_interfaces_new_old_all_different(self):
|
def test_instance_update_network_interfaces_new_old_all_different(self):
|
||||||
"""
|
"""Tests updating NetworkInterfaces when new and old are different.
|
||||||
|
|
||||||
Instance.handle_update supports changing the NetworkInterfaces,
|
Instance.handle_update supports changing the NetworkInterfaces,
|
||||||
and makes the change making a resize API call against Nova.
|
and makes the change making a resize API call against Nova.
|
||||||
"""
|
"""
|
||||||
|
@ -963,7 +969,8 @@ class InstancesTest(common.HeatTestCase):
|
||||||
self.assertEqual((instance.UPDATE, instance.COMPLETE), instance.state)
|
self.assertEqual((instance.UPDATE, instance.COMPLETE), instance.state)
|
||||||
|
|
||||||
def test_instance_update_network_interfaces_no_old(self):
|
def test_instance_update_network_interfaces_no_old(self):
|
||||||
"""
|
"""Test case for updating NetworkInterfaces when there's no old prop.
|
||||||
|
|
||||||
Instance.handle_update supports changing the NetworkInterfaces,
|
Instance.handle_update supports changing the NetworkInterfaces,
|
||||||
and makes the change making a resize API call against Nova.
|
and makes the change making a resize API call against Nova.
|
||||||
"""
|
"""
|
||||||
|
@ -1004,8 +1011,9 @@ class InstancesTest(common.HeatTestCase):
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_instance_update_network_interfaces_no_old_empty_new(self):
|
def test_instance_update_network_interfaces_no_old_empty_new(self):
|
||||||
"""
|
"""Test case for updating NetworkInterfaces when no old, no new prop.
|
||||||
Instance.handle_update supports changing the NetworkInterfaces
|
|
||||||
|
Instance.handle_update supports changing the NetworkInterfaces.
|
||||||
"""
|
"""
|
||||||
return_server = self.fc.servers.list()[1]
|
return_server = self.fc.servers.list()[1]
|
||||||
return_server.id = '1234'
|
return_server.id = '1234'
|
||||||
|
@ -1083,9 +1091,7 @@ class InstancesTest(common.HeatTestCase):
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_instance_update_network_interfaces_empty_new_with_subnet(self):
|
def test_instance_update_network_interfaces_empty_new_with_subnet(self):
|
||||||
"""
|
"""Test update NetworkInterfaces to empty, and update with subnet."""
|
||||||
Test update NetworkInterfaces to empty, and update with subnet.
|
|
||||||
"""
|
|
||||||
stack_name = 'ud_network_interfaces_empty_with_subnet'
|
stack_name = 'ud_network_interfaces_empty_with_subnet'
|
||||||
self._test_instance_update_with_subnet(
|
self._test_instance_update_with_subnet(
|
||||||
stack_name, new_interfaces=[])
|
stack_name, new_interfaces=[])
|
||||||
|
@ -1334,9 +1340,10 @@ class InstancesTest(common.HeatTestCase):
|
||||||
))
|
))
|
||||||
|
|
||||||
def test_build_nics_with_security_groups(self):
|
def test_build_nics_with_security_groups(self):
|
||||||
"""
|
"""Test the security groups can be associated to a new created port.
|
||||||
Test the security groups defined in heat template can be associated
|
|
||||||
to a new created port.
|
Test the security groups defined in heat template can be associated to
|
||||||
|
a new created port.
|
||||||
"""
|
"""
|
||||||
return_server = self.fc.servers.list()[1]
|
return_server = self.fc.servers.list()[1]
|
||||||
instance = self._create_test_instance(return_server,
|
instance = self._create_test_instance(return_server,
|
||||||
|
|
|
@ -205,10 +205,8 @@ class CeilometerAlarmTest(common.HeatTestCase):
|
||||||
return stack
|
return stack
|
||||||
|
|
||||||
def test_mem_alarm_high_update_no_replace(self):
|
def test_mem_alarm_high_update_no_replace(self):
|
||||||
'''
|
"""Tests update updatable properties without replacing the Alarm."""
|
||||||
Make sure that we can change the update-able properties
|
|
||||||
without replacing the Alarm rsrc.
|
|
||||||
'''
|
|
||||||
# short circuit the alarm's references
|
# short circuit the alarm's references
|
||||||
t = template_format.parse(alarm_template)
|
t = template_format.parse(alarm_template)
|
||||||
properties = t['Resources']['MEMAlarmHigh']['Properties']
|
properties = t['Resources']['MEMAlarmHigh']['Properties']
|
||||||
|
@ -270,10 +268,8 @@ class CeilometerAlarmTest(common.HeatTestCase):
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_mem_alarm_high_update_replace(self):
|
def test_mem_alarm_high_update_replace(self):
|
||||||
'''
|
"""Tests resource replacing when changing non-updatable properties."""
|
||||||
Make sure that the Alarm resource IS replaced when non-update-able
|
|
||||||
properties are changed.
|
|
||||||
'''
|
|
||||||
t = template_format.parse(alarm_template)
|
t = template_format.parse(alarm_template)
|
||||||
properties = t['Resources']['MEMAlarmHigh']['Properties']
|
properties = t['Resources']['MEMAlarmHigh']['Properties']
|
||||||
properties['alarm_actions'] = ['signal_handler']
|
properties['alarm_actions'] = ['signal_handler']
|
||||||
|
@ -297,9 +293,10 @@ class CeilometerAlarmTest(common.HeatTestCase):
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_mem_alarm_suspend_resume(self):
|
def test_mem_alarm_suspend_resume(self):
|
||||||
"""
|
"""Tests suspending and resuming of the alarm.
|
||||||
|
|
||||||
Make sure that the Alarm resource gets disabled on suspend
|
Make sure that the Alarm resource gets disabled on suspend
|
||||||
and reenabled on resume.
|
and re-enabled on resume.
|
||||||
"""
|
"""
|
||||||
self.stack = self.create_stack()
|
self.stack = self.create_stack()
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,8 @@ from heat.tests import utils
|
||||||
|
|
||||||
|
|
||||||
class CinderClientPluginTests(common.HeatTestCase):
|
class CinderClientPluginTests(common.HeatTestCase):
|
||||||
"""
|
"""Basic tests for :module:'heat.engine.clients.os.cinder'."""
|
||||||
Basic tests for the helper methods in
|
|
||||||
:module:'heat.engine.clients.os.cinder'.
|
|
||||||
"""
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(CinderClientPluginTests, self).setUp()
|
super(CinderClientPluginTests, self).setUp()
|
||||||
self.cinder_client = mock.MagicMock()
|
self.cinder_client = mock.MagicMock()
|
||||||
|
|
|
@ -24,10 +24,7 @@ from heat.tests import utils
|
||||||
|
|
||||||
|
|
||||||
class GlanceUtilsTests(common.HeatTestCase):
|
class GlanceUtilsTests(common.HeatTestCase):
|
||||||
"""
|
"""Basic tests for :module:'heat.engine.resources.clients.os.glance'."""
|
||||||
Basic tests for the helper methods in
|
|
||||||
:module:'heat.engine.resources.clients.os.glance'.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(GlanceUtilsTests, self).setUp()
|
super(GlanceUtilsTests, self).setUp()
|
||||||
|
|
|
@ -1372,10 +1372,7 @@ class KeystoneClientTest(common.HeatTestCase):
|
||||||
project_id='aprojectid'))
|
project_id='aprojectid'))
|
||||||
|
|
||||||
def _test_url_for(self, service_url, expected_kwargs, ctx=None, **kwargs):
|
def _test_url_for(self, service_url, expected_kwargs, ctx=None, **kwargs):
|
||||||
"""
|
"""Testing url_for depending on different ways to pass region name."""
|
||||||
Helper function for testing url_for depending on different ways to
|
|
||||||
pass region name.
|
|
||||||
"""
|
|
||||||
mock_ks_auth, mock_auth_ref = self._stubs_v3(client=False)
|
mock_ks_auth, mock_auth_ref = self._stubs_v3(client=False)
|
||||||
mock_ks_auth.get_endpoint(mox.IsA(ks_session.Session),
|
mock_ks_auth.get_endpoint(mox.IsA(ks_session.Session),
|
||||||
**expected_kwargs).AndReturn(service_url)
|
**expected_kwargs).AndReturn(service_url)
|
||||||
|
@ -1387,7 +1384,8 @@ class KeystoneClientTest(common.HeatTestCase):
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_url_for(self):
|
def test_url_for(self):
|
||||||
"""
|
"""Test that None value is passed as region name.
|
||||||
|
|
||||||
Test that None value is passed as region name if region name is not
|
Test that None value is passed as region name if region name is not
|
||||||
specified in the config file or as one of the arguments.
|
specified in the config file or as one of the arguments.
|
||||||
"""
|
"""
|
||||||
|
@ -1399,7 +1397,8 @@ class KeystoneClientTest(common.HeatTestCase):
|
||||||
self._test_url_for(service_url, kwargs)
|
self._test_url_for(service_url, kwargs)
|
||||||
|
|
||||||
def test_url_for_with_region(self):
|
def test_url_for_with_region(self):
|
||||||
"""
|
"""Test that region name passed as argument.
|
||||||
|
|
||||||
Test that region name passed as argument is not override by region name
|
Test that region name passed as argument is not override by region name
|
||||||
specified in the config file.
|
specified in the config file.
|
||||||
"""
|
"""
|
||||||
|
@ -1411,7 +1410,8 @@ class KeystoneClientTest(common.HeatTestCase):
|
||||||
self._test_url_for(service_url, kwargs, None, **kwargs)
|
self._test_url_for(service_url, kwargs, None, **kwargs)
|
||||||
|
|
||||||
def test_url_for_with_region_name_from_config(self):
|
def test_url_for_with_region_name_from_config(self):
|
||||||
"""
|
"""Test default region name for services from config file is passed.
|
||||||
|
|
||||||
Test that default region name for services from config file is passed
|
Test that default region name for services from config file is passed
|
||||||
if region name is not specified in arguments.
|
if region name is not specified in arguments.
|
||||||
"""
|
"""
|
||||||
|
@ -1425,7 +1425,8 @@ class KeystoneClientTest(common.HeatTestCase):
|
||||||
self._test_url_for(service_url, kwargs)
|
self._test_url_for(service_url, kwargs)
|
||||||
|
|
||||||
def test_url_for_with_region_name_from_context(self):
|
def test_url_for_with_region_name_from_context(self):
|
||||||
"""
|
"""Test that default region name for services from context is passed.
|
||||||
|
|
||||||
Test that default region name for services from context is passed
|
Test that default region name for services from context is passed
|
||||||
if region name is not specified in arguments.
|
if region name is not specified in arguments.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -40,10 +40,7 @@ class NovaClientPluginTestCase(common.HeatTestCase):
|
||||||
|
|
||||||
|
|
||||||
class NovaClientPluginTests(NovaClientPluginTestCase):
|
class NovaClientPluginTests(NovaClientPluginTestCase):
|
||||||
"""
|
"""Basic tests for :module:'heat.engine.clients.os.nova'."""
|
||||||
Basic tests for the helper methods in
|
|
||||||
:module:'heat.engine.clients.os.nova'.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def test_create(self):
|
def test_create(self):
|
||||||
context = utils.dummy_context()
|
context = utils.dummy_context()
|
||||||
|
@ -393,9 +390,7 @@ class NovaClientPluginMetadataTests(NovaClientPluginTestCase):
|
||||||
self.assertEqual(expected, self.nova_plugin.meta_serialize(original))
|
self.assertEqual(expected, self.nova_plugin.meta_serialize(original))
|
||||||
|
|
||||||
def test_serialize_no_value(self):
|
def test_serialize_no_value(self):
|
||||||
"""This test is to prove that the user can only pass in a dict to nova
|
"""Prove that the user can only pass in a dict to nova metadata."""
|
||||||
metadata.
|
|
||||||
"""
|
|
||||||
excp = self.assertRaises(exception.StackValidationFailed,
|
excp = self.assertRaises(exception.StackValidationFailed,
|
||||||
self.nova_plugin.meta_serialize, "foo")
|
self.nova_plugin.meta_serialize, "foo")
|
||||||
self.assertIn('metadata needs to be a Map', six.text_type(excp))
|
self.assertIn('metadata needs to be a Map', six.text_type(excp))
|
||||||
|
|
|
@ -24,10 +24,7 @@ from heat.tests import utils
|
||||||
|
|
||||||
|
|
||||||
class SaharaUtilsTests(common.HeatTestCase):
|
class SaharaUtilsTests(common.HeatTestCase):
|
||||||
"""
|
"""Basic tests :module:'heat.engine.resources.clients.os.sahara'."""
|
||||||
Basic tests for the helper methods in
|
|
||||||
:module:'heat.engine.resources.clients.os.sahara'.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(SaharaUtilsTests, self).setUp()
|
super(SaharaUtilsTests, self).setUp()
|
||||||
|
|
|
@ -23,10 +23,10 @@ from heat.tests import utils
|
||||||
|
|
||||||
|
|
||||||
class Engine(message_processor.MessageProcessor):
|
class Engine(message_processor.MessageProcessor):
|
||||||
'''
|
"""Wrapper to the engine service.
|
||||||
Wrapper to the engine service. Methods of this
|
|
||||||
class will be called from the scenario tests.
|
Methods of this class will be called from the scenario tests.
|
||||||
'''
|
"""
|
||||||
|
|
||||||
queue = message_queue.MessageQueue('engine')
|
queue = message_queue.MessageQueue('engine')
|
||||||
|
|
||||||
|
@ -34,9 +34,7 @@ class Engine(message_processor.MessageProcessor):
|
||||||
super(Engine, self).__init__('engine')
|
super(Engine, self).__init__('engine')
|
||||||
|
|
||||||
def scenario_template_to_hot(self, scenario_tmpl):
|
def scenario_template_to_hot(self, scenario_tmpl):
|
||||||
'''
|
"""Converts the scenario template into hot template."""
|
||||||
Converts the scenario template into hot template.
|
|
||||||
'''
|
|
||||||
hot_tmpl = {"heat_template_version": "2013-05-23"}
|
hot_tmpl = {"heat_template_version": "2013-05-23"}
|
||||||
resources = {}
|
resources = {}
|
||||||
for res_name, res_def in six.iteritems(scenario_tmpl.resources):
|
for res_name, res_def in six.iteritems(scenario_tmpl.resources):
|
||||||
|
|
|
@ -21,12 +21,13 @@ LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def asynchronous(function):
|
def asynchronous(function):
|
||||||
'''Decorator for MessageProcessor methods to make them asynchronous.
|
"""Decorator for MessageProcessor methods to make them asynchronous.
|
||||||
|
|
||||||
To use, simply call the method as usual. Instead of being executed
|
To use, simply call the method as usual. Instead of being executed
|
||||||
immediately, it will be placed on the queue for the MessageProcessor and
|
immediately, it will be placed on the queue for the MessageProcessor and
|
||||||
run on a future iteration of the event loop.
|
run on a future iteration of the event loop.
|
||||||
'''
|
"""
|
||||||
|
|
||||||
arg_names = inspect.getargspec(function).args
|
arg_names = inspect.getargspec(function).args
|
||||||
MessageData = collections.namedtuple(function.__name__, arg_names[1:])
|
MessageData = collections.namedtuple(function.__name__, arg_names[1:])
|
||||||
|
|
||||||
|
@ -76,9 +77,7 @@ class MessageProcessor(object):
|
||||||
|
|
||||||
@asynchronous
|
@asynchronous
|
||||||
def noop(self, count=1):
|
def noop(self, count=1):
|
||||||
'''
|
"""Insert <count> No-op operations in the message queue."""
|
||||||
Insert <count> No-op operations in the message queue.
|
|
||||||
'''
|
|
||||||
assert isinstance(count, int)
|
assert isinstance(count, int)
|
||||||
if count > 1:
|
if count > 1:
|
||||||
self.queue.send_priority('noop',
|
self.queue.send_priority('noop',
|
||||||
|
@ -86,24 +85,19 @@ class MessageProcessor(object):
|
||||||
|
|
||||||
@asynchronous
|
@asynchronous
|
||||||
def _execute(self, func):
|
def _execute(self, func):
|
||||||
'''
|
"""Insert a function call in the message queue.
|
||||||
Insert a function call in the message queue.
|
|
||||||
|
|
||||||
The function takes no arguments, so use functools.partial to curry the
|
The function takes no arguments, so use functools.partial to curry the
|
||||||
arguments before passing it here.
|
arguments before passing it here.
|
||||||
'''
|
"""
|
||||||
func()
|
func()
|
||||||
|
|
||||||
def call(self, func, *args, **kwargs):
|
def call(self, func, *args, **kwargs):
|
||||||
'''
|
"""Insert a function call in the message queue."""
|
||||||
Insert a function call in the message queue.
|
|
||||||
'''
|
|
||||||
self._execute(functools.partial(func, *args, **kwargs))
|
self._execute(functools.partial(func, *args, **kwargs))
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
'''
|
"""Delete all the messages from the queue."""
|
||||||
Delete all the messages from the queue.
|
|
||||||
'''
|
|
||||||
self.queue.clear()
|
self.queue.clear()
|
||||||
|
|
||||||
__all__ = ['MessageProcessor', 'asynchronous']
|
__all__ = ['MessageProcessor', 'asynchronous']
|
||||||
|
|
|
@ -127,10 +127,12 @@ class ServiceStackUpdateTest(common.HeatTestCase):
|
||||||
self.assertEqual(stk.identifier(), result)
|
self.assertEqual(stk.identifier(), result)
|
||||||
|
|
||||||
def test_stack_update_existing_parameters_remove(self):
|
def test_stack_update_existing_parameters_remove(self):
|
||||||
'''Use a template with existing parameters, then update with a
|
"""Test case for updating stack with changed parameters.
|
||||||
|
|
||||||
|
Use a template with existing parameters, then update with a
|
||||||
template containing additional parameters and a list of
|
template containing additional parameters and a list of
|
||||||
parameters to be removed.
|
parameters to be removed.
|
||||||
'''
|
"""
|
||||||
stack_name = 'service_update_test_stack_existing_parameters_remove'
|
stack_name = 'service_update_test_stack_existing_parameters_remove'
|
||||||
update_params = {'encrypted_param_names': [],
|
update_params = {'encrypted_param_names': [],
|
||||||
'parameter_defaults': {},
|
'parameter_defaults': {},
|
||||||
|
@ -227,9 +229,11 @@ class ServiceStackUpdateTest(common.HeatTestCase):
|
||||||
self.assertEqual(stk.identifier(), result)
|
self.assertEqual(stk.identifier(), result)
|
||||||
|
|
||||||
def test_stack_update_existing_parameter_defaults(self):
|
def test_stack_update_existing_parameter_defaults(self):
|
||||||
'''Use a template with existing flag and ensure the
|
"""Ensure the environment parameter_defaults are preserved.
|
||||||
environment parameter_defaults are preserved.
|
|
||||||
'''
|
Use a template with existing flag and ensure the environment
|
||||||
|
parameter_defaults are preserved.
|
||||||
|
"""
|
||||||
stack_name = 'service_update_test_stack_existing_param_defaults'
|
stack_name = 'service_update_test_stack_existing_param_defaults'
|
||||||
intial_params = {'encrypted_param_names': [],
|
intial_params = {'encrypted_param_names': [],
|
||||||
'parameter_defaults': {'mydefault': 123},
|
'parameter_defaults': {'mydefault': 123},
|
||||||
|
|
|
@ -250,10 +250,11 @@ def clean_up_stack(stack, delete_res=True):
|
||||||
|
|
||||||
|
|
||||||
def stack_context(stack_name, create_res=True):
|
def stack_context(stack_name, create_res=True):
|
||||||
"""
|
"""Decorator for creating and deleting stack.
|
||||||
|
|
||||||
Decorator which creates a stack by using the test case's context and
|
Decorator which creates a stack by using the test case's context and
|
||||||
deletes it afterwards to ensure tests clean up their stacks regardless
|
deletes it afterwards to ensure tests clean up their stacks regardless
|
||||||
of test success/failure
|
of test success/failure.
|
||||||
"""
|
"""
|
||||||
def stack_delete(test_fn):
|
def stack_delete(test_fn):
|
||||||
@six.wraps(test_fn)
|
@six.wraps(test_fn)
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
"""
|
"""A fake server that "responds" to API methods with pre-canned responses.
|
||||||
A fake server that "responds" to API methods with pre-canned responses.
|
|
||||||
|
|
||||||
All of these responses come from the spec, so if for some reason the spec's
|
All of these responses come from the spec, so if for some reason the spec's
|
||||||
wrong the tests might raise AssertionError. I've indicated in comments the
|
wrong the tests might raise AssertionError. I've indicated in comments the
|
||||||
|
@ -28,9 +27,7 @@ from heat.common import context
|
||||||
class FakeClient(object):
|
class FakeClient(object):
|
||||||
|
|
||||||
def assert_called(self, method, url, body=None, pos=-1):
|
def assert_called(self, method, url, body=None, pos=-1):
|
||||||
"""
|
"""Assert that an API method was just called."""
|
||||||
Assert than an API method was just called.
|
|
||||||
"""
|
|
||||||
expected = (method, url)
|
expected = (method, url)
|
||||||
called = self.client.callstack[pos][0:2]
|
called = self.client.callstack[pos][0:2]
|
||||||
|
|
||||||
|
@ -44,9 +41,7 @@ class FakeClient(object):
|
||||||
assert self.client.callstack[pos][2] == body
|
assert self.client.callstack[pos][2] == body
|
||||||
|
|
||||||
def assert_called_anytime(self, method, url, body=None):
|
def assert_called_anytime(self, method, url, body=None):
|
||||||
"""
|
"""Assert that an API method was called anytime in the test."""
|
||||||
Assert than an API method was called anytime in the test.
|
|
||||||
"""
|
|
||||||
expected = (method, url)
|
expected = (method, url)
|
||||||
|
|
||||||
assert self.client.callstack, ("Expected %s %s but no calls "
|
assert self.client.callstack, ("Expected %s %s but no calls "
|
||||||
|
|
|
@ -28,9 +28,7 @@ LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class GenericResource(resource.Resource):
|
class GenericResource(resource.Resource):
|
||||||
'''
|
"""Dummy resource for use in tests."""
|
||||||
Dummy resource for use in tests
|
|
||||||
'''
|
|
||||||
properties_schema = {}
|
properties_schema = {}
|
||||||
attributes_schema = collections.OrderedDict([
|
attributes_schema = collections.OrderedDict([
|
||||||
('foo', attributes.Schema('A generic attribute')),
|
('foo', attributes.Schema('A generic attribute')),
|
||||||
|
|
|
@ -1646,9 +1646,10 @@ class ServersTest(common.HeatTestCase):
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_server_update_nova_metadata_complex(self):
|
def test_server_update_nova_metadata_complex(self):
|
||||||
"""
|
"""Test that complex metadata values are correctly serialized to JSON.
|
||||||
Test that complex metadata values are correctly serialized
|
|
||||||
to JSON when sent to Nova.
|
Test that complex metadata values are correctly serialized to JSON when
|
||||||
|
sent to Nova.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return_server = self.fc.servers.list()[1]
|
return_server = self.fc.servers.list()[1]
|
||||||
|
@ -1720,9 +1721,7 @@ class ServersTest(common.HeatTestCase):
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_server_update_server_name(self):
|
def test_server_update_server_name(self):
|
||||||
"""
|
"""Server.handle_update supports changing the name."""
|
||||||
Server.handle_update supports changing the name.
|
|
||||||
"""
|
|
||||||
return_server = self.fc.servers.list()[1]
|
return_server = self.fc.servers.list()[1]
|
||||||
return_server.id = '5678'
|
return_server.id = '5678'
|
||||||
server = self._create_test_server(return_server,
|
server = self._create_test_server(return_server,
|
||||||
|
@ -1743,9 +1742,7 @@ class ServersTest(common.HeatTestCase):
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_server_update_server_admin_password(self):
|
def test_server_update_server_admin_password(self):
|
||||||
"""
|
"""Server.handle_update supports changing the admin password."""
|
||||||
Server.handle_update supports changing the admin password.
|
|
||||||
"""
|
|
||||||
return_server = self.fc.servers.list()[1]
|
return_server = self.fc.servers.list()[1]
|
||||||
return_server.id = '5678'
|
return_server.id = '5678'
|
||||||
server = self._create_test_server(return_server,
|
server = self._create_test_server(return_server,
|
||||||
|
@ -1764,7 +1761,8 @@ class ServersTest(common.HeatTestCase):
|
||||||
self.assertEqual(1, return_server.change_password.call_count)
|
self.assertEqual(1, return_server.change_password.call_count)
|
||||||
|
|
||||||
def test_server_update_server_flavor(self):
|
def test_server_update_server_flavor(self):
|
||||||
"""
|
"""Tests update server changing the flavor.
|
||||||
|
|
||||||
Server.handle_update supports changing the flavor, and makes
|
Server.handle_update supports changing the flavor, and makes
|
||||||
the change making a resize API call against Nova.
|
the change making a resize API call against Nova.
|
||||||
"""
|
"""
|
||||||
|
@ -1811,7 +1809,8 @@ class ServersTest(common.HeatTestCase):
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_server_update_server_flavor_failed(self):
|
def test_server_update_server_flavor_failed(self):
|
||||||
"""
|
"""Check raising exception due to resize call failing.
|
||||||
|
|
||||||
If the status after a resize is not VERIFY_RESIZE, it means the resize
|
If the status after a resize is not VERIFY_RESIZE, it means the resize
|
||||||
call failed, so we raise an explicit error.
|
call failed, so we raise an explicit error.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -46,10 +46,11 @@ RESOURCE_TYPE = 'OS::Monasca::AlarmDefinition'
|
||||||
|
|
||||||
|
|
||||||
class MonascaAlarmDefinition(alarm_definition.MonascaAlarmDefinition):
|
class MonascaAlarmDefinition(alarm_definition.MonascaAlarmDefinition):
|
||||||
'''
|
"""This class overrides the is_service_available to return True.
|
||||||
|
|
||||||
Monasca service is not available by default. So, this class overrides
|
Monasca service is not available by default. So, this class overrides
|
||||||
the is_service_available to return True
|
the is_service_available to return True.
|
||||||
'''
|
"""
|
||||||
@classmethod
|
@classmethod
|
||||||
def is_service_available(cls, context):
|
def is_service_available(cls, context):
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -40,10 +40,11 @@ RESOURCE_TYPE = 'OS::Monasca::Notification'
|
||||||
|
|
||||||
|
|
||||||
class MonascaNotification(notification.MonascaNotification):
|
class MonascaNotification(notification.MonascaNotification):
|
||||||
'''
|
"""This class overrides the is_service_available to return True.
|
||||||
|
|
||||||
Monasca service is not available by default. So, this class overrides
|
Monasca service is not available by default. So, this class overrides
|
||||||
the is_service_available to return True
|
the is_service_available to return True.
|
||||||
'''
|
"""
|
||||||
@classmethod
|
@classmethod
|
||||||
def is_service_available(cls, context):
|
def is_service_available(cls, context):
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -114,9 +114,7 @@ class TestRequestContext(common.HeatTestCase):
|
||||||
self.assertFalse(ctx.is_admin)
|
self.assertFalse(ctx.is_admin)
|
||||||
|
|
||||||
def test_keystone_v3_endpoint_in_context(self):
|
def test_keystone_v3_endpoint_in_context(self):
|
||||||
"""Ensure that the context is the preferred source for the
|
"""Ensure that the context is the preferred source for the auth_uri."""
|
||||||
auth_uri.
|
|
||||||
"""
|
|
||||||
cfg.CONF.set_override('auth_uri', 'http://xyz',
|
cfg.CONF.set_override('auth_uri', 'http://xyz',
|
||||||
group='clients_keystone')
|
group='clients_keystone')
|
||||||
policy_check = 'heat.common.policy.Enforcer.check_is_admin'
|
policy_check = 'heat.common.policy.Enforcer.check_is_admin'
|
||||||
|
@ -128,7 +126,9 @@ class TestRequestContext(common.HeatTestCase):
|
||||||
'http://example.com:5000/v3')
|
'http://example.com:5000/v3')
|
||||||
|
|
||||||
def test_keystone_v3_endpoint_in_clients_keystone_config(self):
|
def test_keystone_v3_endpoint_in_clients_keystone_config(self):
|
||||||
"""Ensure that the [clients_keystone] section of the configuration is
|
"""Ensure that the [clients_keystone] section is the preferred source.
|
||||||
|
|
||||||
|
Ensure that the [clients_keystone] section of the configuration is
|
||||||
the preferred source when the context does not have the auth_uri.
|
the preferred source when the context does not have the auth_uri.
|
||||||
"""
|
"""
|
||||||
cfg.CONF.set_override('auth_uri', 'http://xyz',
|
cfg.CONF.set_override('auth_uri', 'http://xyz',
|
||||||
|
@ -149,7 +149,9 @@ class TestRequestContext(common.HeatTestCase):
|
||||||
self.assertEqual(ctx.keystone_v3_endpoint, 'http://xyz/v3')
|
self.assertEqual(ctx.keystone_v3_endpoint, 'http://xyz/v3')
|
||||||
|
|
||||||
def test_keystone_v3_endpoint_in_keystone_authtoken_config(self):
|
def test_keystone_v3_endpoint_in_keystone_authtoken_config(self):
|
||||||
"""Ensure that the [keystone_authtoken] section of the configuration
|
"""Ensure that the [keystone_authtoken] section is used.
|
||||||
|
|
||||||
|
Ensure that the [keystone_authtoken] section of the configuration
|
||||||
is used when the auth_uri is not defined in the context or the
|
is used when the auth_uri is not defined in the context or the
|
||||||
[clients_keystone] section.
|
[clients_keystone] section.
|
||||||
"""
|
"""
|
||||||
|
@ -163,7 +165,9 @@ class TestRequestContext(common.HeatTestCase):
|
||||||
self.assertEqual(ctx.keystone_v3_endpoint, 'http://abc/v3')
|
self.assertEqual(ctx.keystone_v3_endpoint, 'http://abc/v3')
|
||||||
|
|
||||||
def test_keystone_v3_endpoint_not_set_in_config(self):
|
def test_keystone_v3_endpoint_not_set_in_config(self):
|
||||||
"""Ensure an exception is raised when the auth_uri cannot be obtained
|
"""Ensure an exception is raised when the auth_uri cannot be obtained.
|
||||||
|
|
||||||
|
Ensure an exception is raised when the auth_uri cannot be obtained
|
||||||
from any source.
|
from any source.
|
||||||
"""
|
"""
|
||||||
policy_check = 'heat.common.policy.Enforcer.check_is_admin'
|
policy_check = 'heat.common.policy.Enforcer.check_is_admin'
|
||||||
|
|
|
@ -278,13 +278,12 @@ class SchemaTest(common.HeatTestCase):
|
||||||
six.text_type(err))
|
six.text_type(err))
|
||||||
|
|
||||||
def test_allowed_values_numeric_int(self):
|
def test_allowed_values_numeric_int(self):
|
||||||
'''
|
"""Test AllowedValues constraint for numeric integer values.
|
||||||
Test AllowedValues constraint for numeric integer values.
|
|
||||||
|
|
||||||
Test if the AllowedValues constraint works for numeric values in any
|
Test if the AllowedValues constraint works for numeric values in any
|
||||||
combination of numeric strings or numbers in the constraint and
|
combination of numeric strings or numbers in the constraint and
|
||||||
numeric strings or numbers as value.
|
numeric strings or numbers as value.
|
||||||
'''
|
"""
|
||||||
|
|
||||||
# Allowed values defined as integer numbers
|
# Allowed values defined as integer numbers
|
||||||
schema = constraints.Schema(
|
schema = constraints.Schema(
|
||||||
|
@ -321,13 +320,12 @@ class SchemaTest(common.HeatTestCase):
|
||||||
six.text_type(err))
|
six.text_type(err))
|
||||||
|
|
||||||
def test_allowed_values_numeric_float(self):
|
def test_allowed_values_numeric_float(self):
|
||||||
'''
|
"""Test AllowedValues constraint for numeric floating point values.
|
||||||
Test AllowedValues constraint for numeric floating point values.
|
|
||||||
|
|
||||||
Test if the AllowedValues constraint works for numeric values in any
|
Test if the AllowedValues constraint works for numeric values in any
|
||||||
combination of numeric strings or numbers in the constraint and
|
combination of numeric strings or numbers in the constraint and
|
||||||
numeric strings or numbers as value.
|
numeric strings or numbers as value.
|
||||||
'''
|
"""
|
||||||
|
|
||||||
# Allowed values defined as numbers
|
# Allowed values defined as numbers
|
||||||
schema = constraints.Schema(
|
schema = constraints.Schema(
|
||||||
|
@ -364,7 +362,7 @@ class SchemaTest(common.HeatTestCase):
|
||||||
six.text_type(err))
|
six.text_type(err))
|
||||||
|
|
||||||
def test_to_schema_type_int(self):
|
def test_to_schema_type_int(self):
|
||||||
'''Test Schema.to_schema_type method for type Integer.'''
|
"""Test Schema.to_schema_type method for type Integer."""
|
||||||
schema = constraints.Schema('Integer')
|
schema = constraints.Schema('Integer')
|
||||||
# test valid values, i.e. integeres as string or number
|
# test valid values, i.e. integeres as string or number
|
||||||
res = schema.to_schema_type(1)
|
res = schema.to_schema_type(1)
|
||||||
|
@ -384,7 +382,7 @@ class SchemaTest(common.HeatTestCase):
|
||||||
six.text_type(err))
|
six.text_type(err))
|
||||||
|
|
||||||
def test_to_schema_type_num(self):
|
def test_to_schema_type_num(self):
|
||||||
'''Test Schema.to_schema_type method for type Number.'''
|
"""Test Schema.to_schema_type method for type Number."""
|
||||||
schema = constraints.Schema('Number')
|
schema = constraints.Schema('Number')
|
||||||
res = schema.to_schema_type(1)
|
res = schema.to_schema_type(1)
|
||||||
self.assertIsInstance(res, int)
|
self.assertIsInstance(res, int)
|
||||||
|
@ -400,7 +398,7 @@ class SchemaTest(common.HeatTestCase):
|
||||||
six.text_type(err))
|
six.text_type(err))
|
||||||
|
|
||||||
def test_to_schema_type_string(self):
|
def test_to_schema_type_string(self):
|
||||||
'''Test Schema.to_schema_type method for type String.'''
|
"""Test Schema.to_schema_type method for type String."""
|
||||||
schema = constraints.Schema('String')
|
schema = constraints.Schema('String')
|
||||||
res = schema.to_schema_type('one')
|
res = schema.to_schema_type('one')
|
||||||
self.assertIsInstance(res, six.string_types)
|
self.assertIsInstance(res, six.string_types)
|
||||||
|
@ -414,7 +412,7 @@ class SchemaTest(common.HeatTestCase):
|
||||||
self.assertIsInstance(res, six.string_types)
|
self.assertIsInstance(res, six.string_types)
|
||||||
|
|
||||||
def test_to_schema_type_boolean(self):
|
def test_to_schema_type_boolean(self):
|
||||||
'''Test Schema.to_schema_type method for type Boolean.'''
|
"""Test Schema.to_schema_type method for type Boolean."""
|
||||||
schema = constraints.Schema('Boolean')
|
schema = constraints.Schema('Boolean')
|
||||||
|
|
||||||
true_values = [1, '1', True, 'true', 'True', 'yes', 'Yes']
|
true_values = [1, '1', True, 'true', 'True', 'yes', 'Yes']
|
||||||
|
@ -434,14 +432,14 @@ class SchemaTest(common.HeatTestCase):
|
||||||
six.text_type(err))
|
six.text_type(err))
|
||||||
|
|
||||||
def test_to_schema_type_map(self):
|
def test_to_schema_type_map(self):
|
||||||
'''Test Schema.to_schema_type method for type Map.'''
|
"""Test Schema.to_schema_type method for type Map."""
|
||||||
schema = constraints.Schema('Map')
|
schema = constraints.Schema('Map')
|
||||||
res = schema.to_schema_type({'a': 'aa', 'b': 'bb'})
|
res = schema.to_schema_type({'a': 'aa', 'b': 'bb'})
|
||||||
self.assertIsInstance(res, dict)
|
self.assertIsInstance(res, dict)
|
||||||
self.assertEqual({'a': 'aa', 'b': 'bb'}, res)
|
self.assertEqual({'a': 'aa', 'b': 'bb'}, res)
|
||||||
|
|
||||||
def test_to_schema_type_list(self):
|
def test_to_schema_type_list(self):
|
||||||
'''Test Schema.to_schema_type method for type List.'''
|
"""Test Schema.to_schema_type method for type List."""
|
||||||
schema = constraints.Schema('List')
|
schema = constraints.Schema('List')
|
||||||
res = schema.to_schema_type(['a', 'b'])
|
res = schema.to_schema_type(['a', 'b'])
|
||||||
self.assertIsInstance(res, list)
|
self.assertIsInstance(res, list)
|
||||||
|
|
|
@ -133,6 +133,7 @@ class StackConvergenceCreateUpdateDeleteTest(common.HeatTestCase):
|
||||||
|
|
||||||
def _mock_convg_db_update_requires(self, key_id=False):
|
def _mock_convg_db_update_requires(self, key_id=False):
|
||||||
"""Updates requires column of resources.
|
"""Updates requires column of resources.
|
||||||
|
|
||||||
Required for testing the generation of convergence dependency graph
|
Required for testing the generation of convergence dependency graph
|
||||||
on an update.
|
on an update.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -65,10 +65,11 @@ class CloudWatchAlarmTest(common.HeatTestCase):
|
||||||
return rsrc
|
return rsrc
|
||||||
|
|
||||||
def test_mem_alarm_high_update_no_replace(self):
|
def test_mem_alarm_high_update_no_replace(self):
|
||||||
'''
|
"""Test case for updating the alarm with updatable properties.
|
||||||
Make sure that we can change the update-able properties
|
|
||||||
|
Make sure that we can change the updatable properties
|
||||||
without replacing the Alarm rsrc.
|
without replacing the Alarm rsrc.
|
||||||
'''
|
"""
|
||||||
t = template_format.parse(alarm_template)
|
t = template_format.parse(alarm_template)
|
||||||
|
|
||||||
# short circuit the alarm's references
|
# short circuit the alarm's references
|
||||||
|
@ -101,10 +102,11 @@ class CloudWatchAlarmTest(common.HeatTestCase):
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_mem_alarm_high_update_replace(self):
|
def test_mem_alarm_high_update_replace(self):
|
||||||
'''
|
"""Test case for replacing the alarm with non-updatable properties.
|
||||||
|
|
||||||
Make sure that the Alarm resource IS replaced when non-update-able
|
Make sure that the Alarm resource IS replaced when non-update-able
|
||||||
properties are changed.
|
properties are changed.
|
||||||
'''
|
"""
|
||||||
t = template_format.parse(alarm_template)
|
t = template_format.parse(alarm_template)
|
||||||
|
|
||||||
# short circuit the alarm's references
|
# short circuit the alarm's references
|
||||||
|
|
|
@ -52,8 +52,9 @@ rds_template = '''
|
||||||
|
|
||||||
|
|
||||||
class DBInstance(resource.Resource):
|
class DBInstance(resource.Resource):
|
||||||
"""This is copied from the old DBInstance
|
"""Verify the schema of the new TemplateResource.
|
||||||
to verify the schema of the new TemplateResource.
|
|
||||||
|
This is copied from the old DBInstance.
|
||||||
"""
|
"""
|
||||||
properties_schema = {
|
properties_schema = {
|
||||||
'DBSnapshotIdentifier': properties.Schema(
|
'DBSnapshotIdentifier': properties.Schema(
|
||||||
|
@ -152,9 +153,7 @@ class DBInstanceTest(common.HeatTestCase):
|
||||||
super(DBInstanceTest, self).setUp()
|
super(DBInstanceTest, self).setUp()
|
||||||
|
|
||||||
def test_dbinstance(self):
|
def test_dbinstance(self):
|
||||||
"""test that the Template is parsable and
|
"""Test that Template is parsable and publishes correct properties."""
|
||||||
publishes the correct properties.
|
|
||||||
"""
|
|
||||||
templ = template.Template(template_format.parse(rds_template))
|
templ = template.Template(template_format.parse(rds_template))
|
||||||
stack = parser.Stack(utils.dummy_context(), 'test_stack',
|
stack = parser.Stack(utils.dummy_context(), 'test_stack',
|
||||||
templ)
|
templ)
|
||||||
|
|
|
@ -954,9 +954,7 @@ class FormatValidateParameterTest(common.HeatTestCase):
|
||||||
]
|
]
|
||||||
|
|
||||||
def test_format_validate_parameter(self):
|
def test_format_validate_parameter(self):
|
||||||
"""
|
"""Test format of a parameter."""
|
||||||
Test format of a parameter.
|
|
||||||
"""
|
|
||||||
|
|
||||||
t = template_format.parse(self.template % self.param)
|
t = template_format.parse(self.template % self.param)
|
||||||
tmpl = template.Template(t)
|
tmpl = template.Template(t)
|
||||||
|
|
|
@ -957,16 +957,15 @@ class StackServiceTest(common.HeatTestCase):
|
||||||
def test_list_template_functions(self, templ_mock):
|
def test_list_template_functions(self, templ_mock):
|
||||||
|
|
||||||
class DummyFunc1(object):
|
class DummyFunc1(object):
|
||||||
"""
|
"""Dummy Func1.
|
||||||
Dummy Func1
|
|
||||||
|
|
||||||
Dummy Func1 Long Description
|
Dummy Func1 Long Description.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class DummyFunc2(object):
|
class DummyFunc2(object):
|
||||||
"""Dummy Func2
|
"""Dummy Func2.
|
||||||
|
|
||||||
Dummy Func2 Long Description
|
Dummy Func2 Long Description.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
plugin_mock = mock.Mock(
|
plugin_mock = mock.Mock(
|
||||||
|
@ -982,9 +981,9 @@ class StackServiceTest(common.HeatTestCase):
|
||||||
templ_mock.return_value = DummyMgr()
|
templ_mock.return_value = DummyMgr()
|
||||||
functions = self.eng.list_template_functions(self.ctx, 'dummytemplate')
|
functions = self.eng.list_template_functions(self.ctx, 'dummytemplate')
|
||||||
expected = [{'functions': 'dummy1',
|
expected = [{'functions': 'dummy1',
|
||||||
'description': 'Dummy Func1'},
|
'description': 'Dummy Func1.'},
|
||||||
{'functions': 'dummy2',
|
{'functions': 'dummy2',
|
||||||
'description': 'Dummy Func2'}]
|
'description': 'Dummy Func2.'}]
|
||||||
self.assertEqual(sorted(expected, key=lambda k: k['functions']),
|
self.assertEqual(sorted(expected, key=lambda k: k['functions']),
|
||||||
sorted(functions, key=lambda k: k['functions']))
|
sorted(functions, key=lambda k: k['functions']))
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,10 @@ class StackServiceWatcherTest(common.HeatTestCase):
|
||||||
def test_periodic_watch_task_not_created(self, watch_rule_update,
|
def test_periodic_watch_task_not_created(self, watch_rule_update,
|
||||||
watch_rule_get_all_by_stack,
|
watch_rule_get_all_by_stack,
|
||||||
stack_get_all_by_owner_id):
|
stack_get_all_by_owner_id):
|
||||||
"""If there is no cloud watch lite alarm, then don't create
|
"""Test case for not creating periodic task for cloud watch lite alarm.
|
||||||
a periodic task for it.
|
|
||||||
|
If there is no cloud watch lite alarm, then don't create a periodic
|
||||||
|
task for it.
|
||||||
"""
|
"""
|
||||||
stack_id = 83
|
stack_id = 83
|
||||||
watch_rule_get_all_by_stack.return_value = []
|
watch_rule_get_all_by_stack.return_value = []
|
||||||
|
@ -56,8 +58,10 @@ class StackServiceWatcherTest(common.HeatTestCase):
|
||||||
def test_periodic_watch_task_created(self, watch_rule_update,
|
def test_periodic_watch_task_created(self, watch_rule_update,
|
||||||
watch_rule_get_all_by_stack,
|
watch_rule_get_all_by_stack,
|
||||||
stack_get_all_by_owner_id):
|
stack_get_all_by_owner_id):
|
||||||
"""If there is no cloud watch lite alarm, then DO create
|
"""Test case for creating periodic task for cloud watch lite alarm.
|
||||||
a periodic task for it.
|
|
||||||
|
If there is no cloud watch lite alarm, then DO create a periodic task
|
||||||
|
for it.
|
||||||
"""
|
"""
|
||||||
stack_id = 86
|
stack_id = 86
|
||||||
wr1 = mock.Mock()
|
wr1 = mock.Mock()
|
||||||
|
|
|
@ -289,8 +289,12 @@ class GlobalEnvLoadingTest(common.HeatTestCase):
|
||||||
m_ldir.assert_called_once_with(env_dir + '/*')
|
m_ldir.assert_called_once_with(env_dir + '/*')
|
||||||
|
|
||||||
def test_continue_on_ioerror(self):
|
def test_continue_on_ioerror(self):
|
||||||
"""assert we get all files processed even if there are
|
"""Assert we get all files processed.
|
||||||
processing exceptions.
|
|
||||||
|
Assert we get all files processed even if there are processing
|
||||||
|
exceptions.
|
||||||
|
|
||||||
|
Test uses IOError as side effect of mock open.
|
||||||
"""
|
"""
|
||||||
with mock.patch('glob.glob') as m_ldir:
|
with mock.patch('glob.glob') as m_ldir:
|
||||||
m_ldir.return_value = ['/etc_etc/heat/environment.d/a.yaml',
|
m_ldir.return_value = ['/etc_etc/heat/environment.d/a.yaml',
|
||||||
|
@ -312,8 +316,12 @@ class GlobalEnvLoadingTest(common.HeatTestCase):
|
||||||
self.assertEqual(expected, m_open.call_args_list)
|
self.assertEqual(expected, m_open.call_args_list)
|
||||||
|
|
||||||
def test_continue_on_parse_error(self):
|
def test_continue_on_parse_error(self):
|
||||||
"""assert we get all files processed even if there are
|
"""Assert we get all files processed.
|
||||||
processing exceptions.
|
|
||||||
|
Assert we get all files processed even if there are processing
|
||||||
|
exceptions.
|
||||||
|
|
||||||
|
Test checks case when env content is incorrect.
|
||||||
"""
|
"""
|
||||||
with mock.patch('glob.glob') as m_ldir:
|
with mock.patch('glob.glob') as m_ldir:
|
||||||
m_ldir.return_value = ['/etc_etc/heat/environment.d/a.yaml',
|
m_ldir.return_value = ['/etc_etc/heat/environment.d/a.yaml',
|
||||||
|
|
|
@ -533,8 +533,7 @@ class HOTemplateTest(common.HeatTestCase):
|
||||||
self.assertEqual(snippet_resolved, self.resolve(snippet, tmpl))
|
self.assertEqual(snippet_resolved, self.resolve(snippet, tmpl))
|
||||||
|
|
||||||
def test_str_replace_syntax(self):
|
def test_str_replace_syntax(self):
|
||||||
"""
|
"""Test str_replace function syntax.
|
||||||
Test str_replace function syntax.
|
|
||||||
|
|
||||||
Pass wrong syntax (array instead of dictionary) to function and
|
Pass wrong syntax (array instead of dictionary) to function and
|
||||||
validate that we get a TypeError.
|
validate that we get a TypeError.
|
||||||
|
@ -548,8 +547,7 @@ class HOTemplateTest(common.HeatTestCase):
|
||||||
self.assertRaises(TypeError, self.resolve, snippet, tmpl)
|
self.assertRaises(TypeError, self.resolve, snippet, tmpl)
|
||||||
|
|
||||||
def test_str_replace_invalid_param_keys(self):
|
def test_str_replace_invalid_param_keys(self):
|
||||||
"""
|
"""Test str_replace function parameter keys.
|
||||||
Test str_replace function parameter keys.
|
|
||||||
|
|
||||||
Pass wrong parameters to function and verify that we get
|
Pass wrong parameters to function and verify that we get
|
||||||
a KeyError.
|
a KeyError.
|
||||||
|
@ -568,8 +566,7 @@ class HOTemplateTest(common.HeatTestCase):
|
||||||
self.assertRaises(KeyError, self.resolve, snippet, tmpl)
|
self.assertRaises(KeyError, self.resolve, snippet, tmpl)
|
||||||
|
|
||||||
def test_str_replace_invalid_param_types(self):
|
def test_str_replace_invalid_param_types(self):
|
||||||
"""
|
"""Test str_replace function parameter values.
|
||||||
Test str_replace function parameter values.
|
|
||||||
|
|
||||||
Pass parameter values of wrong type to function and verify that we get
|
Pass parameter values of wrong type to function and verify that we get
|
||||||
a TypeError.
|
a TypeError.
|
||||||
|
@ -755,9 +752,10 @@ class HOTemplateTest(common.HeatTestCase):
|
||||||
self.assertIn(item, snippet_resolved)
|
self.assertIn(item, snippet_resolved)
|
||||||
|
|
||||||
def test_repeat_bad_args(self):
|
def test_repeat_bad_args(self):
|
||||||
"""
|
"""Tests reporting error by repeat function.
|
||||||
Test that the repeat function reports a proper error when missing
|
|
||||||
or invalid arguments.
|
Test that the repeat function reports a proper error when missing or
|
||||||
|
invalid arguments.
|
||||||
"""
|
"""
|
||||||
tmpl = template.Template(hot_kilo_tpl_empty)
|
tmpl = template.Template(hot_kilo_tpl_empty)
|
||||||
|
|
||||||
|
@ -871,7 +869,8 @@ class HOTemplateTest(common.HeatTestCase):
|
||||||
six.text_type(exc))
|
six.text_type(exc))
|
||||||
|
|
||||||
def test_prevent_parameters_access(self):
|
def test_prevent_parameters_access(self):
|
||||||
"""
|
"""Check parameters section inaccessible using the template as a dict.
|
||||||
|
|
||||||
Test that the parameters section can't be accessed using the template
|
Test that the parameters section can't be accessed using the template
|
||||||
as a dictionary.
|
as a dictionary.
|
||||||
"""
|
"""
|
||||||
|
@ -898,7 +897,8 @@ class HOTemplateTest(common.HeatTestCase):
|
||||||
self.assertIn(err_str, six.text_type(keyError))
|
self.assertIn(err_str, six.text_type(keyError))
|
||||||
|
|
||||||
def test_parameters_section_not_iterable(self):
|
def test_parameters_section_not_iterable(self):
|
||||||
"""
|
"""Check parameters section is not returned using the template as iter.
|
||||||
|
|
||||||
Test that the parameters section is not returned when the template is
|
Test that the parameters section is not returned when the template is
|
||||||
used as an iterable.
|
used as an iterable.
|
||||||
"""
|
"""
|
||||||
|
@ -912,8 +912,7 @@ class HOTemplateTest(common.HeatTestCase):
|
||||||
self.assertNotIn('parameters', six.iterkeys(tmpl))
|
self.assertNotIn('parameters', six.iterkeys(tmpl))
|
||||||
|
|
||||||
def test_invalid_hot_version(self):
|
def test_invalid_hot_version(self):
|
||||||
"""
|
"""Test HOT version check.
|
||||||
Test HOT version check.
|
|
||||||
|
|
||||||
Pass an invalid HOT version to template.Template.__new__() and
|
Pass an invalid HOT version to template.Template.__new__() and
|
||||||
validate that we get a ValueError.
|
validate that we get a ValueError.
|
||||||
|
@ -925,8 +924,7 @@ class HOTemplateTest(common.HeatTestCase):
|
||||||
template.Template, hot_tmpl)
|
template.Template, hot_tmpl)
|
||||||
|
|
||||||
def test_valid_hot_version(self):
|
def test_valid_hot_version(self):
|
||||||
"""
|
"""Test HOT version check.
|
||||||
Test HOT version check.
|
|
||||||
|
|
||||||
Pass a valid HOT version to template.Template.__new__() and
|
Pass a valid HOT version to template.Template.__new__() and
|
||||||
validate that we get back a parsed template.
|
validate that we get back a parsed template.
|
||||||
|
@ -1283,9 +1281,8 @@ class HotStackTest(common.HeatTestCase):
|
||||||
|
|
||||||
|
|
||||||
class StackAttributesTest(common.HeatTestCase):
|
class StackAttributesTest(common.HeatTestCase):
|
||||||
"""
|
"""Test get_attr function when stack was created from HOT template."""
|
||||||
Test stack get_attr function when stack was created from HOT template.
|
|
||||||
"""
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(StackAttributesTest, self).setUp()
|
super(StackAttributesTest, self).setUp()
|
||||||
|
|
||||||
|
@ -1414,9 +1411,7 @@ class StackGetAttrValidationTest(common.HeatTestCase):
|
||||||
|
|
||||||
|
|
||||||
class StackParametersTest(common.HeatTestCase):
|
class StackParametersTest(common.HeatTestCase):
|
||||||
"""
|
"""Test get_param function when stack was created from HOT template."""
|
||||||
Test stack get_param function when stack was created from HOT template.
|
|
||||||
"""
|
|
||||||
|
|
||||||
scenarios = [
|
scenarios = [
|
||||||
('Ref_string',
|
('Ref_string',
|
||||||
|
|
|
@ -27,7 +27,8 @@ resources:
|
||||||
|
|
||||||
|
|
||||||
class LifecyclePluginUtilsTests(common.HeatTestCase):
|
class LifecyclePluginUtilsTests(common.HeatTestCase):
|
||||||
"""
|
"""Basic tests for :module:'heat.common.lifecycle_plugin_utils'.
|
||||||
|
|
||||||
Basic tests for the helper methods in
|
Basic tests for the helper methods in
|
||||||
:module:'heat.common.lifecycle_plugin_utils'.
|
:module:'heat.common.lifecycle_plugin_utils'.
|
||||||
"""
|
"""
|
||||||
|
@ -180,9 +181,8 @@ class LifecyclePluginUtilsTests(common.HeatTestCase):
|
||||||
|
|
||||||
|
|
||||||
class TestLifecycleCallout1(lifecycle_plugin.LifecyclePlugin):
|
class TestLifecycleCallout1(lifecycle_plugin.LifecyclePlugin):
|
||||||
'''
|
"""Sample test class for testing pre-op and post-op work on a stack."""
|
||||||
Sample test class for testing pre-op and post-op work on a stack
|
|
||||||
'''
|
|
||||||
def do_pre_op(self, cnxt, stack, current_stack=None, action=None):
|
def do_pre_op(self, cnxt, stack, current_stack=None, action=None):
|
||||||
cnxt.pre_counter_for_unit_test += 1
|
cnxt.pre_counter_for_unit_test += 1
|
||||||
|
|
||||||
|
@ -195,10 +195,11 @@ class TestLifecycleCallout1(lifecycle_plugin.LifecyclePlugin):
|
||||||
|
|
||||||
|
|
||||||
class TestLifecycleCallout2(lifecycle_plugin.LifecyclePlugin):
|
class TestLifecycleCallout2(lifecycle_plugin.LifecyclePlugin):
|
||||||
'''
|
"""Sample test class for testing pre-op and post-op work on a stack.
|
||||||
Sample test class for testing pre-op and post-op work on a stack,
|
|
||||||
different ordinal, and increment counters by 2
|
Different ordinal and increment counters by 2.
|
||||||
'''
|
"""
|
||||||
|
|
||||||
def do_pre_op(self, cnxt, stack, current_stack=None, action=None):
|
def do_pre_op(self, cnxt, stack, current_stack=None, action=None):
|
||||||
cnxt.pre_counter_for_unit_test += 2
|
cnxt.pre_counter_for_unit_test += 2
|
||||||
|
|
||||||
|
@ -211,10 +212,10 @@ class TestLifecycleCallout2(lifecycle_plugin.LifecyclePlugin):
|
||||||
|
|
||||||
|
|
||||||
class TestLifecycleCallout3(lifecycle_plugin.LifecyclePlugin):
|
class TestLifecycleCallout3(lifecycle_plugin.LifecyclePlugin):
|
||||||
'''
|
"""Sample test class for testing pre-op and post-op work on a stack.
|
||||||
Sample test class for testing pre-op and post-op work on a stack,
|
|
||||||
methods raise exceptions
|
Methods raise exceptions.
|
||||||
'''
|
"""
|
||||||
def do_pre_op(self, cnxt, stack, current_stack=None, action=None):
|
def do_pre_op(self, cnxt, stack, current_stack=None, action=None):
|
||||||
raise Exception()
|
raise Exception()
|
||||||
|
|
||||||
|
@ -227,10 +228,10 @@ class TestLifecycleCallout3(lifecycle_plugin.LifecyclePlugin):
|
||||||
|
|
||||||
|
|
||||||
class TestLifecycleCallout4(lifecycle_plugin.LifecyclePlugin):
|
class TestLifecycleCallout4(lifecycle_plugin.LifecyclePlugin):
|
||||||
'''
|
"""Sample test class for testing pre-op and post-op work on a stack.
|
||||||
Sample test class for testing pre-op and post-op work on a stack;
|
|
||||||
do_pre_op, do_post_op both throw exception
|
do_pre_op, do_post_op both throw exception.
|
||||||
'''
|
"""
|
||||||
def do_pre_op(self, cnxt, stack, current_stack=None, action=None):
|
def do_pre_op(self, cnxt, stack, current_stack=None, action=None):
|
||||||
raise Exception()
|
raise Exception()
|
||||||
|
|
||||||
|
@ -243,10 +244,10 @@ class TestLifecycleCallout4(lifecycle_plugin.LifecyclePlugin):
|
||||||
|
|
||||||
|
|
||||||
class TestLifecycleCallout5(lifecycle_plugin.LifecyclePlugin):
|
class TestLifecycleCallout5(lifecycle_plugin.LifecyclePlugin):
|
||||||
'''
|
"""Sample test class for testing pre-op and post-op work on a stack.
|
||||||
Sample test class for testing pre-op and post-op work on a stack;
|
|
||||||
do_post_op throws exception
|
do_post_op throws exception.
|
||||||
'''
|
"""
|
||||||
def do_pre_op(self, cnxt, stack, current_stack=None, action=None):
|
def do_pre_op(self, cnxt, stack, current_stack=None, action=None):
|
||||||
cnxt.pre_counter_for_unit_test += 1
|
cnxt.pre_counter_for_unit_test += 1
|
||||||
|
|
||||||
|
|
|
@ -144,10 +144,11 @@ resources:
|
||||||
|
|
||||||
|
|
||||||
class MetadataRefreshTest(common.HeatTestCase):
|
class MetadataRefreshTest(common.HeatTestCase):
|
||||||
'''
|
"""Metadata gets updated when FnGetAtt() returns something different.
|
||||||
|
|
||||||
The point of the test is to confirm that metadata gets updated
|
The point of the test is to confirm that metadata gets updated
|
||||||
when FnGetAtt() returns something different.
|
when FnGetAtt() returns something different.
|
||||||
'''
|
"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(MetadataRefreshTest, self).setUp()
|
super(MetadataRefreshTest, self).setUp()
|
||||||
|
|
||||||
|
@ -243,13 +244,14 @@ class WaitCondMetadataUpdateTest(common.HeatTestCase):
|
||||||
@mock.patch(('heat.engine.resources.aws.ec2.instance.Instance'
|
@mock.patch(('heat.engine.resources.aws.ec2.instance.Instance'
|
||||||
'.is_service_available'))
|
'.is_service_available'))
|
||||||
def test_wait_meta(self, mock_is_service_available):
|
def test_wait_meta(self, mock_is_service_available):
|
||||||
'''
|
"""Tests valid waitcondition metadata after signal call.
|
||||||
|
|
||||||
1 create stack
|
1 create stack
|
||||||
2 assert empty instance metadata
|
2 assert empty instance metadata
|
||||||
3 service.resource_signal()
|
3 service.resource_signal()
|
||||||
4 assert valid waitcond metadata
|
4 assert valid waitcond metadata
|
||||||
5 assert valid instance metadata
|
5 assert valid instance metadata
|
||||||
'''
|
"""
|
||||||
mock_is_service_available.return_value = True
|
mock_is_service_available.return_value = True
|
||||||
self.stack = self.create_stack()
|
self.stack = self.create_stack()
|
||||||
|
|
||||||
|
@ -299,13 +301,14 @@ class WaitCondMetadataUpdateTest(common.HeatTestCase):
|
||||||
|
|
||||||
|
|
||||||
class MetadataRefreshTestServer(common.HeatTestCase):
|
class MetadataRefreshTestServer(common.HeatTestCase):
|
||||||
'''
|
"""Metadata gets updated when FnGetAtt() returns something different.
|
||||||
|
|
||||||
The point of the test is to confirm that metadata gets updated
|
The point of the test is to confirm that metadata gets updated
|
||||||
when FnGetAtt() returns something different when using a native
|
when FnGetAtt() returns something different when using a native
|
||||||
OS::Nova::Server resource, and that metadata keys set inside the
|
OS::Nova::Server resource, and that metadata keys set inside the
|
||||||
resource (as opposed to in the template), e.g for deployments, don't
|
resource (as opposed to in the template), e.g for deployments, don't
|
||||||
get overwritten on update/refresh.
|
get overwritten on update/refresh.
|
||||||
'''
|
"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(MetadataRefreshTestServer, self).setUp()
|
super(MetadataRefreshTestServer, self).setUp()
|
||||||
|
|
||||||
|
|
|
@ -674,8 +674,7 @@ class ProviderTemplateTest(common.HeatTestCase):
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_template_as_resource(self):
|
def test_template_as_resource(self):
|
||||||
"""
|
"""Test that resulting resource has the right prop and attrib schema.
|
||||||
Test that the resulting resource has the right prop and attrib schema.
|
|
||||||
|
|
||||||
Note that this test requires the Wordpress_Single_Instance.yaml
|
Note that this test requires the Wordpress_Single_Instance.yaml
|
||||||
template in the templates directory since we want to test using a
|
template in the templates directory since we want to test using a
|
||||||
|
@ -734,7 +733,8 @@ class ProviderTemplateTest(common.HeatTestCase):
|
||||||
resources.global_env().registry._registry)
|
resources.global_env().registry._registry)
|
||||||
|
|
||||||
def test_persisted_unregistered_provider_templates(self):
|
def test_persisted_unregistered_provider_templates(self):
|
||||||
"""
|
"""Test that templates are registered correctly.
|
||||||
|
|
||||||
Test that templates persisted in the database prior to
|
Test that templates persisted in the database prior to
|
||||||
https://review.openstack.org/#/c/79953/1 are registered correctly.
|
https://review.openstack.org/#/c/79953/1 are registered correctly.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1665,10 +1665,11 @@ class ResourceTest(common.HeatTestCase):
|
||||||
0)
|
0)
|
||||||
|
|
||||||
def test_create_convergence_sets_requires_for_failure(self):
|
def test_create_convergence_sets_requires_for_failure(self):
|
||||||
'''
|
"""Ensure that requires are computed correctly.
|
||||||
|
|
||||||
Ensure that requires are computed correctly even if resource
|
Ensure that requires are computed correctly even if resource
|
||||||
create fails,
|
create fails.
|
||||||
'''
|
"""
|
||||||
tmpl = rsrc_defn.ResourceDefinition('test_res', 'Foo')
|
tmpl = rsrc_defn.ResourceDefinition('test_res', 'Foo')
|
||||||
res = generic_rsrc.GenericResource('test_res', tmpl, self.stack)
|
res = generic_rsrc.GenericResource('test_res', tmpl, self.stack)
|
||||||
res._store()
|
res._store()
|
||||||
|
@ -2851,9 +2852,10 @@ class ResourceAvailabilityTest(common.HeatTestCase):
|
||||||
return mock_service_types, mock_client_plugin
|
return mock_service_types, mock_client_plugin
|
||||||
|
|
||||||
def test_default_true_with_default_client_name_none(self):
|
def test_default_true_with_default_client_name_none(self):
|
||||||
'''
|
"""Test availability of resource when default_client_name is None.
|
||||||
|
|
||||||
When default_client_name is None, resource is considered as available.
|
When default_client_name is None, resource is considered as available.
|
||||||
'''
|
"""
|
||||||
with mock.patch(('heat.tests.generic_resource'
|
with mock.patch(('heat.tests.generic_resource'
|
||||||
'.ResourceWithDefaultClientName.default_client_name'),
|
'.ResourceWithDefaultClientName.default_client_name'),
|
||||||
new_callable=mock.PropertyMock) as mock_client_name:
|
new_callable=mock.PropertyMock) as mock_client_name:
|
||||||
|
@ -2865,9 +2867,10 @@ class ResourceAvailabilityTest(common.HeatTestCase):
|
||||||
def test_default_true_empty_service_types(
|
def test_default_true_empty_service_types(
|
||||||
self,
|
self,
|
||||||
mock_client_plugin_method):
|
mock_client_plugin_method):
|
||||||
'''
|
"""Test availability of resource when service_types is empty list.
|
||||||
|
|
||||||
When service_types is empty list, resource is considered as available.
|
When service_types is empty list, resource is considered as available.
|
||||||
'''
|
"""
|
||||||
|
|
||||||
mock_service_types, mock_client_plugin = self._mock_client_plugin()
|
mock_service_types, mock_client_plugin = self._mock_client_plugin()
|
||||||
mock_client_plugin_method.return_value = mock_client_plugin
|
mock_client_plugin_method.return_value = mock_client_plugin
|
||||||
|
@ -2883,9 +2886,10 @@ class ResourceAvailabilityTest(common.HeatTestCase):
|
||||||
def test_service_deployed(
|
def test_service_deployed(
|
||||||
self,
|
self,
|
||||||
mock_client_plugin_method):
|
mock_client_plugin_method):
|
||||||
'''
|
"""Test availability of resource when the service is deployed.
|
||||||
|
|
||||||
When the service is deployed, resource is considered as available.
|
When the service is deployed, resource is considered as available.
|
||||||
'''
|
"""
|
||||||
|
|
||||||
mock_service_types, mock_client_plugin = self._mock_client_plugin(
|
mock_service_types, mock_client_plugin = self._mock_client_plugin(
|
||||||
['test_type']
|
['test_type']
|
||||||
|
@ -2908,10 +2912,11 @@ class ResourceAvailabilityTest(common.HeatTestCase):
|
||||||
def test_service_not_deployed(
|
def test_service_not_deployed(
|
||||||
self,
|
self,
|
||||||
mock_client_plugin_method):
|
mock_client_plugin_method):
|
||||||
'''
|
"""Test availability of resource when the service is not deployed.
|
||||||
|
|
||||||
When the service is not deployed, resource is considered as
|
When the service is not deployed, resource is considered as
|
||||||
unavailable.
|
unavailable.
|
||||||
'''
|
"""
|
||||||
|
|
||||||
mock_service_types, mock_client_plugin = self._mock_client_plugin(
|
mock_service_types, mock_client_plugin = self._mock_client_plugin(
|
||||||
['test_type_un_deployed'],
|
['test_type_un_deployed'],
|
||||||
|
@ -2932,10 +2937,11 @@ class ResourceAvailabilityTest(common.HeatTestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_service_not_deployed_throws_exception(self):
|
def test_service_not_deployed_throws_exception(self):
|
||||||
'''
|
"""Test raising exception when the service is not deployed.
|
||||||
|
|
||||||
When the service is not deployed, make sure resource is throwing
|
When the service is not deployed, make sure resource is throwing
|
||||||
ResourceTypeUnavailable exception.
|
ResourceTypeUnavailable exception.
|
||||||
'''
|
"""
|
||||||
with mock.patch.object(
|
with mock.patch.object(
|
||||||
generic_rsrc.ResourceWithDefaultClientName,
|
generic_rsrc.ResourceWithDefaultClientName,
|
||||||
'is_service_available') as mock_method:
|
'is_service_available') as mock_method:
|
||||||
|
|
|
@ -121,7 +121,8 @@ class ResourceGroupTest(common.HeatTestCase):
|
||||||
self.m.StubOutWithMock(stackm.Stack, 'validate')
|
self.m.StubOutWithMock(stackm.Stack, 'validate')
|
||||||
|
|
||||||
def test_assemble_nested(self):
|
def test_assemble_nested(self):
|
||||||
"""
|
"""Tests nested stack creation based on props.
|
||||||
|
|
||||||
Tests that the nested stack that implements the group is created
|
Tests that the nested stack that implements the group is created
|
||||||
appropriately based on properties.
|
appropriately based on properties.
|
||||||
"""
|
"""
|
||||||
|
@ -636,7 +637,8 @@ class ResourceGroupNameListTest(common.HeatTestCase):
|
||||||
class ResourceGroupAttrTest(common.HeatTestCase):
|
class ResourceGroupAttrTest(common.HeatTestCase):
|
||||||
|
|
||||||
def test_aggregate_attribs(self):
|
def test_aggregate_attribs(self):
|
||||||
"""
|
"""Test attribute aggregation.
|
||||||
|
|
||||||
Test attribute aggregation and that we mimic the nested resource's
|
Test attribute aggregation and that we mimic the nested resource's
|
||||||
attributes.
|
attributes.
|
||||||
"""
|
"""
|
||||||
|
@ -646,7 +648,8 @@ class ResourceGroupAttrTest(common.HeatTestCase):
|
||||||
self.assertEqual(expected, resg.FnGetAtt('Foo'))
|
self.assertEqual(expected, resg.FnGetAtt('Foo'))
|
||||||
|
|
||||||
def test_index_dotted_attribs(self):
|
def test_index_dotted_attribs(self):
|
||||||
"""
|
"""Test attribute aggregation.
|
||||||
|
|
||||||
Test attribute aggregation and that we mimic the nested resource's
|
Test attribute aggregation and that we mimic the nested resource's
|
||||||
attributes.
|
attributes.
|
||||||
"""
|
"""
|
||||||
|
@ -655,7 +658,8 @@ class ResourceGroupAttrTest(common.HeatTestCase):
|
||||||
self.assertEqual('1', resg.FnGetAtt('resource.1.Foo'))
|
self.assertEqual('1', resg.FnGetAtt('resource.1.Foo'))
|
||||||
|
|
||||||
def test_index_path_attribs(self):
|
def test_index_path_attribs(self):
|
||||||
"""
|
"""Test attribute aggregation.
|
||||||
|
|
||||||
Test attribute aggregation and that we mimic the nested resource's
|
Test attribute aggregation and that we mimic the nested resource's
|
||||||
attributes.
|
attributes.
|
||||||
"""
|
"""
|
||||||
|
@ -664,7 +668,8 @@ class ResourceGroupAttrTest(common.HeatTestCase):
|
||||||
self.assertEqual('1', resg.FnGetAtt('resource.1', 'Foo'))
|
self.assertEqual('1', resg.FnGetAtt('resource.1', 'Foo'))
|
||||||
|
|
||||||
def test_index_deep_path_attribs(self):
|
def test_index_deep_path_attribs(self):
|
||||||
"""
|
"""Test attribute aggregation.
|
||||||
|
|
||||||
Test attribute aggregation and that we mimic the nested resource's
|
Test attribute aggregation and that we mimic the nested resource's
|
||||||
attributes.
|
attributes.
|
||||||
"""
|
"""
|
||||||
|
@ -676,7 +681,8 @@ class ResourceGroupAttrTest(common.HeatTestCase):
|
||||||
'nested_dict', 'dict', 'b'))
|
'nested_dict', 'dict', 'b'))
|
||||||
|
|
||||||
def test_aggregate_deep_path_attribs(self):
|
def test_aggregate_deep_path_attribs(self):
|
||||||
"""
|
"""Test attribute aggregation.
|
||||||
|
|
||||||
Test attribute aggregation and that we mimic the nested resource's
|
Test attribute aggregation and that we mimic the nested resource's
|
||||||
attributes.
|
attributes.
|
||||||
"""
|
"""
|
||||||
|
@ -686,17 +692,13 @@ class ResourceGroupAttrTest(common.HeatTestCase):
|
||||||
self.assertEqual(expected, resg.FnGetAtt('nested_dict', 'list', 2))
|
self.assertEqual(expected, resg.FnGetAtt('nested_dict', 'list', 2))
|
||||||
|
|
||||||
def test_aggregate_refs(self):
|
def test_aggregate_refs(self):
|
||||||
"""
|
"""Test resource id aggregation."""
|
||||||
Test resource id aggregation
|
|
||||||
"""
|
|
||||||
resg = self._create_dummy_stack()
|
resg = self._create_dummy_stack()
|
||||||
expected = ['ID-0', 'ID-1']
|
expected = ['ID-0', 'ID-1']
|
||||||
self.assertEqual(expected, resg.FnGetAtt("refs"))
|
self.assertEqual(expected, resg.FnGetAtt("refs"))
|
||||||
|
|
||||||
def test_aggregate_refs_with_index(self):
|
def test_aggregate_refs_with_index(self):
|
||||||
"""
|
"""Test resource id aggregation with index."""
|
||||||
Test resource id aggregation with index
|
|
||||||
"""
|
|
||||||
resg = self._create_dummy_stack()
|
resg = self._create_dummy_stack()
|
||||||
expected = ['ID-0', 'ID-1']
|
expected = ['ID-0', 'ID-1']
|
||||||
self.assertEqual(expected[0], resg.FnGetAtt("refs", 0))
|
self.assertEqual(expected[0], resg.FnGetAtt("refs", 0))
|
||||||
|
@ -704,17 +706,13 @@ class ResourceGroupAttrTest(common.HeatTestCase):
|
||||||
self.assertIsNone(resg.FnGetAtt("refs", 2))
|
self.assertIsNone(resg.FnGetAtt("refs", 2))
|
||||||
|
|
||||||
def test_aggregate_outputs(self):
|
def test_aggregate_outputs(self):
|
||||||
"""
|
"""Test outputs aggregation."""
|
||||||
Test outputs aggregation
|
|
||||||
"""
|
|
||||||
expected = {'0': ['foo', 'bar'], '1': ['foo', 'bar']}
|
expected = {'0': ['foo', 'bar'], '1': ['foo', 'bar']}
|
||||||
resg = self._create_dummy_stack(template_attr, expect_attrs=expected)
|
resg = self._create_dummy_stack(template_attr, expect_attrs=expected)
|
||||||
self.assertEqual(expected, resg.FnGetAtt('attributes', 'list'))
|
self.assertEqual(expected, resg.FnGetAtt('attributes', 'list'))
|
||||||
|
|
||||||
def test_aggregate_outputs_no_path(self):
|
def test_aggregate_outputs_no_path(self):
|
||||||
"""
|
"""Test outputs aggregation with missing path."""
|
||||||
Test outputs aggregation with missing path
|
|
||||||
"""
|
|
||||||
resg = self._create_dummy_stack(template_attr)
|
resg = self._create_dummy_stack(template_attr)
|
||||||
self.assertRaises(exception.InvalidTemplateAttribute,
|
self.assertRaises(exception.InvalidTemplateAttribute,
|
||||||
resg.FnGetAtt, 'attributes')
|
resg.FnGetAtt, 'attributes')
|
||||||
|
|
|
@ -41,8 +41,7 @@ class EngineRpcAPITestCase(common.HeatTestCase):
|
||||||
self.rpcapi = rpc_client.EngineClient()
|
self.rpcapi = rpc_client.EngineClient()
|
||||||
|
|
||||||
def _to_remote_error(self, error):
|
def _to_remote_error(self, error):
|
||||||
"""Converts the given exception to the one with the _Remote suffix.
|
"""Converts the given exception to the one with the _Remote suffix."""
|
||||||
"""
|
|
||||||
exc_info = (type(error), error, None)
|
exc_info = (type(error), error, None)
|
||||||
serialized = rpc_common.serialize_remote_exception(exc_info)
|
serialized = rpc_common.serialize_remote_exception(exc_info)
|
||||||
remote_error = rpc_common.deserialize_remote_exception(
|
remote_error = rpc_common.deserialize_remote_exception(
|
||||||
|
|
|
@ -1203,7 +1203,8 @@ class SoftwareDeploymentGroupTest(common.HeatTestCase):
|
||||||
set(resg._resource_names()))
|
set(resg._resource_names()))
|
||||||
|
|
||||||
def test_assemble_nested(self):
|
def test_assemble_nested(self):
|
||||||
"""
|
"""Tests nested stack implements group creation based on properties.
|
||||||
|
|
||||||
Tests that the nested stack that implements the group is created
|
Tests that the nested stack that implements the group is created
|
||||||
appropriately based on properties.
|
appropriately based on properties.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -963,11 +963,10 @@ class StackTest(common.HeatTestCase):
|
||||||
rsrc.state_set(rsrc.CREATE, rsrc.COMPLETE)
|
rsrc.state_set(rsrc.CREATE, rsrc.COMPLETE)
|
||||||
|
|
||||||
def test_create_failure_recovery(self):
|
def test_create_failure_recovery(self):
|
||||||
'''
|
"""Check that rollback still works with dynamic metadata.
|
||||||
assertion:
|
|
||||||
check that rollback still works with dynamic metadata
|
This test fails the second instance.
|
||||||
this test fails the second instance
|
"""
|
||||||
'''
|
|
||||||
|
|
||||||
tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
|
tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
|
||||||
'Resources': {
|
'Resources': {
|
||||||
|
@ -1179,9 +1178,7 @@ class StackTest(common.HeatTestCase):
|
||||||
self.stack[r].required_by())
|
self.stack[r].required_by())
|
||||||
|
|
||||||
def test_store_saves_owner(self):
|
def test_store_saves_owner(self):
|
||||||
"""
|
"""owner_id attribute of Store is saved to the database when stored."""
|
||||||
The owner_id attribute of Store is saved to the database when stored.
|
|
||||||
"""
|
|
||||||
self.stack = stack.Stack(self.ctx, 'owner_stack', self.tmpl)
|
self.stack = stack.Stack(self.ctx, 'owner_stack', self.tmpl)
|
||||||
stack_ownee = stack.Stack(self.ctx, 'ownee_stack', self.tmpl,
|
stack_ownee = stack.Stack(self.ctx, 'ownee_stack', self.tmpl,
|
||||||
owner_id=self.stack.id)
|
owner_id=self.stack.id)
|
||||||
|
@ -1232,9 +1229,7 @@ class StackTest(common.HeatTestCase):
|
||||||
self.assertEqual('tag2', db_tags[1].tag)
|
self.assertEqual('tag2', db_tags[1].tag)
|
||||||
|
|
||||||
def test_store_saves_creds(self):
|
def test_store_saves_creds(self):
|
||||||
"""
|
"""A user_creds entry is created on first stack store."""
|
||||||
A user_creds entry is created on first stack store
|
|
||||||
"""
|
|
||||||
cfg.CONF.set_default('deferred_auth_method', 'password')
|
cfg.CONF.set_default('deferred_auth_method', 'password')
|
||||||
self.stack = stack.Stack(self.ctx, 'creds_stack', self.tmpl)
|
self.stack = stack.Stack(self.ctx, 'creds_stack', self.tmpl)
|
||||||
self.stack.store()
|
self.stack.store()
|
||||||
|
@ -1262,9 +1257,7 @@ class StackTest(common.HeatTestCase):
|
||||||
self.assertEqual(user_creds_id, db_stack.user_creds_id)
|
self.assertEqual(user_creds_id, db_stack.user_creds_id)
|
||||||
|
|
||||||
def test_store_saves_creds_trust(self):
|
def test_store_saves_creds_trust(self):
|
||||||
"""
|
"""A user_creds entry is created on first stack store."""
|
||||||
A user_creds entry is created on first stack store
|
|
||||||
"""
|
|
||||||
cfg.CONF.set_override('deferred_auth_method', 'trusts')
|
cfg.CONF.set_override('deferred_auth_method', 'trusts')
|
||||||
|
|
||||||
self.m.StubOutWithMock(keystone.KeystoneClientPlugin, '_create')
|
self.m.StubOutWithMock(keystone.KeystoneClientPlugin, '_create')
|
||||||
|
@ -1313,9 +1306,7 @@ class StackTest(common.HeatTestCase):
|
||||||
self.assertEqual(creds.id, backup.user_creds_id)
|
self.assertEqual(creds.id, backup.user_creds_id)
|
||||||
|
|
||||||
def test_stored_context_err(self):
|
def test_stored_context_err(self):
|
||||||
"""
|
"""Test stored_context error path."""
|
||||||
Test stored_context error path.
|
|
||||||
"""
|
|
||||||
self.stack = stack.Stack(self.ctx, 'creds_stack', self.tmpl)
|
self.stack = stack.Stack(self.ctx, 'creds_stack', self.tmpl)
|
||||||
ex = self.assertRaises(exception.Error, self.stack.stored_context)
|
ex = self.assertRaises(exception.Error, self.stack.stored_context)
|
||||||
expected_err = 'Attempt to use stored_context with no user_creds'
|
expected_err = 'Attempt to use stored_context with no user_creds'
|
||||||
|
@ -1401,7 +1392,8 @@ class StackTest(common.HeatTestCase):
|
||||||
self.assertEqual(ctx_expected, load_stack.context.to_dict())
|
self.assertEqual(ctx_expected, load_stack.context.to_dict())
|
||||||
|
|
||||||
def test_load_honors_owner(self):
|
def test_load_honors_owner(self):
|
||||||
"""
|
"""Loading a stack from the database will set the owner_id.
|
||||||
|
|
||||||
Loading a stack from the database will set the owner_id of the
|
Loading a stack from the database will set the owner_id of the
|
||||||
resultant stack appropriately.
|
resultant stack appropriately.
|
||||||
"""
|
"""
|
||||||
|
@ -1559,9 +1551,7 @@ class StackTest(common.HeatTestCase):
|
||||||
self.stack.state)
|
self.stack.state)
|
||||||
|
|
||||||
def test_stack_load_no_param_value_validation(self):
|
def test_stack_load_no_param_value_validation(self):
|
||||||
'''
|
"""Test stack loading with disabled parameter value validation."""
|
||||||
Test stack loading with disabled parameter value validation.
|
|
||||||
'''
|
|
||||||
tmpl = template_format.parse('''
|
tmpl = template_format.parse('''
|
||||||
heat_template_version: 2013-05-23
|
heat_template_version: 2013-05-23
|
||||||
parameters:
|
parameters:
|
||||||
|
@ -2156,9 +2146,7 @@ class StackTest(common.HeatTestCase):
|
||||||
self.assertFalse(mock_drg.called)
|
self.assertFalse(mock_drg.called)
|
||||||
|
|
||||||
def test_encrypt_parameters_false_parameters_stored_plaintext(self):
|
def test_encrypt_parameters_false_parameters_stored_plaintext(self):
|
||||||
'''
|
"""Test stack loading with disabled parameter value validation."""
|
||||||
Test stack loading with disabled parameter value validation.
|
|
||||||
'''
|
|
||||||
tmpl = template_format.parse('''
|
tmpl = template_format.parse('''
|
||||||
heat_template_version: 2013-05-23
|
heat_template_version: 2013-05-23
|
||||||
parameters:
|
parameters:
|
||||||
|
@ -2186,9 +2174,7 @@ class StackTest(common.HeatTestCase):
|
||||||
self.assertEqual('bar', params['param2'])
|
self.assertEqual('bar', params['param2'])
|
||||||
|
|
||||||
def test_parameters_stored_encrypted_decrypted_on_load(self):
|
def test_parameters_stored_encrypted_decrypted_on_load(self):
|
||||||
'''
|
"""Test stack loading with disabled parameter value validation."""
|
||||||
Test stack loading with disabled parameter value validation.
|
|
||||||
'''
|
|
||||||
tmpl = template_format.parse('''
|
tmpl = template_format.parse('''
|
||||||
heat_template_version: 2013-05-23
|
heat_template_version: 2013-05-23
|
||||||
parameters:
|
parameters:
|
||||||
|
@ -2223,9 +2209,7 @@ class StackTest(common.HeatTestCase):
|
||||||
self.assertEqual('bar', params.get('param2'))
|
self.assertEqual('bar', params.get('param2'))
|
||||||
|
|
||||||
def test_parameters_stored_decrypted_successful_load(self):
|
def test_parameters_stored_decrypted_successful_load(self):
|
||||||
'''
|
"""Test stack loading with disabled parameter value validation."""
|
||||||
Test stack loading with disabled parameter value validation.
|
|
||||||
'''
|
|
||||||
tmpl = template_format.parse('''
|
tmpl = template_format.parse('''
|
||||||
heat_template_version: 2013-05-23
|
heat_template_version: 2013-05-23
|
||||||
parameters:
|
parameters:
|
||||||
|
|
|
@ -214,8 +214,10 @@ class StackResourceTest(StackResourceBaseTest):
|
||||||
self.assertNotEqual(sig2, sig2a)
|
self.assertNotEqual(sig2, sig2a)
|
||||||
|
|
||||||
def test_propagated_files(self):
|
def test_propagated_files(self):
|
||||||
"""Makes sure that the files map in the top level stack
|
"""Test passing of the files map in the top level to the child.
|
||||||
are passed on to the child stack.
|
|
||||||
|
Makes sure that the files map in the top level stack are passed on to
|
||||||
|
the child stack.
|
||||||
"""
|
"""
|
||||||
self.parent_stack.t.files["foo"] = "bar"
|
self.parent_stack.t.files["foo"] = "bar"
|
||||||
parsed_t = self.parent_resource._parse_child_template(self.templ, None)
|
parsed_t = self.parent_resource._parse_child_template(self.templ, None)
|
||||||
|
@ -520,9 +522,10 @@ class StackResourceTest(StackResourceBaseTest):
|
||||||
self.parent_resource.context, mock.ANY)
|
self.parent_resource.context, mock.ANY)
|
||||||
|
|
||||||
def test_need_update_for_nested_resource(self):
|
def test_need_update_for_nested_resource(self):
|
||||||
"""
|
"""Test the resource with nested stack should need update.
|
||||||
The resource in Create or Update state and has nested stack,
|
|
||||||
should need update.
|
The resource in Create or Update state and has nested stack, should
|
||||||
|
need update.
|
||||||
"""
|
"""
|
||||||
self.parent_resource.action = self.parent_resource.CREATE
|
self.parent_resource.action = self.parent_resource.CREATE
|
||||||
need_update = self.parent_resource._needs_update(
|
need_update = self.parent_resource._needs_update(
|
||||||
|
@ -535,7 +538,8 @@ class StackResourceTest(StackResourceBaseTest):
|
||||||
self.assertEqual(True, need_update)
|
self.assertEqual(True, need_update)
|
||||||
|
|
||||||
def test_need_update_in_failed_state_for_nested_resource(self):
|
def test_need_update_in_failed_state_for_nested_resource(self):
|
||||||
"""
|
"""Test the resource with no nested stack should need replacement.
|
||||||
|
|
||||||
The resource in failed state and has no nested stack,
|
The resource in failed state and has no nested stack,
|
||||||
should need update with UpdateReplace.
|
should need update with UpdateReplace.
|
||||||
"""
|
"""
|
||||||
|
@ -551,7 +555,8 @@ class StackResourceTest(StackResourceBaseTest):
|
||||||
self.parent_resource)
|
self.parent_resource)
|
||||||
|
|
||||||
def test_need_update_in_init_complete_state_for_nested_resource(self):
|
def test_need_update_in_init_complete_state_for_nested_resource(self):
|
||||||
"""
|
"""Test the resource with no nested stack should need replacement.
|
||||||
|
|
||||||
The resource in failed state and has no nested stack,
|
The resource in failed state and has no nested stack,
|
||||||
should need update with UpdateReplace.
|
should need update with UpdateReplace.
|
||||||
"""
|
"""
|
||||||
|
@ -717,7 +722,8 @@ class StackResourceCheckCompleteTest(StackResourceBaseTest):
|
||||||
self.nested.COMPLETE = 'COMPLETE'
|
self.nested.COMPLETE = 'COMPLETE'
|
||||||
|
|
||||||
def test_state_ok(self):
|
def test_state_ok(self):
|
||||||
"""
|
"""Test case when check_create_complete should return True.
|
||||||
|
|
||||||
check_create_complete should return True create task is
|
check_create_complete should return True create task is
|
||||||
done and the nested stack is in (<action>,COMPLETE) state.
|
done and the nested stack is in (<action>,COMPLETE) state.
|
||||||
"""
|
"""
|
||||||
|
@ -729,7 +735,8 @@ class StackResourceCheckCompleteTest(StackResourceBaseTest):
|
||||||
show_deleted=self.show_deleted, force_reload=True)
|
show_deleted=self.show_deleted, force_reload=True)
|
||||||
|
|
||||||
def test_state_err(self):
|
def test_state_err(self):
|
||||||
"""
|
"""Test case when check_create_complete should raise error.
|
||||||
|
|
||||||
check_create_complete should raise error when create task is
|
check_create_complete should raise error when create task is
|
||||||
done but the nested stack is not in (<action>,COMPLETE) state
|
done but the nested stack is not in (<action>,COMPLETE) state
|
||||||
"""
|
"""
|
||||||
|
@ -749,7 +756,8 @@ class StackResourceCheckCompleteTest(StackResourceBaseTest):
|
||||||
show_deleted=self.show_deleted, force_reload=True)
|
show_deleted=self.show_deleted, force_reload=True)
|
||||||
|
|
||||||
def test_state_unknown(self):
|
def test_state_unknown(self):
|
||||||
"""
|
"""Test case when check_create_complete should raise error.
|
||||||
|
|
||||||
check_create_complete should raise error when create task is
|
check_create_complete should raise error when create task is
|
||||||
done but the nested stack is not in (<action>,COMPLETE) state
|
done but the nested stack is not in (<action>,COMPLETE) state
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1056,11 +1056,11 @@ class StackUpdateTest(common.HeatTestCase):
|
||||||
self.m.UnsetStubs()
|
self.m.UnsetStubs()
|
||||||
|
|
||||||
def test_update_replace_by_reference(self):
|
def test_update_replace_by_reference(self):
|
||||||
'''
|
"""Test case for changes in dynamic attributes.
|
||||||
assertion:
|
|
||||||
changes in dynamic attributes, due to other resources been updated
|
Changes in dynamic attributes, due to other resources been updated
|
||||||
are not ignored and can cause dependent resources to be updated.
|
are not ignored and can cause dependent resources to be updated.
|
||||||
'''
|
"""
|
||||||
tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
|
tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
|
||||||
'Resources': {
|
'Resources': {
|
||||||
'AResource': {'Type': 'ResourceWithPropsType',
|
'AResource': {'Type': 'ResourceWithPropsType',
|
||||||
|
@ -1111,11 +1111,11 @@ class StackUpdateTest(common.HeatTestCase):
|
||||||
mock_id.assert_called_with()
|
mock_id.assert_called_with()
|
||||||
|
|
||||||
def test_update_with_new_resources_with_reference(self):
|
def test_update_with_new_resources_with_reference(self):
|
||||||
'''
|
"""Check correct resolving of references in new resources.
|
||||||
assertion:
|
|
||||||
check, that during update with new resources which one has
|
Check, that during update with new resources which one has
|
||||||
reference on second, reference will be correct resolved.
|
reference on second, reference will be correct resolved.
|
||||||
'''
|
"""
|
||||||
tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
|
tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
|
||||||
'Resources': {
|
'Resources': {
|
||||||
'CResource': {'Type': 'ResourceWithPropsType',
|
'CResource': {'Type': 'ResourceWithPropsType',
|
||||||
|
@ -1157,11 +1157,10 @@ class StackUpdateTest(common.HeatTestCase):
|
||||||
mock_create.assert_called_with()
|
mock_create.assert_called_with()
|
||||||
|
|
||||||
def test_update_by_reference_and_rollback_1(self):
|
def test_update_by_reference_and_rollback_1(self):
|
||||||
'''
|
"""Check that rollback still works with dynamic metadata.
|
||||||
assertion:
|
|
||||||
check that rollback still works with dynamic metadata
|
This test fails the first instance.
|
||||||
this test fails the first instance
|
"""
|
||||||
'''
|
|
||||||
tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
|
tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
|
||||||
'Resources': {
|
'Resources': {
|
||||||
'AResource': {'Type': 'ResourceWithPropsType',
|
'AResource': {'Type': 'ResourceWithPropsType',
|
||||||
|
@ -1208,11 +1207,10 @@ class StackUpdateTest(common.HeatTestCase):
|
||||||
mock_create.assert_called_once_with()
|
mock_create.assert_called_once_with()
|
||||||
|
|
||||||
def test_update_by_reference_and_rollback_2(self):
|
def test_update_by_reference_and_rollback_2(self):
|
||||||
'''
|
"""Check that rollback still works with dynamic metadata.
|
||||||
assertion:
|
|
||||||
check that rollback still works with dynamic metadata
|
This test fails the second instance.
|
||||||
this test fails the second instance
|
"""
|
||||||
'''
|
|
||||||
|
|
||||||
class ResourceTypeA(generic_rsrc.ResourceWithProps):
|
class ResourceTypeA(generic_rsrc.ResourceWithProps):
|
||||||
count = 0
|
count = 0
|
||||||
|
@ -1267,11 +1265,10 @@ class StackUpdateTest(common.HeatTestCase):
|
||||||
mock_create.assert_called_once_with()
|
mock_create.assert_called_once_with()
|
||||||
|
|
||||||
def test_update_failure_recovery(self):
|
def test_update_failure_recovery(self):
|
||||||
'''
|
"""Check that rollback still works with dynamic metadata.
|
||||||
assertion:
|
|
||||||
check that rollback still works with dynamic metadata
|
This test fails the second instance.
|
||||||
this test fails the second instance
|
"""
|
||||||
'''
|
|
||||||
|
|
||||||
class ResourceTypeA(generic_rsrc.ResourceWithProps):
|
class ResourceTypeA(generic_rsrc.ResourceWithProps):
|
||||||
count = 0
|
count = 0
|
||||||
|
@ -1351,11 +1348,10 @@ class StackUpdateTest(common.HeatTestCase):
|
||||||
mock_delete_A.assert_called_once_with()
|
mock_delete_A.assert_called_once_with()
|
||||||
|
|
||||||
def test_update_failure_recovery_new_param(self):
|
def test_update_failure_recovery_new_param(self):
|
||||||
'''
|
"""Check that rollback still works with dynamic metadata.
|
||||||
assertion:
|
|
||||||
check that rollback still works with dynamic metadata
|
This test fails the second instance.
|
||||||
this test fails the second instance
|
"""
|
||||||
'''
|
|
||||||
|
|
||||||
class ResourceTypeA(generic_rsrc.ResourceWithProps):
|
class ResourceTypeA(generic_rsrc.ResourceWithProps):
|
||||||
count = 0
|
count = 0
|
||||||
|
@ -1446,11 +1442,10 @@ class StackUpdateTest(common.HeatTestCase):
|
||||||
self.assertEqual(2, mock_create.call_count)
|
self.assertEqual(2, mock_create.call_count)
|
||||||
|
|
||||||
def test_update_failure_recovery_new_param_stack_list(self):
|
def test_update_failure_recovery_new_param_stack_list(self):
|
||||||
'''
|
"""Check that stack-list is not broken if update fails in between.
|
||||||
assertion:
|
|
||||||
check that stack-list is not broken if update fails in between.
|
Also ensure that next update passes.
|
||||||
Also ensure that next update passes
|
"""
|
||||||
'''
|
|
||||||
|
|
||||||
class ResourceTypeA(generic_rsrc.ResourceWithProps):
|
class ResourceTypeA(generic_rsrc.ResourceWithProps):
|
||||||
count = 0
|
count = 0
|
||||||
|
@ -1547,11 +1542,11 @@ class StackUpdateTest(common.HeatTestCase):
|
||||||
self.assertEqual(2, mock_create.call_count)
|
self.assertEqual(2, mock_create.call_count)
|
||||||
|
|
||||||
def test_update_replace_parameters(self):
|
def test_update_replace_parameters(self):
|
||||||
'''
|
"""Check that changes in static environment parameters are not ignored.
|
||||||
assertion:
|
|
||||||
changes in static environment parameters
|
Changes in static environment parameters are not ignored and can cause
|
||||||
are not ignored and can cause dependent resources to be updated.
|
dependent resources to be updated.
|
||||||
'''
|
"""
|
||||||
tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
|
tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
|
||||||
'Parameters': {'AParam': {'Type': 'String'}},
|
'Parameters': {'AParam': {'Type': 'String'}},
|
||||||
'Resources': {
|
'Resources': {
|
||||||
|
|
|
@ -320,7 +320,8 @@ class StructuredDeploymentGroupTest(common.HeatTestCase):
|
||||||
set(resg._resource_names()))
|
set(resg._resource_names()))
|
||||||
|
|
||||||
def test_assemble_nested(self):
|
def test_assemble_nested(self):
|
||||||
"""
|
"""Tests nested stack implements group creation based on properties.
|
||||||
|
|
||||||
Tests that the nested stack that implements the group is created
|
Tests that the nested stack that implements the group is created
|
||||||
appropriately based on properties.
|
appropriately based on properties.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -402,10 +402,12 @@ class swiftTest(common.HeatTestCase):
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_default_headers_not_none_empty_string(self):
|
def test_default_headers_not_none_empty_string(self):
|
||||||
'''Test that we are not passing None when we have a default
|
"""Test that we are not passing None.
|
||||||
|
|
||||||
|
Test that we are not passing None when we have a default
|
||||||
empty string or sc will pass them as string None. see
|
empty string or sc will pass them as string None. see
|
||||||
bug lp:1259571.
|
bug lp:1259571.
|
||||||
'''
|
"""
|
||||||
container_name = utils.PhysName('test_stack', 'test_resource')
|
container_name = utils.PhysName('test_stack', 'test_resource')
|
||||||
sc.Connection.put_container(
|
sc.Connection.put_container(
|
||||||
container_name, {}).AndReturn(None)
|
container_name, {}).AndReturn(None)
|
||||||
|
|
Loading…
Reference in New Issue