ashb commented on a change in pull request #6732: fixes scheduler queue bug
URL: https://github.com/apache/airflow/pull/6732#discussion_r354242038
##########
File path: tests/jobs/test_scheduler_job.py
##########
@@ -188,6 +188,55 @@ def test_process_executor_events(self, mock_stats_incr):
mock_stats_incr.assert_called_once_with('scheduler.tasks.killed_externally')
+ def test_scheduler_executor_overflow(self):
+ """
+ Test that tasks that tasks that are set back to scheduled after
+ """
+ executor = TestExecutor(do_update=True, parallelism=3)
+ session = settings.Session()
+ dag = self.create_test_dag()
+ task = DummyOperator(
+ task_id='dummy',
+ dag=dag,
+ owner='airflow')
+ from datetime import timedelta
+ tis = []
+ for i in range(1,10):
+ ti = TI(task, DEFAULT_DATE + timedelta(days=i))
+ ti.state = State.SCHEDULED
+ tis.append(ti)
+ session.merge(ti)
+ session.commit()
+
+ simple_dag_bag = self._make_simple_dag_bag([dag])
+ scheduler = SchedulerJob(num_runs=1,
+ executor=executor,
+ subdir=os.path.join(settings.DAGS_FOLDER,
+ "no_dags.py"))
+ mock.patch.object(scheduler,
'_change_state_for_tis_without_dagrun').start()
+ scheduler._process_dags(simple_dag_bag)
+ [ti.refresh_from_db() for ti in tis]
+ self.assertEqual(len(executor.queued_tasks), 0)
+ successful_tasks = [ti for ti in tis if ti.state == State.SUCCESS]
+ scheduled_tasks = [ti for ti in tis if ti.state == State.SCHEDULED]
+ self.assertEqual(3, len(successful_tasks))
+ self.assertEqual(6, len(scheduled_tasks))
+
+ def create_test_dag(self):
Review comment:
Could you use this in the other places in the file too? (Will probably need
to make it look like this:
```suggestion
def create_test_dag(self, start_date=DEFAULT_DATE, **kwargs):
dag = DAG(start_date=start_date, **kwargs)
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services