uranusjr commented on a change in pull request #20349: URL: https://github.com/apache/airflow/pull/20349#discussion_r783617068
########## File path: tests/jobs/test_scheduler_job.py ########## @@ -645,6 +645,36 @@ def test_find_executable_task_instances_in_default_pool(self, dag_maker): session.rollback() session.close() + def test_executable_task_instances_to_queued_fails_task_for_missing_dag_in_dagbag( + self, dag_maker, session + ): + """Check that task instances of missing DAGs are failed""" + dag_id = 'SchedulerJobTest.test_find_executable_task_instances_not_in_dagbag' + task_id_1 = 'dummy' + task_id_2 = 'dummydummy' + + with dag_maker(dag_id=dag_id, session=session, default_args={"max_active_tis_per_dag": 1}): + DummyOperator(task_id=task_id_1) + DummyOperator(task_id=task_id_2) + + self.scheduler_job = SchedulerJob(subdir=os.devnull) + self.scheduler_job.dagbag = mock.MagicMock() + self.scheduler_job.dagbag.get_dag.return_value = None + + dr = dag_maker.create_dagrun(state=DagRunState.RUNNING) + + tis = dr.task_instances + for ti in tis: + ti.state = State.SCHEDULED + session.merge(ti) + session.flush() + res = self.scheduler_job._executable_task_instances_to_queued(max_tis=32, session=session) + session.flush() + assert 0 == len(res) + tis = dr.get_task_instances(session=session) + for ti in tis: + assert ti.state == State.FAILED Review comment: Or ```python assert [TaskInstanceState.FAILED, TaskInstanceState.FAILED] == [ti.state for ti in tis] ``` -- 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: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org