test(integration): address round-3 review — harden RAG fixture & retry naming
- indexed_manual_pdf fixture: also require status == "idle" (alongside the existing indexed > 0 and pending == 0) so it doesn't break during a transient pending==0 window mid re-scan churn. Keeps the indexed > 0 guard — a pure status==idle check would break prematurely on the initial empty state. - _get_with_retry: rename `retries` -> `max_attempts` (3 total) and 1-index the loop so the param and "attempt N/M" log read self-evidently. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
909f36613d
commit
367afa0402
@@ -44,17 +44,17 @@ _SEARCH_TIMEOUT = httpx.Timeout(90.0)
|
|||||||
|
|
||||||
|
|
||||||
async def _get_with_retry(
|
async def _get_with_retry(
|
||||||
client: httpx.AsyncClient, url: str, *, retries: int = 2, **kwargs
|
client: httpx.AsyncClient, url: str, *, max_attempts: int = 3, **kwargs
|
||||||
) -> httpx.Response:
|
) -> httpx.Response:
|
||||||
"""GET with retries on transient transport errors (timeouts/conn resets)."""
|
"""GET, retrying on transient transport errors (timeouts/conn resets)."""
|
||||||
last_exc: httpx.TransportError | None = None
|
last_exc: httpx.TransportError | None = None
|
||||||
for attempt in range(retries + 1):
|
for attempt in range(1, max_attempts + 1):
|
||||||
try:
|
try:
|
||||||
return await client.get(url, **kwargs)
|
return await client.get(url, **kwargs)
|
||||||
except httpx.TransportError as e: # covers timeouts + connect/read errors
|
except httpx.TransportError as e: # covers timeouts + connect/read errors
|
||||||
last_exc = e
|
last_exc = e
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"GET %s failed (attempt %s/%s): %s", url, attempt + 1, retries + 1, e
|
"GET %s failed (attempt %s/%s): %s", url, attempt, max_attempts, e
|
||||||
)
|
)
|
||||||
await anyio.sleep(2)
|
await anyio.sleep(2)
|
||||||
raise last_exc # type: ignore[misc]
|
raise last_exc # type: ignore[misc]
|
||||||
|
|||||||
@@ -174,16 +174,22 @@ async def indexed_manual_pdf(nc_client, nc_mcp_client):
|
|||||||
content = json.loads(result.content[0].text) if result.content else {}
|
content = json.loads(result.content[0].text) if result.content else {}
|
||||||
indexed = content.get("indexed_count", 0)
|
indexed = content.get("indexed_count", 0)
|
||||||
pending = content.get("pending_count", 1)
|
pending = content.get("pending_count", 1)
|
||||||
|
status = content.get("status")
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"Attempt %s/%s: indexed=%s, pending=%s",
|
"Attempt %s/%s: indexed=%s, pending=%s, status=%s",
|
||||||
attempt,
|
attempt,
|
||||||
max_attempts,
|
max_attempts,
|
||||||
indexed,
|
indexed,
|
||||||
pending,
|
pending,
|
||||||
|
status,
|
||||||
)
|
)
|
||||||
|
|
||||||
if indexed > 0 and pending == 0:
|
# Require indexed > 0 (the manual must actually be indexed —
|
||||||
|
# idle/pending==0 is also the *initial* empty state) AND a
|
||||||
|
# settled idle scan so we don't break during a transient
|
||||||
|
# pending==0 window mid re-scan churn.
|
||||||
|
if indexed > 0 and pending == 0 and status == "idle":
|
||||||
logger.info(
|
logger.info(
|
||||||
"Vector indexing complete: %s documents indexed", indexed
|
"Vector indexing complete: %s documents indexed", indexed
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user