def test_get_trigger_in_correct_orders(self): base = datetime(2010, 8, 25) s.create_trigger("test1", "*/5 * * * *", self.wb_name, base) base = datetime(2010, 8, 22) s.create_trigger("test2", "*/5 * * * *", self.wb_name, base) base = datetime(2010, 9, 21) s.create_trigger("test3", "*/5 * * * *", self.wb_name, base) base = datetime.now() + timedelta(0, 50) s.create_trigger("test4", "*/5 * * * *", self.wb_name, base) triggersName = [e['name'] for e in s.get_next_triggers()] self.assertEqual(triggersName, ["test2", "test1", "test3"])
def scheduler_triggers(self, ctx): LOG.debug('Processing next Scheduler triggers.') for trigger in sched.get_next_triggers(): wb = db_api.workbook_get(trigger['workbook_name']) context.set_ctx(trusts.create_context(wb)) try: task = parser.get_workbook( wb['definition']).get_trigger_task_name(trigger['name']) self.engine.start_workflow_execution(wb['name'], task) finally: sched.set_next_execution_time(trigger) context.set_ctx(None)