Miretpl commented on code in PR #69300:
URL: https://github.com/apache/airflow/pull/69300#discussion_r3605836683


##########
providers/cncf/kubernetes/tests/unit/cncf/kubernetes/executors/test_kubernetes_executor.py:
##########
@@ -2323,32 +2323,77 @@ def test_kube_config_get_namespace_list(
 
         assert executor.kube_config.multi_namespace_mode_namespace_list == 
expected_value_in_kube_config
 
-    @pytest.mark.db_test
     
@mock.patch("airflow.providers.cncf.kubernetes.kube_client.get_kube_client")
-    def test_get_task_log(self, mock_get_kube_client, 
create_task_instance_of_operator):
+    def test_get_streaming_task_log(self, mock_get_kube_client):
         """fetch task log from pod"""
         mock_kube_client = mock_get_kube_client.return_value
 
         mock_kube_client.read_namespaced_pod_log.return_value = [b"a_", b"b_", 
b"c_"]
         mock_pod = mock.Mock()
         mock_pod.metadata.name = "x"
         mock_kube_client.list_namespaced_pod.return_value.items = [mock_pod]
-        ti = create_task_instance_of_operator(EmptyOperator, 
dag_id="test_k8s_log_dag", task_id="test_task")
+        ti = mock.MagicMock(
+            dag_id="test_k8s_log_dag",
+            task_id="test_task",
+            map_index=-1,
+            run_id="test_run",
+            queued_by_job_id=None,
+            hostname="",
+            executor_config={},
+        )
 
         executor = KubernetesExecutor()
-        messages, logs = executor.get_task_log(ti=ti, try_number=1)
+        messages, log_streams = executor.get_streaming_task_log(ti=ti, 
try_number=1)
 
         mock_kube_client.read_namespaced_pod_log.assert_called_once()
         assert messages == [
             "Attempting to fetch logs from pod  through kube API",
             "Found logs through kube API",
         ]
-        assert logs[0] == "a_\nb_\nc_"
+        assert list(log_streams[0]) == ["a_", "b_", "c_"]
+
+        mock_kube_client.reset_mock()
+        mock_kube_client.read_namespaced_pod_log.side_effect = 
Exception("error_fetching_pod_log")
+
+        messages, log_streams = executor.get_streaming_task_log(ti=ti, 
try_number=1)
+        assert log_streams == []
+        assert messages == [
+            "Attempting to fetch logs from pod  through kube API",

Review Comment:
   ```suggestion
               "Attempting to fetch logs from pod through kube API",
   ```
   The same is in the test case below.



-- 
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]

Reply via email to