Merge "Use Constraint stubs in common.py"

This commit is contained in:
Jenkins 2014-08-13 23:16:04 +00:00 committed by Gerrit Code Review
commit 3f0083b44b
5 changed files with 20 additions and 41 deletions

View File

@ -878,9 +878,7 @@ class InstancesTest(HeatTestCase):
instance = self._create_test_instance(return_server,
'in_update2')
self.m.StubOutWithMock(glance.ImageConstraint, "validate")
glance.ImageConstraint.validate(
mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(True)
self.stub_ImageConstraint_validate()
self.m.ReplayAll()
update_template = copy.deepcopy(instance.t)
@ -888,6 +886,8 @@ class InstancesTest(HeatTestCase):
updater = scheduler.TaskRunner(instance.update, update_template)
self.assertRaises(resource.UpdateReplace, updater)
self.m.VerifyAll()
def test_instance_status_build(self):
return_server = self.fc.servers.list()[0]
instance = self._setup_test_instance(return_server,

View File

@ -17,11 +17,9 @@ from oslo.config import cfg
from heat.common import identifier
from heat.common import template_format
from heat.engine.clients.os import glance
from heat.engine import environment
from heat.engine import parser
from heat.engine.resources import instance
from heat.engine.resources import nova_keypair
from heat.engine.resources import server
from heat.engine.resources import wait_condition as wc
from heat.engine import scheduler
@ -164,12 +162,8 @@ class MetadataRefreshTest(HeatTestCase):
self.stack_id = stack.store()
self.m.StubOutWithMock(nova_keypair.KeypairConstraint, 'validate')
nova_keypair.KeypairConstraint.validate(
mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(True)
self.m.StubOutWithMock(glance.ImageConstraint, 'validate')
glance.ImageConstraint.validate(
mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(True)
self.stub_ImageConstraint_validate()
self.stub_KeypairConstraint_validate()
self.m.StubOutWithMock(instance.Instance, 'handle_create')
self.m.StubOutWithMock(instance.Instance, 'check_create_complete')
@ -231,12 +225,8 @@ class WaitCondMetadataUpdateTest(HeatTestCase):
self.stack_id = stack.store()
self.m.StubOutWithMock(nova_keypair.KeypairConstraint, 'validate')
nova_keypair.KeypairConstraint.validate(
mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(True)
self.m.StubOutWithMock(glance.ImageConstraint, 'validate')
glance.ImageConstraint.validate(
mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(True)
self.stub_ImageConstraint_validate()
self.stub_KeypairConstraint_validate()
self.m.StubOutWithMock(instance.Instance, 'handle_create')
self.m.StubOutWithMock(instance.Instance, 'check_create_complete')
@ -327,12 +317,8 @@ class MetadataRefreshTestServer(HeatTestCase):
self.stack_id = stack.store()
self.m.StubOutWithMock(nova_keypair.KeypairConstraint, 'validate')
nova_keypair.KeypairConstraint.validate(
mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(True)
self.m.StubOutWithMock(glance.ImageConstraint, 'validate')
glance.ImageConstraint.validate(
mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(True)
self.stub_ImageConstraint_validate()
self.stub_KeypairConstraint_validate()
self.m.StubOutWithMock(server.Server, 'handle_create')
self.m.StubOutWithMock(server.Server, 'check_create_complete')

View File

@ -20,7 +20,6 @@ from oslo.config import cfg
from heat.common import template_format
from heat.db import api as db_api
from heat.engine.clients.os import glance
from heat.engine import environment
from heat.engine import parser
from heat.engine.resources import instance
@ -129,7 +128,6 @@ class AutoScalingTest(HeatTestCase):
self.m.StubOutWithMock(instance.Instance, 'handle_create')
self.m.StubOutWithMock(instance.Instance, 'check_create_complete')
self.m.StubOutWithMock(glance.ImageConstraint, "validate")
def test_lb(self):
@ -278,8 +276,7 @@ class AutoScalingTest(HeatTestCase):
instance.Instance.check_create_complete(mox.IgnoreArg())\
.AndReturn(True)
glance.ImageConstraint.validate(
mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(True)
self.stub_ImageConstraint_validate()
nova_utils.server_to_ipaddress(
mox.IgnoreArg(),

View File

@ -825,14 +825,11 @@ class ServersTest(HeatTestCase):
server = servers.Server('server_validate_test',
resource_defns['WebServer'], stack)
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
self.m.StubOutWithMock(glance.ImageConstraint, "validate")
glance.ImageConstraint.validate(
mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(True)
self.m.ReplayAll()
self.stub_ImageConstraint_validate()
self.m.ReplayAll()
self.assertIsNone(server.validate())
self.m.VerifyAll()
def test_server_validate_with_invalid_ssh_key(self):
@ -1232,9 +1229,7 @@ class ServersTest(HeatTestCase):
image_id = self.getUniqueString()
self.m.StubOutWithMock(nova.NovaClientPlugin, '_create')
nova.NovaClientPlugin._create().AndReturn(self.fc)
self.m.StubOutWithMock(glance.ImageConstraint, "validate")
glance.ImageConstraint.validate(
mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(True)
self.stub_ImageConstraint_validate()
self.m.ReplayAll()
update_template = copy.deepcopy(server.t)
@ -1242,6 +1237,8 @@ class ServersTest(HeatTestCase):
updater = scheduler.TaskRunner(server.update, update_template)
self.assertRaises(resource.UpdateReplace, updater)
self.m.VerifyAll()
def _test_server_update_image_rebuild(self, status, policy='REBUILD'):
# Server.handle_update supports changing the image, and makes
# the change making a rebuild API call against Nova.
@ -1342,9 +1339,7 @@ class ServersTest(HeatTestCase):
server = self._create_test_server(return_server,
'update_prop')
self.m.StubOutWithMock(glance.ImageConstraint, "validate")
glance.ImageConstraint.validate(
mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(True)
self.stub_ImageConstraint_validate()
self.m.ReplayAll()
update_template = copy.deepcopy(server.t)
@ -1352,6 +1347,8 @@ class ServersTest(HeatTestCase):
updater = scheduler.TaskRunner(server.update, update_template)
self.assertRaises(resource.UpdateReplace, updater)
self.m.VerifyAll()
def test_server_status_build(self):
return_server = self.fc.servers.list()[0]
server = self._setup_test_server(return_server,

View File

@ -223,13 +223,12 @@ class VolumeTest(HeatTestCase):
self.m.StubOutWithMock(instance.Instance, 'check_create_complete')
self.m.StubOutWithMock(vol.VolumeAttachment, 'handle_create')
self.m.StubOutWithMock(vol.VolumeAttachment, 'check_create_complete')
self.m.StubOutWithMock(glance.ImageConstraint, "validate")
instance.Instance.handle_create().AndReturn(None)
instance.Instance.check_create_complete(None).AndReturn(True)
cinder.CinderClientPlugin._create().AndReturn(
self.cinder_fc)
glance.ImageConstraint.validate(
mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(True)
self.stub_ImageConstraint_validate()
vol_name = utils.PhysName(stack_name, 'DataVolume')
self.cinder_fc.volumes.create(
size=1, availability_zone=None,