def initialize_application(): objects.register_all() CONF(sys.argv[1:], project='karbor', version=version.version_string()) logging.setup(CONF, "karbor") rpc.init(CONF) return wsgi.Loader(CONF).load_app(name='osapi_karbor')
def setUp(self): """Run before each test method to initialize test environment.""" super(TestCase, self).setUp() rpc.add_extra_exmods("karbor.tests.unit") self.addCleanup(rpc.clear_extra_exmods) self.addCleanup(rpc.cleanup) self.messaging_conf = messaging_conffixture.ConfFixture(CONF) self.messaging_conf.transport_driver = 'fake' self.messaging_conf.response_timeout = 15 self.useFixture(self.messaging_conf) rpc.init(CONF) conf_fixture.set_defaults(CONF) CONF([], default_config_files=[]) # NOTE(vish): We need a better method for creating fixtures for tests # now that we have some required db setup for the system # to work properly. self.start = timeutils.utcnow() CONF.set_default('connection', 'sqlite://', 'database') CONF.set_default('sqlite_synchronous', False, 'database') global _DB_CACHE if not _DB_CACHE: _DB_CACHE = Database(sqla_api, migration, sql_connection=CONF.database.connection) self.useFixture(_DB_CACHE)
def test_init_notifications(self, messaging_mock): self.override_config('driver', ['test'], group='oslo_messaging_notifications') rpc.init(CONF) self.assertTrue(messaging_mock.JsonPayloadSerializer.called) self.assertTrue(messaging_mock.Notifier.called) self.assertEqual(rpc.NOTIFIER, messaging_mock.Notifier.return_value)
def __init__(self, host, binary, topic, manager, report_interval=None, periodic_interval=None, periodic_fuzzy_delay=None, service_name=None, *args, **kwargs): super(Service, self).__init__() rpc.init(CONF) self.host = host self.binary = binary self.topic = topic self.manager_class_name = manager manager_class = importutils.import_class(self.manager_class_name) self.manager = manager_class(host=self.host, service_name=service_name, *args, **kwargs) self.report_interval = report_interval self.periodic_interval = periodic_interval self.periodic_fuzzy_delay = periodic_fuzzy_delay self.basic_config_check() self.saved_args, self.saved_kwargs = args, kwargs self.timers = [] self.rpcserver = None
def test_init_no_notifications(self, serializer_mock): """Test short-circuiting notifications with default and noop driver.""" driver = ['noop'] self.override_config('driver', driver, group='oslo_messaging_notifications') rpc.init(CONF) self.assertEqual(rpc.utils.DO_NOTHING, rpc.NOTIFIER) serializer_mock.assert_not_called()
def main(): objects.register_all() CONF(sys.argv[1:], project='karbor', version=version.version_string()) logging.setup(CONF, "karbor") rpc.init(CONF) launcher = service.get_launcher() server = service.WSGIService('osapi_karbor') launcher.launch_service(server, workers=server.workers) launcher.wait()
def setUp(self): """Run before each test method to initialize test environment.""" super(TestCase, self).setUp() rpc.add_extra_exmods("karbor.tests.unit") self.addCleanup(rpc.clear_extra_exmods) self.addCleanup(rpc.cleanup) self.messaging_conf = messaging_conffixture.ConfFixture(CONF) self.messaging_conf.transport_driver = 'fake' self.messaging_conf.response_timeout = 15 self.useFixture(self.messaging_conf) rpc.init(CONF) conf_fixture.set_defaults(CONF) CONF([], default_config_files=[]) # NOTE(vish): We need a better method for creating fixtures for tests # now that we have some required db setup for the system # to work properly. self.start = timeutils.utcnow() CONF.set_default('connection', 'sqlite://', 'database') CONF.set_default('sqlite_synchronous', False, 'database') global _DB_CACHE if not _DB_CACHE: _DB_CACHE = Database(sqla_api, migration, sql_connection=CONF.database.connection) self.useFixture(_DB_CACHE) self.override_config('policy_file', os.path.join( os.path.abspath( os.path.join( os.path.dirname(__file__), '..', ) ), 'tests/unit/policy.json'), group='oslo_policy')