def periodic_clean_up(): # pragma: no cover try: if node_cache.clean_up(): firewall.update_filters() sync_with_ironic() except Exception: LOG.exception(_LE('Periodic clean up of node cache failed'))
def test_timeout(self, time_mock, get_lock_mock): # Add a finished node to confirm we don't try to timeout it time_mock.return_value = self.started_at session = db.get_session() finished_at = self.started_at + datetime.timedelta(seconds=60) with session.begin(): db.Node(uuid=self.uuid + '1', started_at=self.started_at, state=istate.States.waiting, finished_at=finished_at).save(session) CONF.set_override('timeout', 99) time_mock.return_value = (self.started_at + datetime.timedelta(seconds=100)) self.assertEqual([self.uuid], node_cache.clean_up()) res = [(row.state, row.finished_at, row.error) for row in db.model_query(db.Node).all()] self.assertEqual( [(istate.States.error, self.started_at + datetime.timedelta(seconds=100), 'Introspection timeout'), (istate.States.waiting, self.started_at + datetime.timedelta(seconds=60), None)], res) self.assertEqual([], db.model_query(db.Attribute).all()) self.assertEqual([], db.model_query(db.Option).all()) get_lock_mock.assert_called_once_with(self.uuid) get_lock_mock.return_value.acquire.assert_called_once_with()
def periodic_clean_up(): # pragma: no cover try: if node_cache.clean_up(): firewall.update_filters() sync_with_ironic() except Exception: LOG.exception('Periodic clean up of node cache failed')
def periodic_clean_up(): # pragma: no cover try: if node_cache.clean_up(): pxe_filter.driver().sync(ir_utils.get_client()) sync_with_ironic() except Exception: LOG.exception('Periodic clean up of node cache failed')
def test_old_status(self): CONF.set_override('node_status_keep_time', 42) session = db.get_session() with session.begin(): db.model_query(db.Node).update({'finished_at': time.time() - 100}) self.assertEqual([], node_cache.clean_up()) self.assertEqual([], db.model_query(db.Node).all())
def periodic_clean_up(period): # pragma: no cover while True: LOG.debug('Running periodic clean up of node cache') try: if node_cache.clean_up(): firewall.update_filters() sync_with_ironic() except Exception: LOG.exception(_LE('Periodic clean up of node cache failed')) eventlet.greenthread.sleep(period)
def test_old_status(self): CONF.set_override('node_status_keep_time', 42) session = db.get_session() with session.begin(): db.model_query(db.Node).update( {'finished_at': time.time() - 100}) self.assertEqual([], node_cache.clean_up()) self.assertEqual([], db.model_query(db.Node).all())
def periodic_clean_up(): # pragma: no cover try: if node_cache.clean_up(): pxe_filter.driver().sync(ir_utils.get_client()) except Exception: LOG.exception('Periodic clean up of node cache failed') try: sync_with_ironic() except Exception: LOG.exception('Periodic sync of node list with ironic failed')
def test_ok(self, time_mock): time_mock.return_value = 1000 self.assertFalse(node_cache.clean_up()) res = [tuple(row) for row in db.model_query( db.Node.finished_at, db.Node.error).all()] self.assertEqual([(None, None)], res) self.assertEqual(len(self.macs), db.model_query(db.Attribute).count()) self.assertEqual(1, db.model_query(db.Option).count())
def test_no_timeout(self): CONF.set_override('timeout', 0) self.assertFalse(node_cache.clean_up()) res = [ tuple(row) for row in db.model_query(db.Node.finished_at, db.Node.error).all() ] self.assertEqual([(None, None)], res) self.assertEqual(len(self.macs), db.model_query(db.Attribute).count()) self.assertEqual(1, db.model_query(db.Option).count())
def test_no_timeout(self): CONF.set_override('timeout', 0) self.assertFalse(node_cache.clean_up()) res = [tuple(row) for row in db.model_query(db.Node.finished_at, db.Node.error).all()] self.assertEqual([(None, None)], res) self.assertEqual(len(self.macs), db.model_query(db.Attribute).count()) self.assertEqual(1, db.model_query(db.Option).count())
def test_timeout(self, time_mock): # Add a finished node to confirm we don't try to timeout it time_mock.return_value = self.started_at session = db.get_session() with session.begin(): db.Node(uuid=self.uuid + '1', started_at=self.started_at, finished_at=self.started_at + 60).save(session) CONF.set_override('timeout', 99) time_mock.return_value = (self.started_at + 100) self.assertEqual([self.uuid], node_cache.clean_up()) res = [(row.finished_at, row.error) for row in db.model_query(db.Node).all()] self.assertEqual([(self.started_at + 100, 'Introspection timeout'), (self.started_at + 60, None)], res) self.assertEqual([], db.model_query(db.Attribute).all()) self.assertEqual([], db.model_query(db.Option).all())
def periodic_clean_up(): # pragma: no cover if node_cache.clean_up(): pxe_filter.driver().sync(ir_utils.get_client())