SameerMesiah97 commented on code in PR #74165:
URL: https://github.com/apache/airflow/pull/74165#discussion_r4174468419


##########
airflow-core/tests/unit/dag_processing/test_manager.py:
##########
@@ -1635,31 +1635,44 @@ def test_cleanup_stale_bundle_versions(self, 
mock_bundle_manager):
         manager.cleanup_stale_bundle_versions()
         
mock_bundle_manager.return_value.remove_stale_bundle_versions.assert_called_once_with()
 
+    def 
test_create_process_stdout_target_logs_to_stdout_with_dag_file_context(self, 
tmp_path):
+        with conf_vars({("logging", "dag_processor_log_target"): "stdout"}):
+            manager = DagFileProcessorManager(max_runs=1, 
processor_timeout=60, base_log_dir=str(tmp_path))
+            dag_file = DagFileInfo(
+                bundle_name="testing", rel_path=Path("my_dag.py"), 
bundle_path=Path("/tmp")
+            )
+            with mock.patch.object(DagFileProcessorProcess, "start") as 
mock_start:
+                manager._create_process(dag_file)
+
+        kwargs = mock_start.call_args.kwargs
+        # The process logger already writes to stdout, so nothing should copy 
its output there again.
+        assert not kwargs.get("subprocess_logs_to_stdout")
+        with structlog.testing.capture_logs() as cap:
+            kwargs["logger"].info("parsing")
+        assert cap[0]["dag_file"] == "my_dag.py"
+        assert cap[0]["bundle_name"] == "testing"
+

Review Comment:
   Could we add a test verifying that a parser log message actually reaches 
stdout exactly once, with the DAG file and bundle name attached?



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