merged trunk, just in case
This commit is contained in:
@@ -37,13 +37,18 @@ from nova import utils
|
|||||||
from nova import server
|
from nova import server
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
flags.DEFINE_integer('api_port', 8773, 'API port')
|
flags.DEFINE_integer('osapi_port', 8774, 'OpenStack API port')
|
||||||
|
flags.DEFINE_integer('ec2api_port', 8773, 'EC2 API port')
|
||||||
|
|
||||||
|
|
||||||
def main(_args):
|
def main(_args):
|
||||||
from nova import api
|
from nova import api
|
||||||
from nova import wsgi
|
from nova import wsgi
|
||||||
wsgi.run_server(api.API(), FLAGS.api_port)
|
server = wsgi.Server()
|
||||||
|
server.start(api.API('os'), FLAGS.osapi_port)
|
||||||
|
server.start(api.API('ec2'), FLAGS.ec2api_port)
|
||||||
|
server.wait()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
utils.default_flagfile()
|
utils.default_flagfile()
|
||||||
|
|||||||
@@ -34,10 +34,6 @@ from nova.api.ec2 import apirequest
|
|||||||
from nova.auth import manager
|
from nova.auth import manager
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
|
||||||
FLAGS.FAKE_subdomain = 'ec2'
|
|
||||||
|
|
||||||
|
|
||||||
class FakeHttplibSocket(object):
|
class FakeHttplibSocket(object):
|
||||||
"""a fake socket implementation for httplib.HTTPResponse, trivial"""
|
"""a fake socket implementation for httplib.HTTPResponse, trivial"""
|
||||||
def __init__(self, response_string):
|
def __init__(self, response_string):
|
||||||
@@ -83,7 +79,7 @@ class FakeHttplibConnection(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class XmlConversionTestCase(test.BaseTestCase):
|
class XmlConversionTestCase(test.TrialTestCase):
|
||||||
"""Unit test api xml conversion"""
|
"""Unit test api xml conversion"""
|
||||||
def test_number_conversion(self):
|
def test_number_conversion(self):
|
||||||
conv = apirequest._try_convert
|
conv = apirequest._try_convert
|
||||||
@@ -100,7 +96,7 @@ class XmlConversionTestCase(test.BaseTestCase):
|
|||||||
self.assertEqual(conv('-0'), 0)
|
self.assertEqual(conv('-0'), 0)
|
||||||
|
|
||||||
|
|
||||||
class ApiEc2TestCase(test.BaseTestCase):
|
class ApiEc2TestCase(test.TrialTestCase):
|
||||||
"""Unit test for the cloud controller on an EC2 API"""
|
"""Unit test for the cloud controller on an EC2 API"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ApiEc2TestCase, self).setUp()
|
super(ApiEc2TestCase, self).setUp()
|
||||||
@@ -109,7 +105,7 @@ class ApiEc2TestCase(test.BaseTestCase):
|
|||||||
|
|
||||||
self.host = '127.0.0.1'
|
self.host = '127.0.0.1'
|
||||||
|
|
||||||
self.app = api.API()
|
self.app = api.API('ec2')
|
||||||
|
|
||||||
def expect_http(self, host=None, is_secure=False):
|
def expect_http(self, host=None, is_secure=False):
|
||||||
"""Returns a new EC2 connection"""
|
"""Returns a new EC2 connection"""
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ Unit Tests for remote procedure calls using queue
|
|||||||
import mox
|
import mox
|
||||||
|
|
||||||
from twisted.application.app import startApplication
|
from twisted.application.app import startApplication
|
||||||
|
from twisted.internet import defer
|
||||||
|
|
||||||
from nova import context
|
|
||||||
from nova import exception
|
from nova import exception
|
||||||
from nova import flags
|
from nova import flags
|
||||||
from nova import rpc
|
from nova import rpc
|
||||||
@@ -48,7 +48,7 @@ class ExtendedService(service.Service):
|
|||||||
return 'service'
|
return 'service'
|
||||||
|
|
||||||
|
|
||||||
class ServiceManagerTestCase(test.BaseTestCase):
|
class ServiceManagerTestCase(test.TrialTestCase):
|
||||||
"""Test cases for Services"""
|
"""Test cases for Services"""
|
||||||
|
|
||||||
def test_attribute_error_for_no_manager(self):
|
def test_attribute_error_for_no_manager(self):
|
||||||
@@ -75,13 +75,12 @@ class ServiceManagerTestCase(test.BaseTestCase):
|
|||||||
self.assertEqual(serv.test_method(), 'service')
|
self.assertEqual(serv.test_method(), 'service')
|
||||||
|
|
||||||
|
|
||||||
class ServiceTestCase(test.BaseTestCase):
|
class ServiceTestCase(test.TrialTestCase):
|
||||||
"""Test cases for Services"""
|
"""Test cases for Services"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ServiceTestCase, self).setUp()
|
super(ServiceTestCase, self).setUp()
|
||||||
self.mox.StubOutWithMock(service, 'db')
|
self.mox.StubOutWithMock(service, 'db')
|
||||||
self.context = context.get_admin_context()
|
|
||||||
|
|
||||||
def test_create(self):
|
def test_create(self):
|
||||||
host = 'foo'
|
host = 'foo'
|
||||||
@@ -144,87 +143,103 @@ class ServiceTestCase(test.BaseTestCase):
|
|||||||
# whether it is disconnected, it looks for a variable on itself called
|
# whether it is disconnected, it looks for a variable on itself called
|
||||||
# 'model_disconnected' and report_state doesn't really do much so this
|
# 'model_disconnected' and report_state doesn't really do much so this
|
||||||
# these are mostly just for coverage
|
# these are mostly just for coverage
|
||||||
def test_report_state(self):
|
@defer.inlineCallbacks
|
||||||
host = 'foo'
|
|
||||||
binary = 'bar'
|
|
||||||
service_ref = {'host': host,
|
|
||||||
'binary': binary,
|
|
||||||
'report_count': 0,
|
|
||||||
'id': 1}
|
|
||||||
service.db.__getattr__('report_state')
|
|
||||||
service.db.service_get_by_args(self.context,
|
|
||||||
host,
|
|
||||||
binary).AndReturn(service_ref)
|
|
||||||
service.db.service_update(self.context, service_ref['id'],
|
|
||||||
mox.ContainsKeyValue('report_count', 1))
|
|
||||||
|
|
||||||
self.mox.ReplayAll()
|
|
||||||
s = service.Service()
|
|
||||||
rv = yield s.report_state(host, binary)
|
|
||||||
|
|
||||||
def test_report_state_no_service(self):
|
def test_report_state_no_service(self):
|
||||||
host = 'foo'
|
host = 'foo'
|
||||||
binary = 'bar'
|
binary = 'bar'
|
||||||
|
topic = 'test'
|
||||||
service_create = {'host': host,
|
service_create = {'host': host,
|
||||||
'binary': binary,
|
'binary': binary,
|
||||||
|
'topic': topic,
|
||||||
'report_count': 0}
|
'report_count': 0}
|
||||||
service_ref = {'host': host,
|
service_ref = {'host': host,
|
||||||
'binary': binary,
|
'binary': binary,
|
||||||
'report_count': 0,
|
'topic': topic,
|
||||||
'id': 1}
|
'report_count': 0,
|
||||||
|
'id': 1}
|
||||||
|
|
||||||
service.db.__getattr__('report_state')
|
service.db.service_get_by_args(mox.IgnoreArg(),
|
||||||
service.db.service_get_by_args(self.context,
|
|
||||||
host,
|
host,
|
||||||
binary).AndRaise(exception.NotFound())
|
binary).AndRaise(exception.NotFound())
|
||||||
service.db.service_create(self.context,
|
service.db.service_create(mox.IgnoreArg(),
|
||||||
service_create).AndReturn(service_ref)
|
service_create).AndReturn(service_ref)
|
||||||
service.db.service_get(self.context,
|
service.db.service_get(mox.IgnoreArg(),
|
||||||
service_ref['id']).AndReturn(service_ref)
|
service_ref['id']).AndReturn(service_ref)
|
||||||
service.db.service_update(self.context, service_ref['id'],
|
service.db.service_update(mox.IgnoreArg(), service_ref['id'],
|
||||||
mox.ContainsKeyValue('report_count', 1))
|
mox.ContainsKeyValue('report_count', 1))
|
||||||
|
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
s = service.Service()
|
serv = service.Service(host,
|
||||||
rv = yield s.report_state(host, binary)
|
binary,
|
||||||
|
topic,
|
||||||
|
'nova.tests.service_unittest.FakeManager')
|
||||||
|
serv.startService()
|
||||||
|
yield serv.report_state()
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
def test_report_state_newly_disconnected(self):
|
def test_report_state_newly_disconnected(self):
|
||||||
host = 'foo'
|
host = 'foo'
|
||||||
binary = 'bar'
|
binary = 'bar'
|
||||||
|
topic = 'test'
|
||||||
|
service_create = {'host': host,
|
||||||
|
'binary': binary,
|
||||||
|
'topic': topic,
|
||||||
|
'report_count': 0}
|
||||||
service_ref = {'host': host,
|
service_ref = {'host': host,
|
||||||
'binary': binary,
|
'binary': binary,
|
||||||
'report_count': 0,
|
'topic': topic,
|
||||||
'id': 1}
|
'report_count': 0,
|
||||||
|
'id': 1}
|
||||||
|
|
||||||
service.db.__getattr__('report_state')
|
service.db.service_get_by_args(mox.IgnoreArg(),
|
||||||
service.db.service_get_by_args(self.context,
|
host,
|
||||||
host,
|
binary).AndRaise(exception.NotFound())
|
||||||
binary).AndRaise(Exception())
|
service.db.service_create(mox.IgnoreArg(),
|
||||||
|
service_create).AndReturn(service_ref)
|
||||||
|
service.db.service_get(mox.IgnoreArg(),
|
||||||
|
mox.IgnoreArg()).AndRaise(Exception())
|
||||||
|
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
s = service.Service()
|
serv = service.Service(host,
|
||||||
rv = yield s.report_state(host, binary)
|
binary,
|
||||||
|
topic,
|
||||||
self.assert_(s.model_disconnected)
|
'nova.tests.service_unittest.FakeManager')
|
||||||
|
serv.startService()
|
||||||
|
yield serv.report_state()
|
||||||
|
self.assert_(serv.model_disconnected)
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
def test_report_state_newly_connected(self):
|
def test_report_state_newly_connected(self):
|
||||||
host = 'foo'
|
host = 'foo'
|
||||||
binary = 'bar'
|
binary = 'bar'
|
||||||
|
topic = 'test'
|
||||||
|
service_create = {'host': host,
|
||||||
|
'binary': binary,
|
||||||
|
'topic': topic,
|
||||||
|
'report_count': 0}
|
||||||
service_ref = {'host': host,
|
service_ref = {'host': host,
|
||||||
'binary': binary,
|
'binary': binary,
|
||||||
'report_count': 0,
|
'topic': topic,
|
||||||
'id': 1}
|
'report_count': 0,
|
||||||
|
'id': 1}
|
||||||
|
|
||||||
service.db.__getattr__('report_state')
|
service.db.service_get_by_args(mox.IgnoreArg(),
|
||||||
service.db.service_get_by_args(self.context,
|
host,
|
||||||
host,
|
binary).AndRaise(exception.NotFound())
|
||||||
binary).AndReturn(service_ref)
|
service.db.service_create(mox.IgnoreArg(),
|
||||||
service.db.service_update(self.context, service_ref['id'],
|
service_create).AndReturn(service_ref)
|
||||||
|
service.db.service_get(mox.IgnoreArg(),
|
||||||
|
service_ref['id']).AndReturn(service_ref)
|
||||||
|
service.db.service_update(mox.IgnoreArg(), service_ref['id'],
|
||||||
mox.ContainsKeyValue('report_count', 1))
|
mox.ContainsKeyValue('report_count', 1))
|
||||||
|
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
s = service.Service()
|
serv = service.Service(host,
|
||||||
s.model_disconnected = True
|
binary,
|
||||||
rv = yield s.report_state(host, binary)
|
topic,
|
||||||
|
'nova.tests.service_unittest.FakeManager')
|
||||||
|
serv.startService()
|
||||||
|
serv.model_disconnected = True
|
||||||
|
yield serv.report_state()
|
||||||
|
|
||||||
self.assert_(not s.model_disconnected)
|
self.assert_(not serv.model_disconnected)
|
||||||
|
|||||||
Reference in New Issue
Block a user