Skip to content

Commit a77fe0c

Browse files
dima-asanakaxil
authored andcommitted
[AIRFLOW-1837] Respect task start_date when different from dag's (#4010)
1 parent 562f6df commit a77fe0c

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

tests/core.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2078,14 +2078,14 @@ def test_dag_view_task_with_python_operator_using_partial(self):
20782078
response = self.app.get(
20792079
'/admin/airflow/task?'
20802080
'task_id=test_dagrun_functool_partial&dag_id=test_task_view_type_check&'
2081-
'execution_date={}'.format(DEFAULT_DATE_DS))
2081+
'execution_date={}'.format(EXAMPLE_DAG_DEFAULT_DATE))
20822082
self.assertIn("A function with two args", response.data.decode('utf-8'))
20832083

20842084
def test_dag_view_task_with_python_operator_using_instance(self):
20852085
response = self.app.get(
20862086
'/admin/airflow/task?'
20872087
'task_id=test_dagrun_instance&dag_id=test_task_view_type_check&'
2088-
'execution_date={}'.format(DEFAULT_DATE_DS))
2088+
'execution_date={}'.format(EXAMPLE_DAG_DEFAULT_DATE))
20892089
self.assertIn("A __call__ method", response.data.decode('utf-8'))
20902090

20912091
def tearDown(self):

tests/jobs.py

+21
Original file line numberDiff line numberDiff line change
@@ -2273,6 +2273,27 @@ def test_scheduler_task_start_date(self):
22732273
for t in ti2s:
22742274
self.assertEqual(t.state, State.SUCCESS)
22752275

2276+
def test_scheduler_task_start_date(self):
2277+
"""
2278+
Test that the scheduler respects task start dates that are different
2279+
from DAG start dates
2280+
"""
2281+
dag_id = 'test_task_start_date_scheduling'
2282+
dag = self.dagbag.get_dag(dag_id)
2283+
dag.clear()
2284+
scheduler = SchedulerJob(dag_id,
2285+
num_runs=2)
2286+
scheduler.run()
2287+
2288+
session = settings.Session()
2289+
tiq = session.query(TI).filter(TI.dag_id == dag_id)
2290+
ti1s = tiq.filter(TI.task_id == 'dummy1').all()
2291+
ti2s = tiq.filter(TI.task_id == 'dummy2').all()
2292+
self.assertEqual(len(ti1s), 0)
2293+
self.assertEqual(len(ti2s), 2)
2294+
for t in ti2s:
2295+
self.assertEqual(t.state, State.SUCCESS)
2296+
22762297
def test_scheduler_multiprocessing(self):
22772298
"""
22782299
Test that the scheduler can successfully queue multiple dags in parallel

tests/www_rbac/test_views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ def test_paused(self):
409409
def test_failed(self):
410410
url = ('failed?task_id=run_this_last&dag_id=example_bash_operator&'
411411
'execution_date={}&upstream=false&downstream=false&future=false&past=false'
412-
.format(self.percent_encode(self.default_date)))
412+
.format(self.percent_encode(self.EXAMPLE_DAG_DEFAULT_DATE)))
413413
resp = self.client.get(url)
414414
self.check_content_in_response('Wait a minute', resp)
415415

0 commit comments

Comments
 (0)