Tests for WSGI/Launcher

This commit is contained in:
Brian Lamar
2011-06-21 00:21:33 -04:00
parent e849aa7112
commit c17c73b3d0
3 changed files with 33 additions and 5 deletions

View File

@@ -38,12 +38,12 @@ def main():
launcher = nova.service.Launcher(sys.argv)
launcher.launch_service(ec2)
launcher.launch_service(osapi)
try:
launcher.wait()
except KeyboardInterrupt:
launcher.stop()
if __name__ == '__main__':
sys.exit(main())

View File

@@ -69,9 +69,8 @@ class Launcher(object):
self._version = version.version_string_with_vcs()
logging.setup()
logging.audit(_("Nova Version (%(_version)s)") % self.__dict__)
FLAGS(_flags)
utils.default_flagfile()
FLAGS(_flags or [])
@staticmethod
def run_service(service):
@@ -120,7 +119,6 @@ class Launcher(object):
logging.info("Process exited with %d" % service.exitcode)
class Service(object):
"""Base class for workers that run on hosts."""

View File

@@ -21,6 +21,7 @@ Unit Tests for remote procedure calls using queue
"""
import mox
import unittest2 as unittest
from nova import context
from nova import db
@@ -30,6 +31,7 @@ from nova import rpc
from nova import test
from nova import service
from nova import manager
from nova import wsgi
from nova.compute import manager as compute_manager
FLAGS = flags.FLAGS
@@ -349,3 +351,31 @@ class ServiceTestCase(test.TestCase):
serv.stop()
db.service_destroy(ctxt, service_ref['id'])
class TestWSGIService(test.TestCase):
def setUp(self):
super(TestWSGIService, self).setUp()
self.stubs.Set(wsgi.Loader, "load_app", mox.MockAnything())
def test_service_random_port(self):
test_service = service.WSGIService("test_service")
self.assertEquals(0, test_service.port)
test_service.start()
self.assertNotEqual(0, test_service.port)
test_service.stop()
class TestLauncher(test.TestCase):
def setUp(self):
super(TestLauncher, self).setUp()
self.stubs.Set(wsgi.Loader, "load_app", mox.MockAnything())
self.service = service.WSGIService("test_service")
def test_launch_app(self):
self.assertEquals(0, self.service.port)
launcher = service.Launcher()
launcher.launch_service(self.service)
self.assertEquals(0, self.service.port)
launcher.stop()