Move reload test to test_instance_group
- Now it doesn't need to create the scaling group. part of blueprint decouple-nested Change-Id: I47108acd60bc2c8634fc0d40370a4a6a47c3dd17
This commit is contained in:
parent
c7586bd323
commit
c13ae86c16
|
@ -20,10 +20,8 @@ from oslo.utils import timeutils
|
|||
|
||||
from heat.common import exception
|
||||
from heat.common import grouputils
|
||||
from heat.common import short_id
|
||||
from heat.common import template_format
|
||||
from heat.engine.notification import autoscaling as notification
|
||||
from heat.engine import parser
|
||||
from heat.engine import resource
|
||||
from heat.engine.resources.aws import autoscaling_group as asg
|
||||
from heat.engine.resources.aws import instance
|
||||
|
@ -185,53 +183,6 @@ class AutoScalingTest(common.HeatTestCase):
|
|||
for x in range(nmeta):
|
||||
resource.Resource.metadata_set(expected).AndReturn(None)
|
||||
|
||||
def test_lb_reload_static_resolve(self):
|
||||
t = template_format.parse(as_template)
|
||||
properties = t['Resources']['ElasticLoadBalancer']['Properties']
|
||||
properties['AvailabilityZones'] = {'Fn::GetAZs': ''}
|
||||
|
||||
self.m.StubOutWithMock(parser.Stack, 'get_availability_zones')
|
||||
parser.Stack.get_availability_zones().MultipleTimes().AndReturn(
|
||||
['abc', 'xyz'])
|
||||
|
||||
# Check that the Fn::GetAZs is correctly resolved
|
||||
expected = {u'Type': u'AWS::ElasticLoadBalancing::LoadBalancer',
|
||||
u'Properties': {'Instances': ['aaaabbbbcccc'],
|
||||
u'Listeners': [{u'InstancePort': u'80',
|
||||
u'LoadBalancerPort': u'80',
|
||||
u'Protocol': u'HTTP'}],
|
||||
u'AvailabilityZones': ['abc', 'xyz']}}
|
||||
|
||||
self.m.StubOutWithMock(short_id, 'generate_id')
|
||||
short_id.generate_id().MultipleTimes().AndReturn('aaaabbbbcccc')
|
||||
|
||||
now = timeutils.utcnow()
|
||||
self._stub_meta_expected(now, 'ExactCapacity : 1')
|
||||
self._stub_create(1)
|
||||
self.m.ReplayAll()
|
||||
stack = utils.parse_stack(t, params=self.params)
|
||||
|
||||
lb = stack['ElasticLoadBalancer']
|
||||
self.m.StubOutWithMock(lb, 'handle_update')
|
||||
lb.handle_update(expected,
|
||||
mox.IgnoreArg(),
|
||||
mox.IgnoreArg()).AndReturn(None)
|
||||
self.m.ReplayAll()
|
||||
|
||||
rsrc = self.create_scaling_group(t, stack, 'WebServerGroup')
|
||||
self.assertEqual(utils.PhysName(stack.name, rsrc.name),
|
||||
rsrc.FnGetRefId())
|
||||
self.assertEqual(1, len(grouputils.get_member_names(rsrc)))
|
||||
props = copy.copy(rsrc.properties.data)
|
||||
props['Cooldown'] = '61'
|
||||
update_snippet = rsrc_defn.ResourceDefinition(rsrc.name,
|
||||
rsrc.type(),
|
||||
props)
|
||||
scheduler.TaskRunner(rsrc.update, update_snippet)()
|
||||
|
||||
rsrc.delete()
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_scaling_up_meta_update(self):
|
||||
t = template_format.parse(as_template)
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ from heat.engine import resource
|
|||
from heat.engine.resources import instance_group as instgrp
|
||||
from heat.engine import rsrc_defn
|
||||
from heat.engine import scheduler
|
||||
from heat.engine import stack as parser
|
||||
from heat.tests.autoscaling import inline_templates
|
||||
from heat.tests import common
|
||||
from heat.tests import utils
|
||||
|
@ -286,3 +287,30 @@ class LoadbalancerReloadTest(common.HeatTestCase):
|
|||
"Unsupported resource 'ElasticLoadBalancer' in "
|
||||
"LoadBalancerNames",
|
||||
six.text_type(error))
|
||||
|
||||
def test_lb_reload_static_resolve(self):
|
||||
t = template_format.parse(inline_templates.as_template)
|
||||
properties = t['Resources']['ElasticLoadBalancer']['Properties']
|
||||
properties['AvailabilityZones'] = {'Fn::GetAZs': ''}
|
||||
|
||||
self.patchobject(parser.Stack, 'get_availability_zones',
|
||||
return_value=['abc', 'xyz'])
|
||||
|
||||
mock_members = self.patchobject(grouputils, 'get_member_refids')
|
||||
mock_members.return_value = ['aaaabbbbcccc']
|
||||
|
||||
# Check that the Fn::GetAZs is correctly resolved
|
||||
expected = {u'Properties': {'Instances': ['aaaabbbbcccc'],
|
||||
u'Listeners': [{u'InstancePort': u'80',
|
||||
u'LoadBalancerPort': u'80',
|
||||
u'Protocol': u'HTTP'}],
|
||||
u'AvailabilityZones': ['abc', 'xyz']}}
|
||||
|
||||
stack = utils.parse_stack(t, params=inline_templates.as_params)
|
||||
lb = stack['ElasticLoadBalancer']
|
||||
lb.handle_update = mock.Mock(return_value=None)
|
||||
group = stack['WebServerGroup']
|
||||
group._lb_reload()
|
||||
lb.handle_update.assert_called_once_with(
|
||||
mock.ANY, expected,
|
||||
{'Instances': ['aaaabbbbcccc']})
|
||||
|
|
Loading…
Reference in New Issue