[tests] Speed up the host OTA integration tests (#21248)

This commit is contained in:
J. Nick Koston
2026-10-21 13:29:58 -04:00
committed by GitHub
parent c9fe7451a6
commit 7c0fa49b00
+25 -1
View File
@@ -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(