manipatnam commented on code in PR #72054:
URL: https://github.com/apache/airflow/pull/72054#discussion_r4739538599
##########
airflow-core/tests/unit/jobs/test_scheduler_job.py:
##########
@@ -7650,6 +7650,57 @@ def _running_counts():
assert session.scalar(select(func.count()).select_from(DagRun)) == 6
assert session.scalar(select(func.count()).where(DagRun.dag_id ==
dag1_dag_id)) == 6
+ def
test_backfill_runs_started_when_backfill_completed_despite_paused_flag(self,
dag_maker, session):
+ """
+ A completed backfill leaves is_paused=True (cancel sets both is_paused
and
+ completed_at). Its queued runs -- e.g. one cleared after cancel --
must still
+ be promoted; the stale is_paused flag must not strand them. Regression
test
+ for https://github.com/apache/airflow/issues/69658.
+ """
+ dag1_dag_id = "test_dag1"
+ with dag_maker(
+ dag_id=dag1_dag_id,
+ start_date=DEFAULT_DATE,
+ schedule=timedelta(days=1),
+ max_active_runs=1,
+ catchup=True,
+ ):
+ EmptyOperator(task_id="mytask")
+
+ scheduler_job = Job()
+ self.job_runner = SchedulerJobRunner(job=scheduler_job,
executors=[MockExecutor(do_update=False)])
+
+ from_date = pendulum.parse("2021-01-01")
+ to_date = pendulum.parse("2021-01-06")
+ b = _create_backfill(
+ dag_id=dag1_dag_id,
+ from_date=from_date,
+ to_date=to_date,
+ max_active_runs=3,
+ reverse=False,
+ triggering_user_name="test_user",
+ dag_run_conf={},
+ )
+
+ # Simulate a cancelled backfill: paused and terminal.
Review Comment:
Agreed, the old test built a state cancel never leaves behind. I rewrote it
as `test_cleared_run_of_cancelled_backfill_is_started` in 20bf8b35f6. It
creates a backfill, cancels it through `cancel_backfill`, checks every run is
failed, clears one run, and asserts that only that run starts while the rest
stay failed. Without the scheduler change, the cleared run stays queued and the
test fails.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]