~ubuntu-branches/ubuntu/wily/heat/wily

« back to all changes in this revision

Viewing changes to heat/tests/aws/test_waitcondition.py

  • Committer: Package Import Robot
  • Author(s): Corey Bryant, Corey Bryant, James Page
  • Date: 2015-07-07 17:06:19 UTC
  • mfrom: (1.1.26) (45.1.1 vivid-proposed)
  • Revision ID: package-import@ubuntu.com-20150707170619-hra2dbjpfofpou4s
Tags: 1:5.0.0~b1-0ubuntu1
[ Corey Bryant ]
* New upstream milestone for OpenStack Liberty:
  - d/control: Align (build-)depends with upstream.
  - d/p/fix-requirements.patch: Rebased.
  - d/p/sudoers_patch.patch: Rebased.

[ James Page ]
* d/s/options: Ignore any removal of egg-info data during package clean.
* d/control: Drop MySQL and PostgreSQL related BD's, not required for unit
  testing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
import json
17
17
import uuid
18
18
 
19
 
from oslo_config import cfg
20
19
from oslo_utils import timeutils
21
20
import six
22
21
 
24
23
from heat.common import identifier
25
24
from heat.common import template_format
26
25
from heat.engine import environment
27
 
from heat.engine import parser
28
26
from heat.engine.resources.aws.cfn import wait_condition_handle as aws_wch
29
27
from heat.engine import rsrc_defn
30
28
from heat.engine import scheduler
 
29
from heat.engine import stack as parser
 
30
from heat.engine import template as tmpl
31
31
from heat.objects import resource as resource_objects
32
32
from heat.tests import common
33
33
from heat.tests import utils
78
78
 
79
79
    def setUp(self):
80
80
        super(WaitConditionTest, self).setUp()
81
 
        cfg.CONF.set_default('heat_waitcondition_server_url',
82
 
                             'http://server.test:8000/v1/waitcondition')
83
81
 
84
82
    def create_stack(self, stack_id=None,
85
83
                     template=test_template_waitcondition, params=None,
86
84
                     stub=True, stub_status=True):
87
85
        params = params or {}
88
86
        temp = template_format.parse(template)
89
 
        template = parser.Template(temp,
90
 
                                   env=environment.Environment(params))
 
87
        template = tmpl.Template(temp,
 
88
                                 env=environment.Environment(params))
91
89
        ctx = utils.dummy_context(tenant_id='test_tenant')
92
90
        stack = parser.Stack(ctx, 'test_stack', template,
93
91
                             disable_rollback=True)
350
348
class WaitConditionHandleTest(common.HeatTestCase):
351
349
    def setUp(self):
352
350
        super(WaitConditionHandleTest, self).setUp()
353
 
        cfg.CONF.set_default('heat_waitcondition_server_url',
354
 
                             'http://server.test:8000/v1/waitcondition')
355
351
 
356
352
    def create_stack(self, stack_name=None, stack_id=None):
357
353
        temp = template_format.parse(test_template_waitcondition)
358
 
        template = parser.Template(temp)
 
354
        template = tmpl.Template(temp)
359
355
        ctx = utils.dummy_context(tenant_id='test_tenant')
360
356
        if stack_name is None:
361
357
            stack_name = utils.random_name()
377
373
                                           stack.id, '', 'WaitHandle')
378
374
        self.m.StubOutWithMock(aws_wch.WaitConditionHandle, 'identifier')
379
375
        aws_wch.WaitConditionHandle.identifier().MultipleTimes().AndReturn(id)
380
 
 
381
376
        self.m.ReplayAll()
382
377
        stack.create()
383
 
 
384
378
        return stack
385
379
 
386
380
    def test_handle(self):
390
384
        self.stack = self.create_stack(stack_id=stack_id,
391
385
                                       stack_name=stack_name)
392
386
 
 
387
        self.m.StubOutWithMock(self.stack.clients.client_plugin('heat'),
 
388
                               'get_heat_cfn_url')
 
389
        self.stack.clients.client_plugin('heat').get_heat_cfn_url().AndReturn(
 
390
            'http://server.test:8000/v1')
 
391
        self.m.ReplayAll()
393
392
        rsrc = self.stack['WaitHandle']
394
393
        # clear the url
395
394
        rsrc.data_set('ec2_signed_url', None, False)
520
519
class WaitConditionUpdateTest(common.HeatTestCase):
521
520
    def setUp(self):
522
521
        super(WaitConditionUpdateTest, self).setUp()
523
 
        cfg.CONF.set_default('heat_waitcondition_server_url',
524
 
                             'http://server.test:8000/v1/waitcondition')
525
522
 
526
 
    def create_stack(self, tmpl=None):
527
 
        if tmpl is None:
528
 
            tmpl = test_template_wc_count
529
 
        temp = template_format.parse(tmpl)
530
 
        template = parser.Template(temp)
 
523
    def create_stack(self, temp=None):
 
524
        if temp is None:
 
525
            temp = test_template_wc_count
 
526
        temp_fmt = template_format.parse(temp)
 
527
        template = tmpl.Template(temp_fmt)
531
528
        ctx = utils.dummy_context(tenant_id='test_tenant')
532
529
        stack = parser.Stack(ctx, 'test_stack', template,
533
530
                             disable_rollback=True)
592
589
        self.m.VerifyAll()
593
590
        self.m.UnsetStubs()
594
591
 
595
 
        wait_condition_handle = self.stack['WaitHandle']
 
592
        handle_stack = self.stack
 
593
        wait_condition_handle = handle_stack['WaitHandle']
596
594
        test_metadata = {'Data': 'foo', 'Reason': 'bar',
597
595
                         'Status': 'SUCCESS', 'UniqueId': '1'}
598
596
        self._handle_signal(wait_condition_handle, test_metadata, 2)
653
651
        updater = scheduler.TaskRunner(rsrc.update, update_snippet)
654
652
        ex = self.assertRaises(exception.ResourceFailure,
655
653
                               updater)
656
 
        self.assertEqual("WaitConditionTimeout: 0 of 5 received",
657
 
                         six.text_type(ex))
 
654
        self.assertEqual("WaitConditionTimeout: resources.WaitForTheHandle: "
 
655
                         "0 of 5 received", six.text_type(ex))
658
656
        self.assertEqual(5, rsrc.properties['Count'])
659
657
        self.m.VerifyAll()