dominikhei commented on code in PR #52885:
URL: https://github.com/apache/airflow/pull/52885#discussion_r2200604863
##########
providers/cncf/kubernetes/tests/unit/cncf/kubernetes/operators/test_job.py:
##########
@@ -484,15 +484,49 @@ def test_task_id_as_name_dag_id_is_ignored(self):
job = k.build_job_request_obj({})
assert re.match(r"job-a-very-reasonable-task-name-[a-z0-9-]+",
job.metadata.name) is not None
+ @patch(JOB_OPERATORS_PATH.format("KubernetesJobOperator.find_pod"))
+ def test_get_or_create_pod(self, mock_find_pod):
+ found_pod = mock.MagicMock()
+ mock_find_pod.side_effect = [None,found_pod]
+ mock_ti = mock.MagicMock()
+ context = dict(ti=mock_ti)
+
+ op = KubernetesJobOperator(
+ task_id="test_task_id"
+ )
+
+ assert op.get_or_create_pod({},context) == found_pod
+
+
@pytest.mark.non_db_test_override
-
@patch(JOB_OPERATORS_PATH.format("KubernetesJobOperator.get_or_create_pod"))
+ @patch(JOB_OPERATORS_PATH.format("KubernetesJobOperator.find_pod"))
+
@patch(JOB_OPERATORS_PATH.format("KubernetesJobOperator.build_job_request_obj"))
+ @patch(JOB_OPERATORS_PATH.format("KubernetesJobOperator.create_job"))
+ @patch(HOOK_CLASS)
+ def test_pod_creation_timeout(self, mock_hook, mock_create_job,
mock_build_job_request_obj, mock_find_pod):
Review Comment:
If I am not wrong this tests waits the whole 10s you used as a timeout.
Could you mock the behavior, such that the test does not run for 10s or set it
to 0?
--
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]