~ubuntu-branches/ubuntu/vivid/heat/vivid

« back to all changes in this revision

Viewing changes to heat/tests/test_notifications.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, Corey Bryant
  • Date: 2015-01-06 08:55:22 UTC
  • mfrom: (1.1.21)
  • Revision ID: package-import@ubuntu.com-20150106085522-4o3hnaff5lacvtrf
Tags: 2015.1~b1-0ubuntu1
[ Chuck Short ]
* Open up for vivid.
* debian/control: Update bzr branch. 
* debian/control: Add python-saharaclient,
  python-osprofiler, python-oslo.middleware, python-oslo.serialization.
* debian/patches/fix-reqirements.patch: Refreshed.
* debian/patches/skip-tests.patch: Updated to skip more tests.
* debian/rules: Skip integration tests.

[ Corey Bryant ]
* New upstream release.
  - d/control: Align requirements with upstream.
  - d/watch: Update uversionmangle for kilo beta naming.
  - d/rules: Generate heat.conf.sample and apply patch before copy.
  - d/rules: Run base tests instead of integration tests.
  - d/p/fix-requirements.patch: Refreshed.
  - d/p/remove-gettextutils-import.patch: Cherry picked from master.
* d/control: Bumped Standards-Version to 3.9.6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
from oslo.utils import timeutils
16
16
 
17
17
from heat.common import exception
 
18
from heat.common import grouputils
18
19
from heat.common import template_format
19
20
from heat.engine.clients.os import glance
 
21
from heat.engine.clients.os import nova
20
22
from heat.engine import environment
21
23
from heat.engine import parser
22
24
from heat.engine import resource
23
25
# imports for mocking
24
 
from heat.engine.resources import autoscaling
 
26
from heat.engine.resources.aws import autoscaling_group as aws_asg
25
27
from heat.engine.resources import instance
26
28
from heat.engine.resources import loadbalancer
27
 
from heat.engine.resources import nova_keypair
28
29
from heat.engine.resources import user
29
30
from heat.engine.resources import wait_condition as waitc
30
31
from heat.engine import signal_responder as signal
32
33
from heat.tests import common
33
34
from heat.tests import generic_resource
34
35
# reuse the same template than autoscaling tests
35
 
from heat.tests.test_autoscaling import as_template
 
36
from heat.tests import test_autoscaling as test_as
36
37
from heat.tests import utils
37
38
 
38
39
 
150
151
        env = environment.Environment()
151
152
        env.load({u'parameters':
152
153
                  {u'KeyName': 'foo', 'ImageId': 'cloudimage'}})
153
 
        t = template_format.parse(as_template)
 
154
        t = template_format.parse(test_as.as_template)
154
155
        template = parser.Template(t)
155
156
        self.stack_name = utils.random_name()
156
157
        stack = parser.Stack(self.ctx, self.stack_name, template,
158
159
        stack.store()
159
160
        self.created_time = stack.created_time
160
161
        self.create_at = timeutils.isotime(self.created_time)
 
162
        self.stub_SnapshotConstraint_validate()
 
163
        self.m.ReplayAll()
161
164
        stack.create()
162
165
        self.stack = stack
163
166
        group = stack['WebServerGroup']
164
167
        self.assertEqual((group.CREATE, group.COMPLETE), group.state)
 
168
        self.m.VerifyAll()
165
169
        return group
166
170
 
167
171
    def mock_stack_except_for_group(self):
168
172
        self.m_validate = self.patchobject(parser.Stack, 'validate')
169
 
        self.patchobject(nova_keypair.KeypairConstraint, 'validate')
 
173
        self.patchobject(nova.KeypairConstraint, 'validate')
170
174
        self.patchobject(glance.ImageConstraint, 'validate')
 
175
        self.patchobject(nova.FlavorConstraint, 'validate')
171
176
        self.patchobject(instance.Instance, 'handle_create')\
172
177
            .return_value = True
173
178
        self.patchobject(instance.Instance, 'check_create_complete')\
252
257
                                              end_capacity=2,
253
258
                                              )
254
259
        group.adjust(1)
255
 
        self.assertEqual(2, len(group.get_instance_names()))
 
260
        self.assertEqual(2, grouputils.get_size(group))
256
261
        mock_notify.assert_has_calls(expected)
257
262
 
258
263
        expected = self.expected_notifs_calls(group,
261
266
                                              end_capacity=1,
262
267
                                              )
263
268
        group.adjust(-1)
264
 
        self.assertEqual(1, len(group.get_instance_names()))
 
269
        self.assertEqual(1, grouputils.get_size(group))
265
270
        mock_notify.assert_has_calls(expected)
266
271
 
267
272
    @mock.patch('heat.engine.notification.stack.send')
272
277
        group = self.create_autoscaling_stack_and_get_group()
273
278
 
274
279
        err_message = 'Boooom'
275
 
        m_as = self.patchobject(autoscaling.AutoScalingGroup, 'resize')
 
280
        m_as = self.patchobject(aws_asg.AutoScalingGroup, 'resize')
276
281
        m_as.side_effect = exception.Error(err_message)
277
282
 
278
283
        info, error = self.expected_notifs_calls(group,
280
285
                                                 start_capacity=1,
281
286
                                                 with_error=err_message)
282
287
        self.assertRaises(exception.Error, group.adjust, 2)
283
 
        self.assertEqual(1, len(group.get_instance_names()))
 
288
        self.assertEqual(1, grouputils.get_size(group))
284
289
        mock_error.assert_has_calls([error])
285
290
        mock_info.assert_has_calls([info])