예제 #1
0
    def _test_reset_processing_rows(self,
                                    session,
                                    last_retried,
                                    max_timedelta,
                                    quantity,
                                    dry_reset=False):
        db.create_pending_row(self.db_session, *self.UPDATE_ROW)
        expected_state = odl_const.PROCESSING

        row = db.get_all_db_rows(self.db_session)[-1]
        row.state = expected_state
        row.last_retried = row.last_retried - timedelta(seconds=last_retried)
        self._update_row(row)

        if not dry_reset:
            expected_state = odl_const.PENDING
            reset = db.reset_processing_rows(self.db_session, max_timedelta)
            self.assertIsInstance(reset, int)
            self.assertEqual(reset, quantity)

        rows = db.get_all_db_rows_by_state(self.db_session, expected_state)

        self.assertEqual(len(rows), quantity)
        for row in rows:
            self.assertEqual(row.state, expected_state)
예제 #2
0
def cleanup_processing_rows(context):
    with db_api.autonested_transaction(context.session):
        row_count = db.reset_processing_rows(
            context.session, cfg.CONF.ml2_odl.processing_timeout)
    if row_count:
        LOG.info("Reset %(num)s orphaned rows back to pending",
                 {"num": row_count})
예제 #3
0
    def _test_reset_processing_rows(self, last_retried, max_timedelta,
                                    quantity, dry_reset=False):
        db.create_pending_row(self.db_context, *self.UPDATE_ROW)
        expected_state = odl_const.PROCESSING

        row = db.get_all_db_rows(self.db_context)[-1]
        row.state = expected_state
        row.last_retried = row.last_retried - timedelta(seconds=last_retried)
        self._update_row(row)

        if not dry_reset:
            expected_state = odl_const.PENDING
            reset = db.reset_processing_rows(self.db_context, max_timedelta)
            self.assertIsInstance(reset, int)
            self.assertEqual(reset, quantity)

        rows = db.get_all_db_rows_by_state(self.db_context, expected_state)

        self.assertEqual(len(rows), quantity)
        for row in rows:
            self.assertEqual(row.state, expected_state)
예제 #4
0
def cleanup_processing_rows(context):
    row_count = db.reset_processing_rows(
        context, cfg.CONF.ml2_odl.processing_timeout)
    if row_count:
        LOG.info("Reset %(num)s orphaned rows back to pending",
                 {"num": row_count})
예제 #5
0
 def cleanup_processing_rows(self, session):
     row_count = db.reset_processing_rows(session, self._processing_timeout)
     if row_count:
         LOG.info(_LI("Reset %(num)s orphaned rows back to pending"),
                  {"num": row_count})