def start(self): orchestrator = orchestra_base.load_orchestrator(CONF) db_api.setup_db() LOG.info('Starting periodic tasks...') periodics.start_function_mapping_handler(orchestrator) topic = CONF.engine.topic server = CONF.engine.host transport = messaging.get_transport(CONF) target = messaging.Target(topic=topic, server=server, fanout=False) endpoints = [engine.DefaultEngine(orchestrator)] access_policy = dispatcher.DefaultRPCAccessPolicy self.server = messaging.get_rpc_server( transport, target, endpoints, executor='eventlet', access_policy=access_policy, serializer=rpc.ContextSerializer( messaging.serializer.JsonPayloadSerializer())) LOG.info('Starting engine...') self.server.start() super(EngineService, self).start()
def setUp(self): super(TestDefaultEngine, self).setUp() self.orchestrator = mock.Mock() self.qinling_endpoint = 'http://127.0.0.1:7070' self.default_engine = default_engine.DefaultEngine( self.orchestrator, self.qinling_endpoint) self.rlimit = { 'cpu': cfg.CONF.resource_limits.default_cpu, 'memory_size': cfg.CONF.resource_limits.default_memory }
def test_function_service_expiration_handler(self, mock_etcd_url, mock_etcd_delete): db_func = self.create_function(runtime_id=None, prefix=self.TEST_CASE_NAME) function_id = db_func.id # Update function to simulate function execution db_api.update_function(function_id, {'count': 1}) time.sleep(1.5) mock_k8s = mock.Mock() mock_etcd_url.return_value = 'http://localhost:37718' self.override_config('function_service_expiration', 1, 'engine') engine = default_engine.DefaultEngine(mock_k8s, CONF.qinling_endpoint) periodics.handle_function_service_expiration(self.ctx, engine) self.assertEqual(1, mock_k8s.delete_function.call_count) args, kwargs = mock_k8s.delete_function.call_args self.assertIn(function_id, args) mock_etcd_delete.assert_called_once_with(function_id)
def start(self): orchestrator = orchestra_base.load_orchestrator(CONF) topic = CONF.engine.topic server = CONF.engine.host transport = messaging.get_transport(CONF) target = messaging.Target(topic=topic, server=server, fanout=False) endpoints = [engine.DefaultEngine(orchestrator)] self.server = messaging.get_rpc_server( transport, target, endpoints, executor='eventlet', serializer=rpc.ContextSerializer( messaging.serializer.JsonPayloadSerializer())) db_api.setup_db() LOG.info('Starting engine...') self.server.start() super(EngineService, self).start()
def run(self): qinling_endpoint = keystone_utils.get_qinling_endpoint() orchestrator = orchestra_base.load_orchestrator(CONF, qinling_endpoint) db_api.setup_db() topic = CONF.engine.topic server = CONF.engine.host transport = messaging.get_rpc_transport(CONF) target = messaging.Target(topic=topic, server=server, fanout=False) endpoint = engine.DefaultEngine(orchestrator, qinling_endpoint) access_policy = dispatcher.DefaultRPCAccessPolicy self.server = messaging.get_rpc_server( transport, target, [endpoint], executor='threading', access_policy=access_policy, serializer=rpc.ContextSerializer( messaging.serializer.JsonPayloadSerializer())) LOG.info('Starting function mapping periodic task...') periodics.start_function_mapping_handler(endpoint) LOG.info('Starting engine...') self.server.start()