From 6c20124cbbf0aaaba20672afef7ee6fb22b8fbe0 Mon Sep 17 00:00:00 2001 From: Tanel Kiis Date: Tue, 7 Jun 2022 07:45:53 +0300 Subject: [PATCH] Test process executor events with different try_number --- tests/jobs/test_scheduler_job.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/jobs/test_scheduler_job.py b/tests/jobs/test_scheduler_job.py index 830ab2b826159..db6df7dfeb911 100644 --- a/tests/jobs/test_scheduler_job.py +++ b/tests/jobs/test_scheduler_job.py @@ -401,6 +401,20 @@ def test_process_executor_events_ti_requeued(self, mock_stats_incr, mock_task_ca self.scheduler_job.id = 1 self.scheduler_job.processor_agent = mock.MagicMock() + # ti is queued with another try number - do not fail it + ti1.state = State.QUEUED + ti1.queued_by_job_id = 1 + ti1.try_number = 2 + session.merge(ti1) + session.commit() + + executor.event_buffer[ti1.key.with_try_number(1)] = State.SUCCESS, None + + self.scheduler_job._process_executor_events(session=session) + ti1.refresh_from_db(session=session) + assert ti1.state == State.QUEUED + self.scheduler_job.executor.callback_sink.send.assert_not_called() + # ti is queued by another scheduler - do not fail it ti1.state = State.QUEUED ti1.queued_by_job_id = 2