Store stacks in the database when running unit tests

If stacks are not stored in the database before they are create()'d,
anything that refers to a stack (e.g. Resources and Events) cannot be added
to the database either, and we get numerous errors in any output logs.

Change-Id: Icd1012455d413aad617486c138fd4507e391bc7b
This commit is contained in:
Zane Bitter 2013-06-14 12:31:23 +02:00
parent 84accc898c
commit 157223c4e9
3 changed files with 4 additions and 5 deletions

View File

@ -466,7 +466,7 @@ class AutoScalingTest(HeatTestCase):
now = now + datetime.timedelta(seconds=10)
self.m.StubOutWithMock(timeutils, 'utcnow')
timeutils.utcnow().AndReturn(now)
timeutils.utcnow().MultipleTimes().AndReturn(now)
self.m.StubOutWithMock(Metadata, '__get__')
Metadata.__get__(mox.IgnoreArg(), rsrc, mox.IgnoreArg()
@ -677,7 +677,7 @@ class AutoScalingTest(HeatTestCase):
now = now + datetime.timedelta(seconds=10)
self.m.StubOutWithMock(timeutils, 'utcnow')
timeutils.utcnow().AndReturn(now)
timeutils.utcnow().MultipleTimes().AndReturn(now)
self.m.StubOutWithMock(Metadata, '__get__')
Metadata.__get__(mox.IgnoreArg(), up_policy, mox.IgnoreArg()

View File

@ -16,7 +16,6 @@ from heat.tests.v1_1 import fakes
from heat.engine.resources import instance as instances
from heat.common import template_format
from heat.engine import scheduler
from heat.openstack.common import uuidutils
from heat.tests.common import HeatTestCase
from heat.tests import utils
from heat.tests.utils import setup_dummy_db
@ -52,8 +51,7 @@ class nokeyTest(HeatTestCase):
stack_name = 'instance_create_test_nokey_stack'
t = template_format.parse(nokey_template)
stack = parse_stack(t, stack_name=stack_name,
stack_id=uuidutils.generate_uuid())
stack = parse_stack(t, stack_name=stack_name)
t['Resources']['WebServer']['Properties']['ImageId'] = 'CentOS 5.2'
t['Resources']['WebServer']['Properties']['InstanceType'] = \

View File

@ -64,6 +64,7 @@ def parse_stack(t, params={}, stack_name='test_stack', stack_id=None):
template = parser.Template(t)
parameters = parser.Parameters(stack_name, template, params)
stack = parser.Stack(ctx, stack_name, template, parameters, stack_id)
stack.store()
return stack