namratachaudhary commented on code in PR #68213:
URL: https://github.com/apache/airflow/pull/68213#discussion_r3381355928
##########
task-sdk/tests/task_sdk/bases/test_resumablemixin.py:
##########
@@ -200,6 +205,100 @@ class CustomKeyOp(ConcreteResumableOperator):
assert task_state.get("my_custom_key") == "job-001"
+class TestMetrics:
+ _PATCH = "airflow.sdk._shared.observability.metrics.stats.incr"
+ _TAG = {"operator": "ConcreteResumableOperator"}
+
+ def test_fresh_submit_fires_only_fresh_submit_counter(self):
+ op = ConcreteResumableOperator(task_id="test_task")
+ mock_incr = MagicMock()
+ with patch(self._PATCH, mock_incr):
+ op.execute_resumable(make_context(FakeTaskState()))
+ called_names = [call.args[0] for call in mock_incr.call_args_list]
+ assert called_names == ["resumable_job.fresh_submit"]
+ mock_incr.assert_called_once_with("resumable_job.fresh_submit",
tags=self._TAG)
+
+ def test_reconnect_fires_attempt_and_success(self):
+ op = ConcreteResumableOperator(task_id="test_task")
+ op._status_map["job-001"] = "RUNNING"
+ mock_incr = MagicMock()
+ with patch(self._PATCH, mock_incr):
+ op.execute_resumable(make_context(FakeTaskState({"test_job_id":
"job-001"})))
+ called_names = [call.args[0] for call in mock_incr.call_args_list]
+ assert "resumable_job.reconnect_attempt" in called_names
+ assert "resumable_job.reconnect_success" in called_names
+ assert "resumable_job.fresh_submit" not in called_names
+
+ @pytest.mark.parametrize("status", ["SUCCEEDED", "FAILED"])
+ def test_reconnect_attempt_without_success_when_job_not_active(self,
status):
Review Comment:
nit : you check that reconnect_success does not fire when a job is FAILED &&
assert that fresh_submit does fire in that same case.
--
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]