def setUp(self): super(PolicyTypeTest, self).setUp() self.ctx = utils.dummy_context(project='policy_type_test_project') self.eng = service.EngineService('host-a', 'topic-a') self.eng.init_tgm() environment.global_env().register_policy('TestPolicy', fakes.TestPolicy)
def test_start_action_no_action_ready(self, mock_acquire_action): mock_acquire_action.return_value = None svc = service.EngineService('HOST', 'TOPIC') svc.tg = self.mock_tg res = svc.start_action('4567') self.assertIsNone(res)
def setUp(self): super(TriggerTest, self).setUp() self.ctx = utils.dummy_context(project='trigger_test_project') self.eng = service.EngineService('host-a', 'topic-a') self.eng.init_tgm() environment.global_env().register_trigger('TestTrigger', fakes.TestTrigger)
def setUp(self): super(TestDispatcher, self).setUp() self.context = utils.dummy_context() self.thm = scheduler.ThreadGroupManager() self.svc = service.EngineService('HOST', 'TOPIC') self.svc.engine_id = '1234'
def setUp(self): super(EngineStatusTest, self).setUp() self.eng = service.EngineService('host-a', 'topic-a') self.gen_id = self.patchobject(uuid, 'uuid4', return_value='1234') self.fake_rpc_server = mock.Mock() self.get_rpc = self.patchobject(rpc_messaging, 'get_rpc_server', return_value=self.fake_rpc_server)
def test_start_action_failed_locking_action(self, mock_acquire_action, mock_acquire_action_1st): mock_acquire_action.return_value = None mock_acquire_action_1st.return_value = None svc = service.EngineService('HOST', 'TOPIC') svc.tg = self.mock_tg res = svc.start_action(self.context, '0123') self.assertIsNone(res)
def test_resume_action(self): mock_action = mock.Mock() mock_load = self.patchobject(actionm.Action, 'load', return_value=mock_action) svc = service.EngineService('HOST', 'TOPIC') svc.tg = self.mock_tg svc.resume_action(self.context, 'action0123') mock_load.assert_called_once_with(svc.db_session, 'action0123', project_safe=False) mock_action.signal.assert_called_once_with(mock_action.SIG_RESUME)
def setUp(self): super(ActionTest, self).setUp() self.ctx = utils.dummy_context(project='action_test_project') self.eng = service.EngineService('host-a', 'topic-a') self.eng.init_tgm() self.target = mock.Mock() self.target.id = 'Node1' self.target.user = '******' self.target.project = 'PROJ1' self.target.domain = 'DOM1'
def setUp(self): super(TestEngine, self).setUp() self.context = utils.dummy_context() self.service_id = '4db0a14c-dc10-4131-8ed6-7573987ce9b0' self.tg = mock.Mock() self.topic = consts.ENGINE_TOPIC self.tg = mock.Mock() self.svc = service.EngineService('HOST', self.topic) self.svc.service_id = self.service_id self.svc.tg = self.tg
def setUp(self): super(EngineStatusTest, self).setUp() self.eng = service.EngineService('host-a', 'topic-a') fake_id = '4db0a14c-dc10-4131-8ed6-7573987ce9b0' self.gen_id = self.patchobject(uuidutils, 'generate_uuid', return_value=fake_id) self.fake_rpc_server = mock.Mock() self.get_rpc = self.patchobject(rpc_messaging, 'get_rpc_server', return_value=self.fake_rpc_server)
def test_start_action(self, mock_action_acquire, mock_action_acquire_1st): action = mock.Mock() action.id = '0123' mock_action_acquire.return_value = action mock_action_acquire_1st.return_value = None svc = service.EngineService('HOST', 'TOPIC') svc.tg = self.mock_tg svc.start_action('4567', '0123') self.mock_tg.add_thread.assert_called_once_with( svc._start_with_trace, oslo_context.get_current(), None, actionm.ActionProc, svc.db_session, '0123')
def test_start_action_no_action_id(self, mock_acquire_action): mock_action = mock.Mock() mock_action.id = '0123' mock_action.action = 'CLUSTER_CREATE' mock_acquire_action.side_effect = [mock_action, None] svc = service.EngineService('HOST', 'TOPIC') svc.tg = self.mock_tg svc.start_action('4567') self.mock_tg.add_thread.assert_called_once_with( svc._start_with_trace, oslo_context.get_current(), None, actionm.ActionProc, svc.db_session, '0123')
def setUp(self): super(PolicyTest, self).setUp() self.ctx = utils.dummy_context(project='policy_test_project') self.eng = service.EngineService('host-a', 'topic-a') self.eng.init_tgm() environment.global_env().register_policy('TestPolicy', fakes.TestPolicy) self.spec = { 'type': 'TestPolicy', 'version': '1.0', 'properties': { 'KEY1': 'value1', 'KEY2': 2, } }
def main(): logging.register_options(cfg.CONF) cfg.CONF(project='senlin', prog='senlin-engine') logging.setup(cfg.CONF, 'senlin-engine') logging.set_defaults() messaging.setup() from senlin.engine import service as engine srv = engine.EngineService(cfg.CONF.host, consts.ENGINE_TOPIC) launcher = service.launch(cfg.CONF, srv, workers=cfg.CONF.num_engine_workers) # the following periodic tasks are intended serve as HA checking # srv.create_periodic_tasks() launcher.wait()
def main(): config.parse_args(sys.argv, 'senlin-engine') logging.setup(CONF, 'senlin-engine') logging.set_defaults() gmr.TextGuruMeditation.setup_autorun(version) objects.register_all() messaging.setup() from senlin.engine import service as engine profiler.setup('senlin-engine', CONF.host) srv = engine.EngineService(CONF.host, consts.ENGINE_TOPIC) launcher = service.launch(CONF, srv, workers=CONF.engine.workers, restart_method='mutate') launcher.wait()
def main(): logging.register_options(cfg.CONF) cfg.CONF(project='senlin', prog='senlin-engine') logging.setup(cfg.CONF, 'senlin-engine') logging.set_defaults() gmr.TextGuruMeditation.setup_autorun(version) objects.register_all() messaging.setup() from senlin.engine import service as engine profiler.setup('senlin-engine', cfg.CONF.host) srv = engine.EngineService(cfg.CONF.host, consts.ENGINE_TOPIC) launcher = service.launch(cfg.CONF, srv, workers=cfg.CONF.engine.workers, restart_method='mutate') launcher.wait()
def main(): logging.register_options(cfg.CONF) cfg.CONF(project='senlin', prog='senlin-engine') logging.setup(cfg.CONF, 'senlin-engine') logging.set_defaults() gmr.TextGuruMeditation.setup_autorun(version) objects.register_all() messaging.setup() from senlin.engine import service as engine profiler.setup('senlin-engine', cfg.CONF.host) srv = engine.EngineService(cfg.CONF.host, consts.ENGINE_TOPIC) launcher = service.launch(cfg.CONF, srv, workers=cfg.CONF.num_engine_workers, restart_method='mutate') # the following periodic tasks are intended serve as HA checking # srv.create_periodic_tasks() launcher.wait()
def setUp(self): super(ClusterPolicyTest, self).setUp() self.ctx = utils.dummy_context(project='cluster_policy_test_project') self.eng = service.EngineService('host-a', 'topic-a') self.eng.init_tgm() self.eng.dispatcher = mock.Mock() self.patchobject(dispatcher, 'notify') env = environment.global_env() env.register_profile('TestProfile', fakes.TestProfile) env.register_policy('TestPolicy', fakes.TestPolicy) profile_spec = { 'type': 'TestProfile', 'version': '1.0', 'properties': { 'INT': 10, 'STR': 'string' }, } self.profile = self.eng.profile_create(self.ctx, 'p-test', profile_spec, permission='1111') policy_spec = { 'type': 'TestPolicy', 'version': '1.0', 'properties': { 'KEY2': 5 }, } self.policy = self.eng.policy_create(self.ctx, 'policy_1', policy_spec, cooldown=6, level=5) self.cluster = self.eng.cluster_create(self.ctx, 'c-1', 0, self.profile['id'])
def test_start_action_batch_control(self, mock_acquire_action, mock_sleep): mock_action1 = mock.Mock() mock_action1.id = 'ID1' mock_action1.action = 'NODE_CREATE' mock_action2 = mock.Mock() mock_action2.id = 'ID2' mock_action2.action = 'CLUSTER_CREATE' mock_action3 = mock.Mock() mock_action3.id = 'ID3' mock_action3.action = 'NODE_DELETE' mock_acquire_action.side_effect = [mock_action1, mock_action2, mock_action3, None] cfg.CONF.set_override('max_actions_per_batch', 1) cfg.CONF.set_override('batch_interval', 2) svc = service.EngineService('HOST', 'TOPIC') svc.tg = self.mock_tg svc.start_action('4567') mock_sleep.assert_called_once_with(2) self.assertEqual(self.mock_tg.add_thread.call_count, 3)
def setUp(self): super(WebhookTest, self).setUp() self.ctx = utils.dummy_context(project='webhook_test_project') self.eng = service.EngineService('host-a', 'topic-a') self.eng.init_tgm() self.eng.dispatcher = mock.Mock() env = environment.global_env() env.register_profile('TestProfile', fakes.TestProfile) spec = { 'type': 'TestProfile', 'version': '1.0', 'properties': { 'INT': 10, 'STR': 'string' } } self.profile = self.eng.profile_create(self.ctx, 'p-test', spec, permission='1111')
def test_start_action_multiple_batches(self, mock_acquire_action, mock_sleep): action_types = ['NODE_CREATE', 'NODE_DELETE'] actions = [] for index in range(10): mock_action = mock.Mock() mock_action.id = 'ID%d' % (index + 1) mock_action.action = action_types[index % 2] actions.append(mock_action) # Add a None at the end to end the process. actions.insert(len(actions), None) mock_acquire_action.side_effect = actions cfg.CONF.set_override('max_actions_per_batch', 3) cfg.CONF.set_override('batch_interval', 5) svc = service.EngineService('HOST', 'TOPIC') svc.tg = self.mock_tg svc.start_action(self.context) self.assertEqual(mock_sleep.call_count, 3) self.assertEqual(self.mock_tg.add_thread.call_count, 10)
def test_service_thread_numbers_override_legacy(self, mock_service_init): cfg.CONF.set_override('scheduler_thread_pool_size', 101) service.EngineService('HOST', self.topic) mock_service_init.assert_called_once_with(101)
def test_service_thread_numbers_override(self, mock_service_init): cfg.CONF.set_override('threads', 100, group='engine') service.EngineService('HOST', self.topic) mock_service_init.assert_called_once_with(100)
def test_service_thread_numbers(self, mock_service_init): service.EngineService('HOST', self.topic) mock_service_init.assert_called_once_with(1000)
def setUp(self): super(PolicyTypeTest, self).setUp() self.ctx = utils.dummy_context(project='policy_type_test_project') self.eng = service.EngineService('host-a', 'topic-a')
def setUp(self): super(ClusterPolicyTest, self).setUp() self.ctx = utils.dummy_context(project='cluster_policy_test_project') self.eng = service.EngineService('host-a', 'topic-a') self.eng.init_tgm()
def setUp(self): super(CredentialTest, self).setUp() self.ctx = utils.dummy_context(user_id='fake_user_id', project='fake_project_id') self.eng = service.EngineService('host-a', 'topic-a')
def setUp(self): super(ActionTest, self).setUp() self.ctx = utils.dummy_context(project='action_test_project') self.eng = service.EngineService('host-a', 'topic-a') self.eng.init_tgm()
def setUp(self): super(WebhookTest, self).setUp() self.ctx = utils.dummy_context(project='webhook_test_project') self.eng = service.EngineService('host-a', 'topic-a')
def setUp(self): super(ClusterOpTest, self).setUp() self.ctx = utils.dummy_context(project='cluster_op_test_project') self.eng = service.EngineService('host-a', 'topic-a')