Merge "Don't decide web_framework before config parse"

This commit is contained in:
Jenkins 2016-02-04 04:09:37 +00:00 committed by Gerrit Code Review
commit b80d77ddfe
5 changed files with 15 additions and 35 deletions

View File

@ -12,27 +12,22 @@
from oslo_config import cfg
from neutron import server
from neutron.server import rpc_eventlet
from neutron.server import wsgi_eventlet
from neutron.server import wsgi_pecan
def main():
server.boot_server(_main_neutron_server)
def _main_neutron_server():
if cfg.CONF.web_framework == 'legacy':
main_wsgi_eventlet()
wsgi_eventlet.eventlet_wsgi_server()
else:
main_wsgi_pecan()
def main_wsgi_eventlet():
wsgi_eventlet.main()
# Eventlet patching is not required for Pecan, but some plugins still spawn
# eventlet threads
def main_wsgi_pecan():
wsgi_pecan.main()
wsgi_pecan.pecan_wsgi_server()
def main_rpc_eventlet():
rpc_eventlet.main()
server.boot_server(rpc_eventlet.eventlet_rpc_server)

View File

@ -22,13 +22,12 @@ import eventlet
from oslo_log import log
from neutron._i18n import _LI
from neutron import server
from neutron import service
LOG = log.getLogger(__name__)
def _eventlet_rpc_server():
def eventlet_rpc_server():
pool = eventlet.GreenPool()
LOG.info(_LI("Eventlet based AMQP RPC server starting..."))
try:
@ -39,7 +38,3 @@ def _eventlet_rpc_server():
else:
pool.spawn(neutron_rpc.wait)
pool.waitall()
def main():
server.boot_server(_eventlet_rpc_server)

View File

@ -15,13 +15,12 @@ import eventlet
from oslo_log import log
from neutron._i18n import _LI
from neutron import server
from neutron import service
LOG = log.getLogger(__name__)
def _eventlet_wsgi_server():
def eventlet_wsgi_server():
pool = eventlet.GreenPool()
neutron_api = service.serve_wsgi(service.NeutronApiService)
@ -44,7 +43,3 @@ def _eventlet_wsgi_server():
api_thread.link(lambda gt: rpc_thread.kill())
pool.waitall()
def main():
server.boot_server(_eventlet_wsgi_server)

View File

@ -21,7 +21,6 @@ from six.moves import socketserver
from neutron._i18n import _LI, _LW
from neutron.common import rpc as n_rpc
from neutron.pecan_wsgi import app as pecan_app
from neutron import server
LOG = log.getLogger(__name__)
@ -31,7 +30,7 @@ class ThreadedSimpleServer(socketserver.ThreadingMixIn,
pass
def _pecan_wsgi_server():
def pecan_wsgi_server():
LOG.info(_LI("Pecan WSGI server starting..."))
# No AMQP connection should be created within this process
n_rpc.RPC_DISABLED = True
@ -54,7 +53,3 @@ def _pecan_wsgi_server():
)
wsgi.serve_forever()
def main():
server.boot_server(_pecan_wsgi_server)

View File

@ -17,18 +17,18 @@ from neutron.cmd.eventlet import server
from neutron.tests import base
@mock.patch('neutron.cmd.eventlet.server.main_wsgi_eventlet')
@mock.patch('neutron.cmd.eventlet.server.main_wsgi_pecan')
@mock.patch('neutron.server.wsgi_eventlet.eventlet_wsgi_server')
@mock.patch('neutron.server.wsgi_pecan.pecan_wsgi_server')
class TestNeutronServer(base.BaseTestCase):
def test_legacy_server(self, pecan_mock, legacy_mock):
cfg.CONF.set_override('web_framework', 'legacy')
server.main()
server._main_neutron_server()
pecan_mock.assert_not_called()
legacy_mock.assert_called_with()
def test_pecan_server(self, pecan_mock, legacy_mock):
cfg.CONF.set_override('web_framework', 'pecan')
server.main()
server._main_neutron_server()
pecan_mock.assert_called_with()
legacy_mock.assert_not_called()