- 新增 task_report 任务级聚合指标 task_metrics - 补充创建任务幂等与失败路径/冲突测试 - 将后端测试基线提升到 20 passed - 新增 edge-agent 初始化代码、启动脚本与打包脚本 - 新增 http_health_check、check_port、check_process、grep_log 执行器 - 补充 edge-agent 基础测试并提升基线到 10 passed - 同步更新 backend README 与当前进度总结
27 lines
892 B
Python
27 lines
892 B
Python
from __future__ import annotations
|
|
|
|
import time
|
|
from typing import Any
|
|
|
|
import httpx
|
|
|
|
|
|
class HttpHealthCheckExecutor:
|
|
def execute(self, params: dict[str, Any]) -> tuple[bool, str, dict[str, Any], dict[str, Any]]:
|
|
url = params["url"]
|
|
timeout_ms = int(params.get("timeout_ms", 3000))
|
|
started_at = time.perf_counter()
|
|
with httpx.Client(timeout=timeout_ms / 1000.0) as client:
|
|
response = client.get(url)
|
|
latency_ms = max(int((time.perf_counter() - started_at) * 1000), 0)
|
|
success = response.status_code == 200
|
|
message = f"{response.status_code} {response.reason_phrase}"
|
|
data: dict[str, Any] = {
|
|
"status_code": response.status_code,
|
|
"latency_ms": latency_ms,
|
|
}
|
|
evidence = {
|
|
"response_body": response.text,
|
|
}
|
|
return success, message, data, evidence
|