def test_scheduler_multi_instance(self, method): scheds = [scheduler.start(), scheduler.start()] def stop_schedulers(): [scheduler.stop_scheduler(s, True) for s in scheds] self.addCleanup(stop_schedulers) method_args = {'name': 'task', 'id': '321'} scheduler.schedule_call(None, TARGET_METHOD_PATH, DELAY, **method_args) time_filter = datetime.datetime.now() + datetime.timedelta(seconds=2) calls = db_api.get_delayed_calls_to_start(time_filter) self._assert_single_item(calls, target_method_name=TARGET_METHOD_PATH) eventlet.sleep(WAIT) method.assert_called_once_with(name='task', id='321') time_filter = datetime.datetime.now() + datetime.timedelta(seconds=1) calls = db_api.get_delayed_calls_to_start(time_filter) self.assertEqual(0, len(calls))
def test_scheduler_multi_instance(self, method): scheds = [scheduler.start(), scheduler.start()] def stop_schedulers(): [scheduler.stop_scheduler(s, True) for s in scheds] self.addCleanup(stop_schedulers) method_args = {'name': 'task', 'id': '321'} scheduler.schedule_call( None, TARGET_METHOD_PATH, DELAY, **method_args ) time_filter = datetime.datetime.now() + datetime.timedelta(seconds=2) calls = db_api.get_delayed_calls_to_start(time_filter) self._assert_single_item(calls, target_method_name=TARGET_METHOD_PATH) eventlet.sleep(WAIT) method.assert_called_once_with(name='task', id='321') time_filter = datetime.datetime.now() + datetime.timedelta(seconds=1) calls = db_api.get_delayed_calls_to_start(time_filter) self.assertEqual(0, len(calls))
def start(self): super(EngineServer, self).start() db_api.setup_db() self._scheduler = scheduler.start() self._expiration_policy_tg = expiration_policy.setup() action_execution_checker.start() if self._setup_profiler: profiler_utils.setup('mistral-engine', cfg.CONF.engine.host) # Initialize and start RPC server. self._rpc_server = rpc.get_rpc_server_driver()(cfg.CONF.engine) self._rpc_server.register_endpoint(self) self._rpc_server.run(executor=cfg.CONF.oslo_rpc_executor) self._notify_started('Engine server started.')
def start(self): super(EngineServer, self).start() db_api.setup_db() self._scheduler = scheduler.start() self._expiration_policy_tg = expiration_policy.setup() if self._setup_profiler: profiler_utils.setup('mistral-engine', cfg.CONF.engine.host) # Initialize and start RPC server. self._rpc_server = rpc.get_rpc_server_driver()(cfg.CONF.engine) self._rpc_server.register_endpoint(self) # Note(ddeja): Engine needs to be run in default (blocking) mode # since using another mode may leads to deadlock. # See https://review.openstack.org/#/c/356343 for more info. self._rpc_server.run(executor='blocking') self._notify_started('Engine server started.')
def setUp(self): super(SchedulerServiceTest, self).setUp() sched = scheduler.start() self.addCleanup(scheduler.stop_scheduler, sched, True)