mirror of
https://github.com/hpd840321/starRiverProperty.git
synced 2026-06-09 08:20:31 +08:00
docs+test: 发布包对拍计划、pytest 双端 API 对拍与 run_elevator_parity 脚本
- docs/elevator-api-parity: 计划/报告模板/示例 - tools/elevator_api_parity: 端点目录、fixtures、对拍 client/compare、报告生成 - scripts/run_elevator_parity: JDK8 构建 + 单测/对拍(无服务时跳过对拍用例) Made-with: Cursor Former-commit-id: 3d54a40e1a7ae0b1724261d4f18910a6f415f853
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
"""Probes that work for both Spring Boot 1.5/2.x with common actuator settings."""
|
||||
|
||||
import requests
|
||||
|
||||
_CANDIDATES = (
|
||||
"/actuator/health",
|
||||
"/actuator/health/", # noqa: PIE
|
||||
"/health",
|
||||
"/application/health", # very old
|
||||
)
|
||||
|
||||
|
||||
def probe_healthy(base_url: str, session: requests.Session, timeout: float = 2.0) -> tuple[str, bool, int]:
|
||||
base = base_url.rstrip("/")
|
||||
last_status = 0
|
||||
for path in _CANDIDATES:
|
||||
try:
|
||||
r = session.get(base + path, timeout=timeout, allow_redirects=True)
|
||||
last_status = r.status_code
|
||||
if r.status_code == 200 and _body_up(r.text):
|
||||
return path, True, r.status_code
|
||||
except requests.RequestException:
|
||||
last_status = -1
|
||||
return _CANDIDATES[0], False, last_status
|
||||
|
||||
|
||||
def _body_up(text: str) -> bool:
|
||||
t = (text or "").lower()
|
||||
return "up" in t or '"status":"ok"' in t or '"status": "ok"' in t
|
||||
Reference in New Issue
Block a user