You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/11/08 19:36:00 UTC
[GitHub] [airflow] IKholopov commented on a diff in pull request #27155: Metric for raw task return codes
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org