IKholopov commented on code in PR #27155:
URL: https://github.com/apache/airflow/pull/27155#discussion_r1017040333
##########
tests/jobs/test_local_task_job.py:
##########
@@ -374,6 +374,29 @@ def test_localtaskjob_double_trigger(self):
session.close()
+ @patch.object(StandardTaskRunner, 'return_code')
+ @mock.patch('airflow.jobs.scheduler_job.Stats.incr')
+ def test_raw_task_return_code_metric(self, mock_stats_incr,
mock_return_code, create_dummy_dag):
+
+ _, task = create_dummy_dag('test_localtaskjob_double_trigger')
+ mock_stats_incr.reset_mock()
+
+ ti_run = TaskInstance(task=task, execution_date=DEFAULT_DATE)
+ ti_run.refresh_from_db()
+ job1 = LocalTaskJob(task_instance=ti_run,
executor=SequentialExecutor())
+
+ mock_return_code.side_effect = [None, -9, None]
+
+ with timeout(10):
+ job1.run()
+
+ mock_stats_incr.assert_has_calls(
+ [
+
mock.call('ti.raw_task_return_code.test_localtaskjob_double_trigger.op1.-9'),
+ ],
+ any_order=True,
Review Comment:
Removed any_order. Since return_code is mocked, it it better not to
introduce multiple task instances.
--
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]