Start up nova-api service on an unused port if 0 is specified. Fixes bug 744150
This commit is contained in:
@@ -248,6 +248,12 @@ class WsgiService(object):
|
|||||||
def wait(self):
|
def wait(self):
|
||||||
self.wsgi_app.wait()
|
self.wsgi_app.wait()
|
||||||
|
|
||||||
|
def get_port(self, api):
|
||||||
|
for i in xrange(len(self.apis)):
|
||||||
|
if self.apis[i] == api:
|
||||||
|
return self.wsgi_app.ports[i]
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class ApiService(WsgiService):
|
class ApiService(WsgiService):
|
||||||
"""Class for our nova-api service"""
|
"""Class for our nova-api service"""
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ class IntegratedUnitTestContext(object):
|
|||||||
|
|
||||||
self.api_service = api_service
|
self.api_service = api_service
|
||||||
|
|
||||||
self.auth_url = 'http://localhost:8774/v1.0'
|
host, port = api_service.get_port('osapi')
|
||||||
|
self.auth_url = 'http://%s:%s/v1.0' % (host, port)
|
||||||
|
|
||||||
return api_service
|
return api_service
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ FLAGS.verbose = True
|
|||||||
class LoginTest(test.TestCase):
|
class LoginTest(test.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(LoginTest, self).setUp()
|
super(LoginTest, self).setUp()
|
||||||
|
self.flags(ec2_listen_port=0, osapi_listen_port=0)
|
||||||
self.context = integrated_helpers.IntegratedUnitTestContext()
|
self.context = integrated_helpers.IntegratedUnitTestContext()
|
||||||
self.user = self.context.test_user
|
self.user = self.context.test_user
|
||||||
self.api = self.user.openstack_api
|
self.api = self.user.openstack_api
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class Server(object):
|
|||||||
|
|
||||||
def __init__(self, threads=1000):
|
def __init__(self, threads=1000):
|
||||||
self.pool = eventlet.GreenPool(threads)
|
self.pool = eventlet.GreenPool(threads)
|
||||||
|
self.ports = []
|
||||||
|
|
||||||
def start(self, application, port, host='0.0.0.0', backlog=128):
|
def start(self, application, port, host='0.0.0.0', backlog=128):
|
||||||
"""Run a WSGI server with the given application."""
|
"""Run a WSGI server with the given application."""
|
||||||
@@ -68,6 +69,7 @@ class Server(object):
|
|||||||
logging.audit(_("Starting %(arg0)s on %(host)s:%(port)s") % locals())
|
logging.audit(_("Starting %(arg0)s on %(host)s:%(port)s") % locals())
|
||||||
socket = eventlet.listen((host, port), backlog=backlog)
|
socket = eventlet.listen((host, port), backlog=backlog)
|
||||||
self.pool.spawn_n(self._run, application, socket)
|
self.pool.spawn_n(self._run, application, socket)
|
||||||
|
self.ports.append(socket.getsockname())
|
||||||
|
|
||||||
def wait(self):
|
def wait(self):
|
||||||
"""Wait until all servers have completed running."""
|
"""Wait until all servers have completed running."""
|
||||||
|
|||||||
Reference in New Issue
Block a user