From 7c0fa49b00687a9c76ab9bba4d4e8a64a7523f1a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 21 Oct 2026 07:29:58 -1000 Subject: [PATCH] [tests] Speed up the host OTA integration tests (#21248) --- tests/integration/test_host_ota.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/integration/test_host_ota.py b/tests/integration/test_host_ota.py index 55947e23b34..6280044e4e8 100644 --- a/tests/integration/test_host_ota.py +++ b/tests/integration/test_host_ota.py @@ -13,7 +13,9 @@ from collections.abc import Generator from contextlib import contextmanager from dataclasses import dataclass import functools +import logging from pathlib import Path +import shutil import socket import zlib @@ -34,6 +36,8 @@ from .host_prefs import force_safe_mode from .state_utils import assert_device_name from .types import APIClientConnectedFactory, CompileFunction, ConfigWriter +_LOGGER = logging.getLogger(__name__) + DEVICE_NAME = "host-ota-test" API_KEY = "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8=" @@ -80,6 +84,10 @@ def _udp_mode( real_ack(self, data) with monkeypatch.context() as m: + # Loopback answers in about a millisecond; resend lost datagrams + # sooner so the loss runs do not dominate the test time + m.setattr(espota2, "UDP_RESEND_INITIAL", 0.05) + m.setattr(espota2, "UDP_RESEND_MIN", 0.02) if force: m.setattr(espota2, "UDP_SLOW_EXCHANGE", -1.0) if blocked: @@ -142,7 +150,23 @@ async def _build( binary_path = await compile_esphome(config_path) api_socket.close() ota_socket.close() - return api_port, ota_port, binary_path + return api_port, ota_port, await _strip_debug(binary_path) + + +async def _strip_debug(binary_path: Path) -> Path: + """The fixtures build with -g; every upload sends the image, so drop the + debug info (GNU and Apple strip both take -S).""" + if (strip := shutil.which("strip")) is None: + _LOGGER.warning( + "strip not found; uploading the unstripped binary, which is much slower" + ) + return binary_path + stripped = binary_path.with_name(f"{binary_path.name}.stripped") + proc = await asyncio.create_subprocess_exec( + strip, "-S", "-o", str(stripped), str(binary_path) + ) + assert await proc.wait() == 0, "strip failed" + return stripped async def _run_ota(