def test_registry_claim_with_dead_engine(self, mock_check): db_api.service_create('SERVICE_ID_DEAD') self._create_registry( cluster_id='CLUSTER_1', check_type='NODE_STATUS_POLLING', interval=60, params={}, engine_id='SERVICE_ID') self._create_registry( cluster_id='CLUSTER_1', check_type='NODE_STATUS_POLLING', interval=60, params={}, engine_id='SERVICE_ID_DEAD') mock_check.side_effect = [False, True] registries = db_api.registry_claim(self.ctx, engine_id='ENGINE_ID') self.assertEqual(1, len(registries)) self.assertEqual('SERVICE_ID_DEAD', registries[0].engine_id)
def _create_service(self, service_id=None, **kwargs): service_id = service_id or 'f9aff81e-bc1f-4119-941d-ad1ea7f31d19' values = { 'host': 'host1.devstack.org', 'binary': 'senlin-engine', 'topic': 'engine', } values.update(kwargs) return db_api.service_create(service_id, **values)
def _create_service(self, **kwargs): values = { 'service_id': 'f9aff81e-bc1f-4119-941d-ad1ea7f31d19', 'host': 'host1.devstack.org', 'binary': 'senlin-engine', 'topic': 'engine', } values.update(kwargs) return db_api.service_create(self.ctx, **values)
def setUp(self): super(DBAPIRegistryTest, self).setUp() self.ctx = utils.dummy_context() db_api.service_create(self.ctx, 'SERVICE_ID')