lucafuji commented on a change in pull request #6870: [AIRFLOW-578] Fix check
return code
URL: https://github.com/apache/airflow/pull/6870#discussion_r366082819
##########
File path: tests/jobs/test_local_task_job.py
##########
@@ -81,6 +83,46 @@ def test_localtaskjob_essential_attr(self):
check_result_2 = [getattr(job1, attr) is not None for attr in
essential_attr]
self.assertTrue(all(check_result_2))
+ def test_localtaskjob_invalid_return_code(self):
+ dag = DAG(
+ 'test_localtaskjob_invalid_return_code',
+ start_date=DEFAULT_DATE,
+ default_args={'owner': 'airflow'})
+
+ task = BashOperator(
+ task_id='test_bash',
+ bash_command='exit 1',
+ dag=dag,
+ owner='airflow')
+ session = settings.Session()
+
+ dag.clear()
+ dr = dag.create_dagrun(run_id="test",
+ state=State.SUCCESS,
+ execution_date=DEFAULT_DATE,
+ start_date=DEFAULT_DATE,
+ session=session)
+ ti = dr.get_task_instance(task_id=task.task_id, session=session)
+ ti.state = State.RUNNING
+ ti.hostname = get_hostname()
+ ti.pid = 1
+ session.commit()
+
+ ti_run = TI(task=task, execution_date=DEFAULT_DATE)
+ job1 = LocalTaskJob(task_instance=ti_run,
+ ignore_ti_state=True,
+ executor=SequentialExecutor())
+ with patch.object(BaseTaskRunner, 'start',
+ return_value=None) as mock_method:
+ job1.run()
+ mock_method.assert_not_called()
Review comment:
sorry, it's not..Just rewrite the tests to run the new code. Previously I
wrote in this way is because it's the local_task_job which calling the actual
task's execution but now it's the task_runner.
Thanks for catching this! Nice finding.
----------------------------------------------------------------
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