def test_workers_set_correct_setting(self): self.override_config('api_workers', 8, group='api') with mock.patch('mistral.api.app.setup_app'): test_service = service.WSGIService("mistral_api") self.assertEqual(8, test_service.workers)
def launch_api(): launcher = service.ProcessLauncher(cfg.CONF) server = api_service.WSGIService('mistral_api') launcher.launch_service(server, workers=server.workers) launcher.wait()
def test_workers_set_zero_setting(self): self.override_config('api_workers', 0, group='api') with mock.patch('mistral.api.app.setup_app'): test_service = service.WSGIService("mistral_api") self.assertEqual( processutils.get_worker_count(), test_service.workers )
def test_workers_set_default(self, wsgi_server): service_name = "mistral_api" with mock.patch('mistral.api.app.setup_app'): test_service = service.WSGIService(service_name) wsgi_server.assert_called_once_with( cfg.CONF, service_name, test_service.app, host='0.0.0.0', port=8989, use_ssl=False )
def test_workers_set_zero_setting(self, wsgi_server, mock_app): self.override_config('api_workers', 0, group='api') mock_app.return_value = pecan.testing.load_test_app({ 'app': { 'root': cfg.CONF.pecan.root, 'modules': cfg.CONF.pecan.modules, 'debug': cfg.CONF.pecan.debug, 'auth_enable': cfg.CONF.pecan.auth_enable, 'disable_cron_trigger_thread': True } }) test_service = service.WSGIService("mistral_api") self.assertEqual(processutils.get_worker_count(), test_service.workers)
def test_wsgi_service_with_ssl_enabled(self, wsgi_server): self.override_config('enable_ssl_api', True, group='api') service_name = 'mistral_api' with mock.patch('mistral.api.app.setup_app'): srv = service.WSGIService(service_name) wsgi_server.assert_called_once_with( cfg.CONF, service_name, srv.app, host='0.0.0.0', port=8989, use_ssl=True )
def test_launch_process(self): eventlet.spawn(launch.launch_any, ['api']) for i in range(0, 50): svr_proc_mgr = launch.get_server_process_manager() if svr_proc_mgr: break eventlet.sleep(0.1) svr_thrd_mgr = launch.get_server_thread_manager() self.assertIsNotNone(svr_proc_mgr) self.assertIsNone(svr_thrd_mgr) api_server = api_service.WSGIService('mistral_api') api_workers = api_server.workers self._await(lambda: len(svr_proc_mgr.children.keys()) == api_workers)
def test_workers_set_default(self, wsgi_server, mock_app): service_name = "mistral_api" mock_app.return_value = pecan.testing.load_test_app({ 'app': { 'root': cfg.CONF.pecan.root, 'modules': cfg.CONF.pecan.modules, 'debug': cfg.CONF.pecan.debug, 'auth_enable': cfg.CONF.pecan.auth_enable, 'disable_cron_trigger_thread': True } }) test_service = service.WSGIService(service_name) wsgi_server.assert_called_once_with( cfg.CONF, service_name, test_service.app, host='0.0.0.0', port=8989, use_ssl=False )
def test_wsgi_service_with_ssl_enabled(self, wsgi_server, mock_app): self.override_config('enable_ssl_api', True, group='api') mock_app.return_value = pecan.testing.load_test_app({ 'app': { 'root': cfg.CONF.pecan.root, 'modules': cfg.CONF.pecan.modules, 'debug': cfg.CONF.pecan.debug, 'auth_enable': cfg.CONF.pecan.auth_enable, 'disable_cron_trigger_thread': True } }) service_name = 'mistral_api' srv = service.WSGIService(service_name) wsgi_server.assert_called_once_with( cfg.CONF, service_name, srv.app, host='0.0.0.0', port=8989, use_ssl=True )
def launch_api(): server = api_service.WSGIService('mistral_api') launch_process(server, workers=server.workers)
def launch_api(): launcher = mistral_service.process_launcher() server = mistral_service.WSGIService('mistral_api') launcher.launch_service(server, workers=server.workers) launcher.wait()