Skip to content

Commit

Permalink
Fix flaky backfill test (apache#28087)
Browse files Browse the repository at this point in the history
The test falls sometimes when initial setup of the tests causes
recoverable failure - making "first" test contain different error
followed by an expected one.

The fix is to look for the message in all error logs registered

Co-authored-by: Andrey Anshin <Andrey.Anshin@taragol.is>

Co-authored-by: Andrey Anshin <Andrey.Anshin@taragol.is>
  • Loading branch information
potiuk and Taragolis authored Dec 4, 2022
1 parent 8f98bfe commit 4746882
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/jobs/test_backfill_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,10 @@ def test_backfill_skip_active_scheduled_dagrun(self, dag_maker, caplog):
start_date=DEFAULT_DATE,
end_date=DEFAULT_DATE + datetime.timedelta(days=2),
)
job.run()
error_log_records = [record for record in caplog.records if record.levelname == "ERROR"]
assert "Backfill cannot be created for DagRun" in error_log_records[0].msg
with caplog.at_level(logging.ERROR, logger="airflow.jobs.backfill_job.BackfillJob"):
caplog.clear()
job.run()
assert "Backfill cannot be created for DagRun" in caplog.messages[0]

ti = TI(
task=dag.get_task("test_backfill_skip_active_scheduled_dagrun-1"), execution_date=DEFAULT_DATE
Expand Down

0 comments on commit 4746882

Please sign in to comment.