From fb40e6d45513297e6de3f06d964f1f1407530cf5 Mon Sep 17 00:00:00 2001 From: Luke Date: Sat, 28 Nov 2026 23:05:17 -0500 Subject: [PATCH] test(mqtt): accept a reset TLS peer in the relay teardown test The TLS variant of the relay teardown test expected the robot side to read a clean EOF. The proxy shuts the socket down without a TLS close_notify, so on Linux the robot's read can raise BrokenPipeError or SSLEOFError instead. This failed the v1.3.0-rc1 release build. Accept those for TLS sockets only. Co-Authored-By: Claude Opus 5.5 --- tests/test_mqtt_tls_proxy.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/test_mqtt_tls_proxy.py b/tests/test_mqtt_tls_proxy.py index 4a0140df..3dac6205 100644 --- a/tests/test_mqtt_tls_proxy.py +++ b/tests/test_mqtt_tls_proxy.py @@ -1903,6 +1903,19 @@ def _wrap_tls_socketpair(tmp_path, proxy: MqttTlsProxy) -> tuple[ssl.SSLSocket, return robot, server +def _assert_peer_closed(sock: socket.socket) -> None: + """Assert the peer saw the proxy end the connection. + + A plain socket reads EOF. A TLS socket was shut down without a close_notify, so + depending on timing its read returns EOF or raises SSLEOFError, or the TLS layer's + own write (for example a session-ticket ack) fails with EPIPE / ECONNRESET. + """ + try: + assert sock.recv(1) == b"" + except (ssl.SSLEOFError, BrokenPipeError, ConnectionResetError): + assert isinstance(sock, ssl.SSLSocket) + + @pytest.mark.parametrize("tls", [False, True], ids=["plain", "tls"]) def test_close_conn_endpoints_wakes_relay_threads_blocked_in_recv(tmp_path, tls: bool) -> None: proxy = _teardown_test_proxy(tmp_path) @@ -1933,7 +1946,7 @@ def test_close_conn_endpoints_wakes_relay_threads_blocked_in_recv(tmp_path, tls: assert not thread.is_alive() assert errors == [] assert broker.recv(1) == b"" - assert robot.recv(1) == b"" + _assert_peer_closed(robot) finally: proxy.stop() for sock in (robot, broker, *held):