You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2022/12/04 10:42:03 UTC

[airflow] branch main updated: Fix flaky backfill test (#28087)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 4746882e7b Fix flaky backfill test (#28087)
4746882e7b is described below

commit 4746882e7b27c996047cff29bc831e0fa3c9b0f2
Author: Jarek Potiuk <ja...@potiuk.com>
AuthorDate: Sun Dec 4 11:41:56 2022 +0100

    Fix flaky backfill test (#28087)
    
    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 <An...@taragol.is>
    
    Co-authored-by: Andrey Anshin <An...@taragol.is>
---
 tests/jobs/test_backfill_job.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/jobs/test_backfill_job.py b/tests/jobs/test_backfill_job.py
index b940edba16..b844a08c8e 100644
--- a/tests/jobs/test_backfill_job.py
+++ b/tests/jobs/test_backfill_job.py
@@ -636,9 +636,10 @@ class TestBackfillJob:
             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