Skip to content

Commit

Permalink
Make test_handle_stuck_queued_tasks_multiple_attempts less flaky (apa…
Browse files Browse the repository at this point in the history
…che#45817)

This test - very rarely - fails in CI because it did not order
the log events. Ordering by id should fix the flakiness.
  • Loading branch information
potiuk authored Jan 20, 2025
1 parent acb1bc2 commit 40446af
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/jobs/test_scheduler_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -2190,7 +2190,9 @@ def _queue_tasks(tis):
assert [x.queued_dttm for x in tis] == [None, None]

_queue_tasks(tis=tis)
log_events = [x.event for x in session.scalars(select(Log).where(Log.run_id == run_id)).all()]
log_events = [
x.event for x in session.scalars(select(Log).where(Log.run_id == run_id).order_by(Log.id)).all()
]
assert log_events == [
"stuck in queued reschedule",
"stuck in queued reschedule",
Expand All @@ -2199,7 +2201,9 @@ def _queue_tasks(tis):
with _loader_mock(mock_executors):
scheduler._handle_tasks_stuck_in_queued()

log_events = [x.event for x in session.scalars(select(Log).where(Log.run_id == run_id)).all()]
log_events = [
x.event for x in session.scalars(select(Log).where(Log.run_id == run_id).order_by(Log.id)).all()
]
assert log_events == [
"stuck in queued reschedule",
"stuck in queued reschedule",
Expand All @@ -2213,7 +2217,9 @@ def _queue_tasks(tis):

with _loader_mock(mock_executors):
scheduler._handle_tasks_stuck_in_queued()
log_events = [x.event for x in session.scalars(select(Log).where(Log.run_id == run_id)).all()]
log_events = [
x.event for x in session.scalars(select(Log).where(Log.run_id == run_id).order_by(Log.id)).all()
]
assert log_events == [
"stuck in queued reschedule",
"stuck in queued reschedule",
Expand Down

0 comments on commit 40446af

Please sign in to comment.