verifaied 0.37.1.dev108__tar.gz → 0.37.2.dev109__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/PKG-INFO +1 -1
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/pyproject.toml +1 -1
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/cli.py +32 -7
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/client.py +163 -47
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/record.py +20 -4
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/testcmd.py +14 -2
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_client.py +280 -4
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_record.py +51 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_testcmd.py +83 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/uv.lock +1 -1
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/.gitignore +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/LICENSE +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/README.md +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/__init__.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/__main__.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/agent_mcp.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/agent_steps.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/analyzer.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/audit.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/collect_browser.js +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/collect_browser.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/config.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/credentials.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/failure_text.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/finishing.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/instrument.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/instrument_snippets.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/instrumenter.js +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/instrumenter.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/lanes.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/logincmd.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/prompts.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/proxy.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/recorder_driver.js +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/recorder_observer.js +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/recorder_picker.js +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/recorder_refs.js +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/recorder_spec.js +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/replay_harvest.ts +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/repo_config.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/run_reporter.js +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/runner_dir.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/setupcmd.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/skill/SKILL.md +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/skill/reference/commands.md +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/skillcmd.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/source_index.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/stepcheck.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/subprocess_util.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/suite_report.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/uploader.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/varcmd.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/video_render.js +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/src/verifaied/video_render.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/__init__.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/conftest.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_agent_mcp.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_audit.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_browser_settings_parity.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_caption_parity.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_check.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_check_done.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_clear_manual.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_cli.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_collect_browser.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_config.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_console_label_parity.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_credentials.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_finishing.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_help_markup.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_instrument.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_instrument_detect.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_instrument_snippets.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_instrumenter.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_lanes.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_login_commands.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_logincmd.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_pause_parity.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_prompt_parity.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_proxy.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_render_parity.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_replay_harvest_runner.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_repo_config.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_setupcmd.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_skill_parity.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_skillcmd.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_source_index.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_stepcheck_parity.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_suite_report.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_uploader.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_varcmd.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_video_render.py +0 -0
- {verifaied-0.37.1.dev108 → verifaied-0.37.2.dev109}/tests/test_video_render_runner.py +0 -0
|
@@ -1214,7 +1214,9 @@ def _require_token(token: str | None, api_url: str) -> str:
|
|
|
1214
1214
|
return resolved
|
|
1215
1215
|
|
|
1216
1216
|
|
|
1217
|
-
def _resolve_repo(
|
|
1217
|
+
def _resolve_repo(
|
|
1218
|
+
*, repo_input: str | None, api_url: str, token: str, patient: bool = False
|
|
1219
|
+
) -> UUID:
|
|
1218
1220
|
"""Turn the user's --repo value (or nothing) into a concrete UUID.
|
|
1219
1221
|
|
|
1220
1222
|
Order of preference:
|
|
@@ -1232,7 +1234,13 @@ def _resolve_repo(*, repo_input: str | None, api_url: str, token: str) -> UUID:
|
|
|
1232
1234
|
pass
|
|
1233
1235
|
if "/" in repo_input:
|
|
1234
1236
|
owner, _, name = repo_input.partition("/")
|
|
1235
|
-
return resolve_repo_id(
|
|
1237
|
+
return resolve_repo_id(
|
|
1238
|
+
api_url=api_url,
|
|
1239
|
+
token=token,
|
|
1240
|
+
owner=owner,
|
|
1241
|
+
name=name,
|
|
1242
|
+
patient=patient,
|
|
1243
|
+
)
|
|
1236
1244
|
raise UploaderError(
|
|
1237
1245
|
f"--repo must be a UUID or `owner/name`, got: {repo_input!r}"
|
|
1238
1246
|
)
|
|
@@ -1242,7 +1250,13 @@ def _resolve_repo(*, repo_input: str | None, api_url: str, token: str) -> UUID:
|
|
|
1242
1250
|
"couldn't auto-detect the repo: no GitHub `origin` remote found. "
|
|
1243
1251
|
"Pass --repo <owner/name> or --repo <UUID> explicitly."
|
|
1244
1252
|
)
|
|
1245
|
-
return resolve_repo_id(
|
|
1253
|
+
return resolve_repo_id(
|
|
1254
|
+
api_url=api_url,
|
|
1255
|
+
token=token,
|
|
1256
|
+
owner=slug[0],
|
|
1257
|
+
name=slug[1],
|
|
1258
|
+
patient=patient,
|
|
1259
|
+
)
|
|
1246
1260
|
|
|
1247
1261
|
|
|
1248
1262
|
def _discover_coverage_files() -> list[Path]:
|
|
@@ -1385,19 +1399,30 @@ def _api_error_text(e: ApiError, api_url: str) -> str:
|
|
|
1385
1399
|
|
|
1386
1400
|
|
|
1387
1401
|
def _test_prelude(
|
|
1388
|
-
*,
|
|
1402
|
+
*,
|
|
1403
|
+
repo: str | None,
|
|
1404
|
+
api_url: str | None,
|
|
1405
|
+
token: str | None,
|
|
1406
|
+
patient: bool = False,
|
|
1389
1407
|
) -> tuple[str, str, UUID]:
|
|
1390
1408
|
"""Resolve the API URL, the token and the repo, or exit.
|
|
1391
1409
|
|
|
1392
1410
|
Shared by all three ``verifaied test`` commands because all three need
|
|
1393
1411
|
exactly this, and repeating it is how one of them ends up with a
|
|
1394
1412
|
different exit code for a missing token.
|
|
1413
|
+
|
|
1414
|
+
``patient`` is for the batch commands (``test run``, ``test sync``):
|
|
1415
|
+
resolving the repo then waits out a service that is being replaced
|
|
1416
|
+
instead of failing the whole run on its first request.
|
|
1395
1417
|
"""
|
|
1396
1418
|
resolved_url = resolved_api_url(api_url)
|
|
1397
1419
|
resolved_token = _require_token(token, resolved_url)
|
|
1398
1420
|
try:
|
|
1399
1421
|
repo_id = _resolve_repo(
|
|
1400
|
-
repo_input=repo,
|
|
1422
|
+
repo_input=repo,
|
|
1423
|
+
api_url=resolved_url,
|
|
1424
|
+
token=resolved_token,
|
|
1425
|
+
patient=patient,
|
|
1401
1426
|
)
|
|
1402
1427
|
except (UploaderError, ApiError, RepoNotFoundError) as e:
|
|
1403
1428
|
err_console.print(f"[red]VerifAIed error[/red]: {e}")
|
|
@@ -2174,7 +2199,7 @@ def test_run_command(
|
|
|
2174
2199
|
1 usage / config error (no token, unknown test or folder, no Playwright)
|
|
2175
2200
|
"""
|
|
2176
2201
|
resolved_url, resolved_token, repo_id = _test_prelude(
|
|
2177
|
-
repo=repo, api_url=api_url, token=token
|
|
2202
|
+
repo=repo, api_url=api_url, token=token, patient=True
|
|
2178
2203
|
)
|
|
2179
2204
|
try:
|
|
2180
2205
|
code = run_test_run(
|
|
@@ -2473,7 +2498,7 @@ def test_sync_command(
|
|
|
2473
2498
|
2 the API refused a request
|
|
2474
2499
|
"""
|
|
2475
2500
|
resolved_url, resolved_token, repo_id = _test_prelude(
|
|
2476
|
-
repo=repo, api_url=api_url, token=token
|
|
2501
|
+
repo=repo, api_url=api_url, token=token, patient=True
|
|
2477
2502
|
)
|
|
2478
2503
|
try:
|
|
2479
2504
|
run_test_sync(
|
|
@@ -7,6 +7,7 @@ can be swapped if/when we add a streaming variant for huge uploads.
|
|
|
7
7
|
|
|
8
8
|
from __future__ import annotations
|
|
9
9
|
|
|
10
|
+
import sys
|
|
10
11
|
import time
|
|
11
12
|
from collections.abc import Callable
|
|
12
13
|
from dataclasses import dataclass
|
|
@@ -24,31 +25,80 @@ from verifaied.uploader import Payload
|
|
|
24
25
|
# access points, a CI runner sharing one uplink with five others — and one
|
|
25
26
|
# dropped connection there would otherwise turn a passing run into exit 2.
|
|
26
27
|
UPLOAD_BACKOFF: tuple[float, ...] = (2.0, 6.0)
|
|
28
|
+
# The waits of a call that has to outlast the service being *replaced*, not
|
|
29
|
+
# just one dropped connection: a deploy, or a task killed and started again,
|
|
30
|
+
# leaves the API answering 502/503/504 for forty seconds to two minutes.
|
|
31
|
+
# Eight attempts over two and a half minutes. Used where giving up loses
|
|
32
|
+
# something — a run's last coverage upload, its verdict — and by the batch
|
|
33
|
+
# commands (`test run`, `test sync`) nobody is sitting in front of.
|
|
34
|
+
PATIENT_BACKOFF: tuple[float, ...] = (2.0, 6.0, 15.0, 30.0, 30.0, 30.0, 37.0)
|
|
35
|
+
# A call that is not retried at all.
|
|
36
|
+
NO_BACKOFF: tuple[float, ...] = ()
|
|
37
|
+
# A wait at least this long is announced, so a log shows a CLI that is
|
|
38
|
+
# waiting for the service rather than one that has hung.
|
|
39
|
+
ANNOUNCE_FROM = 15.0
|
|
40
|
+
# Answers a load balancer gives when it has no healthy target to hand the
|
|
41
|
+
# request to — the request never reached the service.
|
|
42
|
+
_UNSENT_STATUSES = frozenset({502, 503})
|
|
27
43
|
# Indirected so tests can skip the waits.
|
|
28
44
|
_sleep: Callable[[float], None] = time.sleep
|
|
29
45
|
|
|
30
46
|
|
|
31
|
-
def
|
|
32
|
-
"""
|
|
47
|
+
def _announce(message: str) -> None:
|
|
48
|
+
"""Say that a retry is waiting. Indirected so tests can read it."""
|
|
49
|
+
print(message, file=sys.stderr, flush=True)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _wait(delay: float, why: str) -> None:
|
|
53
|
+
if delay >= ANNOUNCE_FROM:
|
|
54
|
+
_announce(f"verifAIed is not answering ({why}); trying again in {delay:g}s")
|
|
55
|
+
_sleep(delay)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _send_with_retry(
|
|
59
|
+
send: Callable[[], httpx.Response],
|
|
60
|
+
*,
|
|
61
|
+
backoff: tuple[float, ...] = UPLOAD_BACKOFF,
|
|
62
|
+
unsent_only: bool = False,
|
|
63
|
+
) -> httpx.Response:
|
|
64
|
+
"""Send a request, retrying what a retry can fix.
|
|
33
65
|
|
|
34
66
|
A connection that failed or timed out, or a 5xx, is tried again after
|
|
35
|
-
each
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
67
|
+
each ``backoff`` delay; the last attempt's answer — or its exception —
|
|
68
|
+
is what the caller sees. A 4xx is returned at once: the request itself
|
|
69
|
+
is wrong (a bad token, a payload too big) and sending it again only
|
|
70
|
+
repeats the refusal.
|
|
71
|
+
|
|
72
|
+
``unsent_only`` is for a request that creates something and so must
|
|
73
|
+
not be sent twice. It narrows the retry to failures that mean the
|
|
74
|
+
service never saw the request — a connection that was never made, or
|
|
75
|
+
the load balancer's own 502/503 — and hands back anything else (a
|
|
76
|
+
timeout while reading the answer, a 500, a 504) on the spot, because
|
|
77
|
+
the first attempt may have landed.
|
|
39
78
|
"""
|
|
40
|
-
for delay in
|
|
79
|
+
for delay in backoff:
|
|
41
80
|
try:
|
|
42
81
|
response = send()
|
|
43
|
-
except httpx.TransportError:
|
|
44
|
-
|
|
82
|
+
except httpx.TransportError as e:
|
|
83
|
+
if unsent_only and not isinstance(
|
|
84
|
+
e, (httpx.ConnectError, httpx.ConnectTimeout)
|
|
85
|
+
):
|
|
86
|
+
raise
|
|
87
|
+
_wait(delay, type(e).__name__)
|
|
45
88
|
continue
|
|
46
89
|
if response.status_code < 500:
|
|
47
90
|
return response
|
|
48
|
-
|
|
91
|
+
if unsent_only and response.status_code not in _UNSENT_STATUSES:
|
|
92
|
+
return response
|
|
93
|
+
_wait(delay, str(response.status_code))
|
|
49
94
|
return send()
|
|
50
95
|
|
|
51
96
|
|
|
97
|
+
def _backoff(patient: bool) -> tuple[float, ...]:
|
|
98
|
+
"""The waits of a call that retries only when asked to be patient."""
|
|
99
|
+
return PATIENT_BACKOFF if patient else NO_BACKOFF
|
|
100
|
+
|
|
101
|
+
|
|
52
102
|
class RepoNotFoundError(Exception):
|
|
53
103
|
"""The owner/name slug isn't connected to verifAIed under this
|
|
54
104
|
account. Raised by ``resolve_repo_id`` so the CLI can show a
|
|
@@ -99,6 +149,7 @@ def upload(
|
|
|
99
149
|
session_id: UUID | None = None,
|
|
100
150
|
driver: str | None = None,
|
|
101
151
|
timeout: float = 60.0,
|
|
152
|
+
patient: bool = False,
|
|
102
153
|
) -> UploadResult:
|
|
103
154
|
"""POST the payload and return the parsed response.
|
|
104
155
|
|
|
@@ -107,6 +158,12 @@ def upload(
|
|
|
107
158
|
the default httpx 5s. Callers can override for CI use. A dropped
|
|
108
159
|
connection, a timeout or a 5xx is tried twice more, after 2s and 6s.
|
|
109
160
|
|
|
161
|
+
``patient`` stretches that to :data:`PATIENT_BACKOFF`, long enough to
|
|
162
|
+
outlast the service being replaced. It is for a session's *last*
|
|
163
|
+
upload, whose failure loses the coverage; an interval flush stays
|
|
164
|
+
short, because the next tick sends the same cumulative data anyway and
|
|
165
|
+
a long wait there would hold up the recording.
|
|
166
|
+
|
|
110
167
|
``session_id`` attaches the upload to a session in the evidence ledger;
|
|
111
168
|
``driver`` says who was at the wheel for the implicit session a
|
|
112
169
|
sessionless browser upload gets. Both are ignored by older backends.
|
|
@@ -135,7 +192,8 @@ def upload(
|
|
|
135
192
|
|
|
136
193
|
try:
|
|
137
194
|
response = _send_with_retry(
|
|
138
|
-
lambda: httpx.post(url, json=body, headers=headers, timeout=timeout)
|
|
195
|
+
lambda: httpx.post(url, json=body, headers=headers, timeout=timeout),
|
|
196
|
+
backoff=PATIENT_BACKOFF if patient else UPLOAD_BACKOFF,
|
|
139
197
|
)
|
|
140
198
|
except httpx.HTTPError as e:
|
|
141
199
|
raise ApiError(0, f"could not reach {url}: {e}") from e
|
|
@@ -176,6 +234,7 @@ def create_session(
|
|
|
176
234
|
recorded_test_id: UUID | None = None,
|
|
177
235
|
environment: str | None = None,
|
|
178
236
|
timeout: float = 15.0,
|
|
237
|
+
patient: bool = False,
|
|
179
238
|
) -> tuple[UUID, str | None]:
|
|
180
239
|
"""Open a session in the branch's evidence ledger.
|
|
181
240
|
|
|
@@ -194,6 +253,12 @@ def create_session(
|
|
|
194
253
|
slow or unreachable ledger must not hold up the thing the user actually
|
|
195
254
|
asked for. Callers are expected to treat a failure as "record without a
|
|
196
255
|
session", not as a reason to stop.
|
|
256
|
+
|
|
257
|
+
``patient`` is for a replay nobody is watching (`test run`), where a
|
|
258
|
+
session that failed to open costs the run its verdict: the open then
|
|
259
|
+
waits out a service that is being replaced. Only failures that mean
|
|
260
|
+
the request never arrived are retried — opening twice would leave a
|
|
261
|
+
second session nobody closes.
|
|
197
262
|
"""
|
|
198
263
|
url = f"{api_url.rstrip('/')}/repositories/{repo_id}/sessions"
|
|
199
264
|
body: dict[str, Any] = {"branch": branch, "driver": driver, "kind": kind}
|
|
@@ -208,11 +273,15 @@ def create_session(
|
|
|
208
273
|
if environment is not None:
|
|
209
274
|
body["environment"] = environment
|
|
210
275
|
try:
|
|
211
|
-
response =
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
276
|
+
response = _send_with_retry(
|
|
277
|
+
lambda: httpx.post(
|
|
278
|
+
url,
|
|
279
|
+
json=body,
|
|
280
|
+
headers={"Authorization": f"Bearer {token}"},
|
|
281
|
+
timeout=timeout,
|
|
282
|
+
),
|
|
283
|
+
backoff=_backoff(patient),
|
|
284
|
+
unsent_only=True,
|
|
216
285
|
)
|
|
217
286
|
except httpx.HTTPError as e:
|
|
218
287
|
raise ApiError(0, f"could not reach {url}: {e}") from e
|
|
@@ -246,8 +315,10 @@ def finalize_session(
|
|
|
246
315
|
there is one, so a close from anything without a flowchart is the same
|
|
247
316
|
request it always was.
|
|
248
317
|
|
|
249
|
-
Retried
|
|
250
|
-
|
|
318
|
+
Retried on a dropped connection, a timeout or a 5xx, and patiently
|
|
319
|
+
(:data:`PATIENT_BACKOFF`): the close carries the run's verdict, and a
|
|
320
|
+
service that is being replaced is back within a couple of minutes.
|
|
321
|
+
Safe to repeat: the service keeps the first close's end time and
|
|
251
322
|
writes the verdict again, so a close that landed but whose answer was
|
|
252
323
|
lost is only recorded twice.
|
|
253
324
|
"""
|
|
@@ -266,7 +337,8 @@ def finalize_session(
|
|
|
266
337
|
json=body,
|
|
267
338
|
headers={"Authorization": f"Bearer {token}"},
|
|
268
339
|
timeout=timeout,
|
|
269
|
-
)
|
|
340
|
+
),
|
|
341
|
+
backoff=PATIENT_BACKOFF,
|
|
270
342
|
)
|
|
271
343
|
except httpx.HTTPError as e:
|
|
272
344
|
raise ApiError(0, f"could not reach {url}: {e}") from e
|
|
@@ -341,7 +413,11 @@ def upload_artifact(
|
|
|
341
413
|
Streamed as multipart with a generous timeout: a trace archive is tens
|
|
342
414
|
of megabytes and the server hashes it on the way through, so the
|
|
343
415
|
default 60s used elsewhere is too tight to be safe. Retried like
|
|
344
|
-
:func:`upload` on a dropped connection, a timeout or a
|
|
416
|
+
an interval :func:`upload` on a dropped connection, a timeout or a
|
|
417
|
+
5xx — the short :data:`UPLOAD_BACKOFF`, not the patient one: every
|
|
418
|
+
request here adds an artifact, so a repeat of one that landed leaves
|
|
419
|
+
two, and a run's last coverage upload has already waited out an
|
|
420
|
+
outage by the time its evidence is sent.
|
|
345
421
|
"""
|
|
346
422
|
url = f"{api_url.rstrip('/')}/sessions/{session_id}/artifacts"
|
|
347
423
|
data: dict[str, str] = {"kind": kind}
|
|
@@ -480,6 +556,7 @@ def list_recorded_tests(
|
|
|
480
556
|
repo_id: UUID,
|
|
481
557
|
branch: str | None = None,
|
|
482
558
|
timeout: float = 30.0,
|
|
559
|
+
patient: bool = False,
|
|
483
560
|
) -> list[dict[str, Any]]:
|
|
484
561
|
"""The repo's recorded tests, resolved against a branch.
|
|
485
562
|
|
|
@@ -487,15 +564,22 @@ def list_recorded_tests(
|
|
|
487
564
|
``name_slug`` in here rather than deriving a row from the name it was
|
|
488
565
|
given — the server owns identity, and ``spec_path`` in particular is
|
|
489
566
|
frozen at creation and must always come from the row.
|
|
567
|
+
|
|
568
|
+
``patient`` waits out a service that is being replaced
|
|
569
|
+
(:data:`PATIENT_BACKOFF`), for the batch commands whose whole run
|
|
570
|
+
would otherwise fail on this one read.
|
|
490
571
|
"""
|
|
491
572
|
url = f"{api_url.rstrip('/')}/repositories/{repo_id}/recorded-tests"
|
|
492
573
|
params = {"branch": branch} if branch is not None else None
|
|
493
574
|
try:
|
|
494
|
-
response =
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
575
|
+
response = _send_with_retry(
|
|
576
|
+
lambda: httpx.get(
|
|
577
|
+
url,
|
|
578
|
+
params=params,
|
|
579
|
+
headers={"Authorization": f"Bearer {token}"},
|
|
580
|
+
timeout=timeout,
|
|
581
|
+
),
|
|
582
|
+
backoff=_backoff(patient),
|
|
499
583
|
)
|
|
500
584
|
except httpx.HTTPError as e:
|
|
501
585
|
raise ApiError(0, f"could not reach {url}: {e}") from e
|
|
@@ -518,6 +602,7 @@ def create_recorded_test(
|
|
|
518
602
|
description: str | None = None,
|
|
519
603
|
branch: str | None = None,
|
|
520
604
|
timeout: float = 30.0,
|
|
605
|
+
patient: bool = False,
|
|
521
606
|
) -> dict[str, Any]:
|
|
522
607
|
"""Declare a test. Returns the created row, including its ``spec_path``.
|
|
523
608
|
|
|
@@ -531,6 +616,10 @@ def create_recorded_test(
|
|
|
531
616
|
anywhere, the branch it was made on is the only thing that says where
|
|
532
617
|
it belongs. Omitted from the body when there is none, so a request
|
|
533
618
|
from an older client is byte-identical to what it always sent.
|
|
619
|
+
|
|
620
|
+
``patient`` waits out a service that is being replaced, retrying only
|
|
621
|
+
failures that mean the request never arrived: a create that landed and
|
|
622
|
+
is sent again answers 409.
|
|
534
623
|
"""
|
|
535
624
|
request_url = f"{api_url.rstrip('/')}/repositories/{repo_id}/recorded-tests"
|
|
536
625
|
body: dict[str, Any] = {"feature": feature, "name": name}
|
|
@@ -541,11 +630,15 @@ def create_recorded_test(
|
|
|
541
630
|
if branch is not None:
|
|
542
631
|
body["branch"] = branch
|
|
543
632
|
try:
|
|
544
|
-
response =
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
633
|
+
response = _send_with_retry(
|
|
634
|
+
lambda: httpx.post(
|
|
635
|
+
request_url,
|
|
636
|
+
json=body,
|
|
637
|
+
headers={"Authorization": f"Bearer {token}"},
|
|
638
|
+
timeout=timeout,
|
|
639
|
+
),
|
|
640
|
+
backoff=_backoff(patient),
|
|
641
|
+
unsent_only=True,
|
|
549
642
|
)
|
|
550
643
|
except httpx.HTTPError as e:
|
|
551
644
|
raise ApiError(0, f"could not reach {request_url}: {e}") from e
|
|
@@ -569,6 +662,7 @@ def patch_recorded_test(
|
|
|
569
662
|
body_hash: str | None = None,
|
|
570
663
|
links: list[dict[str, Any]] | None = None,
|
|
571
664
|
timeout: float = 30.0,
|
|
665
|
+
patient: bool = False,
|
|
572
666
|
) -> dict[str, Any]:
|
|
573
667
|
"""Update a test's status, URL, description, chain or saved-body facts.
|
|
574
668
|
|
|
@@ -586,6 +680,9 @@ def patch_recorded_test(
|
|
|
586
680
|
are sent together whenever a save or a refresh rewrote the file, and
|
|
587
681
|
``links`` follows the same rule as ``pre_steps``: an explicit ``[]``
|
|
588
682
|
is how a spec that no longer has any linked blocks says so.
|
|
683
|
+
|
|
684
|
+
``patient`` waits out a service that is being replaced. Safe to
|
|
685
|
+
repeat: every field is set, none is added to.
|
|
589
686
|
"""
|
|
590
687
|
request_url = f"{api_url.rstrip('/')}/recorded-tests/{test_id}"
|
|
591
688
|
body: dict[str, Any] = {}
|
|
@@ -602,11 +699,14 @@ def patch_recorded_test(
|
|
|
602
699
|
if links is not None:
|
|
603
700
|
body["links"] = list(links)
|
|
604
701
|
try:
|
|
605
|
-
response =
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
702
|
+
response = _send_with_retry(
|
|
703
|
+
lambda: httpx.patch(
|
|
704
|
+
request_url,
|
|
705
|
+
json=body,
|
|
706
|
+
headers={"Authorization": f"Bearer {token}"},
|
|
707
|
+
timeout=timeout,
|
|
708
|
+
),
|
|
709
|
+
backoff=_backoff(patient),
|
|
610
710
|
)
|
|
611
711
|
except httpx.HTTPError as e:
|
|
612
712
|
raise ApiError(0, f"could not reach {request_url}: {e}") from e
|
|
@@ -647,6 +747,7 @@ def post_recording_steps(
|
|
|
647
747
|
live: bool = True,
|
|
648
748
|
context: dict[str, Any] | None = None,
|
|
649
749
|
timeout: float = 30.0,
|
|
750
|
+
patient: bool = False,
|
|
650
751
|
) -> dict[str, Any]:
|
|
651
752
|
"""Stream the flowchart of a recording in progress, and collect work.
|
|
652
753
|
|
|
@@ -662,17 +763,24 @@ def post_recording_steps(
|
|
|
662
763
|
A server that predates the channel answers 204 with no body; that is
|
|
663
764
|
read as "nothing to do" rather than an error, so an older backend
|
|
664
765
|
still gets a live flowchart.
|
|
766
|
+
|
|
767
|
+
``patient`` waits out a service that is being replaced — for `test
|
|
768
|
+
sync`, which posts each list once. A live recording never asks for it:
|
|
769
|
+
its next post, seconds later, carries the whole list again.
|
|
665
770
|
"""
|
|
666
771
|
request_url = f"{api_url.rstrip('/')}/recorded-tests/{test_id}/recording-steps"
|
|
667
772
|
body: dict[str, Any] = {"steps": steps, "live": live}
|
|
668
773
|
if context is not None:
|
|
669
774
|
body["context"] = context
|
|
670
775
|
try:
|
|
671
|
-
response =
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
776
|
+
response = _send_with_retry(
|
|
777
|
+
lambda: _http().post(
|
|
778
|
+
request_url,
|
|
779
|
+
json=body,
|
|
780
|
+
headers={"Authorization": f"Bearer {token}"},
|
|
781
|
+
timeout=timeout,
|
|
782
|
+
),
|
|
783
|
+
backoff=_backoff(patient),
|
|
676
784
|
)
|
|
677
785
|
except httpx.HTTPError as e:
|
|
678
786
|
raise ApiError(0, f"could not reach {request_url}: {e}") from e
|
|
@@ -987,7 +1095,7 @@ def clear_manual_coverage(
|
|
|
987
1095
|
|
|
988
1096
|
|
|
989
1097
|
def list_installations(
|
|
990
|
-
*, api_url: str, token: str, timeout: float = 15.0
|
|
1098
|
+
*, api_url: str, token: str, timeout: float = 15.0, patient: bool = False
|
|
991
1099
|
) -> list[dict[str, Any]]:
|
|
992
1100
|
"""Fetch ``GET /installations/me``.
|
|
993
1101
|
|
|
@@ -995,13 +1103,19 @@ def list_installations(
|
|
|
995
1103
|
with a ``repositories`` array). Used by ``resolve_repo_id`` to map
|
|
996
1104
|
an owner/name slug to a UUID without forcing the user to look one
|
|
997
1105
|
up by hand.
|
|
1106
|
+
|
|
1107
|
+
``patient`` waits out a service that is being replaced
|
|
1108
|
+
(:data:`PATIENT_BACKOFF`).
|
|
998
1109
|
"""
|
|
999
1110
|
url = f"{api_url.rstrip('/')}/installations/me"
|
|
1000
1111
|
try:
|
|
1001
|
-
response =
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1112
|
+
response = _send_with_retry(
|
|
1113
|
+
lambda: httpx.get(
|
|
1114
|
+
url,
|
|
1115
|
+
headers={"Authorization": f"Bearer {token}"},
|
|
1116
|
+
timeout=timeout,
|
|
1117
|
+
),
|
|
1118
|
+
backoff=_backoff(patient),
|
|
1005
1119
|
)
|
|
1006
1120
|
except httpx.HTTPError as e:
|
|
1007
1121
|
raise ApiError(0, f"could not reach {url}: {e}") from e
|
|
@@ -1013,7 +1127,9 @@ def list_installations(
|
|
|
1013
1127
|
return data
|
|
1014
1128
|
|
|
1015
1129
|
|
|
1016
|
-
def resolve_repo_id(
|
|
1130
|
+
def resolve_repo_id(
|
|
1131
|
+
*, api_url: str, token: str, owner: str, name: str, patient: bool = False
|
|
1132
|
+
) -> UUID:
|
|
1017
1133
|
"""Map ``owner/name`` to a repository UUID via /installations/me.
|
|
1018
1134
|
|
|
1019
1135
|
Raises ``RepoNotFoundError`` if the slug isn't connected under this
|
|
@@ -1021,7 +1137,7 @@ def resolve_repo_id(*, api_url: str, token: str, owner: str, name: str) -> UUID:
|
|
|
1021
1137
|
treats slugs that way and a user may have it written either way in
|
|
1022
1138
|
their `origin` remote.
|
|
1023
1139
|
"""
|
|
1024
|
-
installs = list_installations(api_url=api_url, token=token)
|
|
1140
|
+
installs = list_installations(api_url=api_url, token=token, patient=patient)
|
|
1025
1141
|
owner_lc, name_lc = owner.lower(), name.lower()
|
|
1026
1142
|
for install in installs:
|
|
1027
1143
|
for repo in install.get("repositories") or []:
|
|
@@ -329,9 +329,14 @@ def flush_upload(
|
|
|
329
329
|
coverage_kind: str = "manual",
|
|
330
330
|
session_id: UUID | None = None,
|
|
331
331
|
driver: str | None = None,
|
|
332
|
+
patient: bool = False,
|
|
332
333
|
) -> UploadResult | None:
|
|
333
334
|
"""Upload the merged state as session coverage, if it changed.
|
|
334
335
|
|
|
336
|
+
``patient`` is passed through to :func:`upload`: a session's last
|
|
337
|
+
flush waits out a service that is being replaced, an interval one
|
|
338
|
+
does not.
|
|
339
|
+
|
|
335
340
|
``coverage_kind`` picks the dimension: ``"browser"`` when this collector
|
|
336
341
|
is wrapping a suite command, ``"manual"`` for a bare interactive
|
|
337
342
|
session. They differ server-side — a browser upload becomes this
|
|
@@ -386,6 +391,7 @@ def flush_upload(
|
|
|
386
391
|
payload=payload,
|
|
387
392
|
session_id=session_id,
|
|
388
393
|
driver=driver,
|
|
394
|
+
patient=patient,
|
|
389
395
|
)
|
|
390
396
|
collector.mark_uploaded(version)
|
|
391
397
|
return result
|
|
@@ -763,10 +769,13 @@ def _final_flush(
|
|
|
763
769
|
flush_kwargs: dict[str, Any],
|
|
764
770
|
) -> bool:
|
|
765
771
|
"""The last upload of the session. Returns False only if it failed —
|
|
766
|
-
that data is about to be lost, so the caller turns it into exit 2.
|
|
772
|
+
that data is about to be lost, so the caller turns it into exit 2.
|
|
773
|
+
|
|
774
|
+
Patient where an interval tick is not: nothing comes after this one to
|
|
775
|
+
send the data again, so it waits out a service that is being replaced."""
|
|
767
776
|
console.print("\n[dim]finishing — final upload…[/dim]")
|
|
768
777
|
try:
|
|
769
|
-
result = flush_upload(collector, **flush_kwargs)
|
|
778
|
+
result = flush_upload(collector, patient=True, **flush_kwargs)
|
|
770
779
|
except (ApiError, UploaderError) as e:
|
|
771
780
|
err_console.print(f"[red]VerifAIed error[/red]: final upload failed: {e}")
|
|
772
781
|
return False
|
|
@@ -1011,6 +1020,7 @@ def _open_session(
|
|
|
1011
1020
|
recorded_test_id: UUID | None = None,
|
|
1012
1021
|
kind: str = "record",
|
|
1013
1022
|
environment: str | None = None,
|
|
1023
|
+
patient: bool = False,
|
|
1014
1024
|
console: Console,
|
|
1015
1025
|
err_console: Console,
|
|
1016
1026
|
) -> UUID | None:
|
|
@@ -1038,6 +1048,10 @@ def _open_session(
|
|
|
1038
1048
|
|
|
1039
1049
|
``environment`` is which configured environment produced this run,
|
|
1040
1050
|
carried so a pass on the ledger says where it passed.
|
|
1051
|
+
|
|
1052
|
+
``patient`` waits out a service that is being replaced before giving
|
|
1053
|
+
up on the session — a replay's, whose verdict has nowhere to go
|
|
1054
|
+
without one.
|
|
1041
1055
|
"""
|
|
1042
1056
|
try:
|
|
1043
1057
|
session_id, warning = create_session(
|
|
@@ -1052,6 +1066,7 @@ def _open_session(
|
|
|
1052
1066
|
commit_sha=commit_sha,
|
|
1053
1067
|
recorded_test_id=recorded_test_id,
|
|
1054
1068
|
environment=environment,
|
|
1069
|
+
patient=patient,
|
|
1055
1070
|
)
|
|
1056
1071
|
except ApiError as e:
|
|
1057
1072
|
if e.status_code == 403:
|
|
@@ -1085,8 +1100,9 @@ def _close_session(
|
|
|
1085
1100
|
) -> bool:
|
|
1086
1101
|
"""Close the session. Returns whether the service recorded the close.
|
|
1087
1102
|
|
|
1088
|
-
The close is
|
|
1089
|
-
connection, a timeout or a 5xx
|
|
1103
|
+
The close is patient (``finalize_session`` retries a dropped
|
|
1104
|
+
connection, a timeout or a 5xx for two and a half minutes, long enough
|
|
1105
|
+
to outlast the service being replaced). If it still fails, one line names the
|
|
1090
1106
|
session and the exact request that closes it by hand, and False goes
|
|
1091
1107
|
back to the caller: a replay's verdict rides this close, so a caller
|
|
1092
1108
|
whose verdict is the point (``test run``) turns it into exit 2 rather
|
|
@@ -4368,6 +4368,7 @@ def replay_spec(
|
|
|
4368
4368
|
recorded_test_id=UUID(str(test["id"])),
|
|
4369
4369
|
kind="test",
|
|
4370
4370
|
environment=env.name,
|
|
4371
|
+
patient=True,
|
|
4371
4372
|
console=console,
|
|
4372
4373
|
err_console=err_console,
|
|
4373
4374
|
)
|
|
@@ -10132,7 +10133,11 @@ def run_test_run(
|
|
|
10132
10133
|
resolved_branch = branch if branch is not None else detect_branch()
|
|
10133
10134
|
resolved_runner_dir = find_runner_dir(root, runner_dir)
|
|
10134
10135
|
rows = list_recorded_tests(
|
|
10135
|
-
api_url=api_url,
|
|
10136
|
+
api_url=api_url,
|
|
10137
|
+
token=token,
|
|
10138
|
+
repo_id=repo_id,
|
|
10139
|
+
branch=resolved_branch,
|
|
10140
|
+
patient=True,
|
|
10136
10141
|
)
|
|
10137
10142
|
if run_all or folder is not None:
|
|
10138
10143
|
ready = [r for r in rows if r.get("status") == "ready"]
|
|
@@ -10665,7 +10670,11 @@ def run_test_sync(
|
|
|
10665
10670
|
problems.extend(order_problems)
|
|
10666
10671
|
|
|
10667
10672
|
rows = list_recorded_tests(
|
|
10668
|
-
api_url=api_url,
|
|
10673
|
+
api_url=api_url,
|
|
10674
|
+
token=token,
|
|
10675
|
+
repo_id=repo_id,
|
|
10676
|
+
branch=resolved_branch,
|
|
10677
|
+
patient=True,
|
|
10669
10678
|
)
|
|
10670
10679
|
by_key = {(str(r.get("feature_slug")), str(r.get("name_slug"))): r for r in rows}
|
|
10671
10680
|
# A slug pair a suite-tracked test already answers to is that suite's,
|
|
@@ -10736,6 +10745,7 @@ def run_test_sync(
|
|
|
10736
10745
|
name=spec.header.name,
|
|
10737
10746
|
url=spec.url,
|
|
10738
10747
|
branch=resolved_branch,
|
|
10748
|
+
patient=True,
|
|
10739
10749
|
)
|
|
10740
10750
|
if row.get("spec_path") != spec.path:
|
|
10741
10751
|
raise RecordedTestError(
|
|
@@ -10780,6 +10790,7 @@ def run_test_sync(
|
|
|
10780
10790
|
pre_steps=wanted_pre if pre_changed else None,
|
|
10781
10791
|
body_hash=spec.body_hash,
|
|
10782
10792
|
links=spec.links,
|
|
10793
|
+
patient=True,
|
|
10783
10794
|
)
|
|
10784
10795
|
if needs_steps:
|
|
10785
10796
|
pre_refs = [
|
|
@@ -10798,6 +10809,7 @@ def run_test_sync(
|
|
|
10798
10809
|
test_id=test_id,
|
|
10799
10810
|
steps=parse_steps(spec.body, pre_refs=pre_refs),
|
|
10800
10811
|
live=False,
|
|
10812
|
+
patient=True,
|
|
10801
10813
|
)
|
|
10802
10814
|
|
|
10803
10815
|
console.print(
|