Skip to content

Commit c6ea332

Browse files
committed
Test closing a Dag file processor that has no parse log file
The base class makes logger_filehandle optional for parse children other than the Python one, but DagFileProcessorProcess still requires it, so nothing in this layer reached the close path without one.
1 parent 438e073 commit c6ea332

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

‎airflow-core/tests/unit/dag_processing/test_processor.py‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import uuid
2828
import zipfile
2929
from collections.abc import Callable, Iterable
30-
from socket import socketpair
30+
from socket import socket, socketpair
3131
from typing import TYPE_CHECKING, Any, BinaryIO
3232
from unittest.mock import MagicMock, PropertyMock, patch
3333

@@ -54,6 +54,7 @@
5454
from airflow.dag_processing.dagbag import DagBag
5555
from airflow.dag_processing.manager import DagFileProcessorManager, process_parse_results
5656
from airflow.dag_processing.processor import (
57+
BaseDagFileProcessorProcess,
5758
DagFileParseRequest,
5859
DagFileParsingResult,
5960
DagFileProcessorProcess,
@@ -2546,6 +2547,25 @@ def test_handle_request_get_variable_masks_value_with_key(self, proc):
25462547
}
25472548

25482549

2550+
class TestBaseDagFileProcessorProcess:
2551+
@patch.object(BaseDagFileProcessorProcess, "cleanup_sockets_after_kill", autospec=True)
2552+
def test_close_without_log_file_handle_cleans_up_sockets(self, cleanup_sockets_after_kill):
2553+
proc = BaseDagFileProcessorProcess(
2554+
process_log=structlog.get_logger(),
2555+
id=uuid.uuid4(),
2556+
pid=1234,
2557+
process=MagicMock(spec=supervisor.ProcessTracker),
2558+
stdin=MagicMock(spec=socket),
2559+
client=MagicMock(spec=Client),
2560+
bundle_name="mybundle",
2561+
dag_file_rel_path="dags/my_dag.py",
2562+
)
2563+
2564+
proc.close()
2565+
2566+
cleanup_sockets_after_kill.assert_called_once_with(proc)
2567+
2568+
25492569
class TestMultiTeamCallbackMetrics:
25502570
"""Tests for team_name tag on dag.callback_exceptions in multi-team mode."""
25512571

0 commit comments

Comments
 (0)