refactor(db): 清理遗留死代码并对齐文档与测试
删除 dbv2 从未挂载的 log_module.py(Flask /log/* 遗留)与纯 TCP 服务 用不到的 security_middleware.py 副本;db/README.md 按 pymsg 实现重写, requirements 去掉 flask/waitress;黑盒测试对 pymsg 服务改用 TCP 探测, 修复 check_service HTTP 探测导致的 db 测试整体假 skip。
This commit is contained in:
1 parent
dabd892601
commit
6692c9c4ee
9 files changed
+130
-818
No files matched your search
@@ -284,6 +284,21 @@ class PymsgClient:
|
||||
# 服务可用性检查
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def check_tcp_service(host: str, port: int, timeout: float = 5.0) -> tuple:
|
||||
"""检查纯 TCP 服务(如 pymsg 协议服务 db/captcha/smtp)是否可达。
|
||||
返回 (reachable: bool, detail: str)。
|
||||
"""
|
||||
try:
|
||||
with socket.create_connection((host, port), timeout=timeout):
|
||||
return True, "TCP 连接成功"
|
||||
except ConnectionRefusedError:
|
||||
return False, "连接被拒绝 (服务未启动或端口未监听)"
|
||||
except socket.timeout:
|
||||
return False, f"TCP 连接超时 ({timeout}s)"
|
||||
except OSError as e:
|
||||
return False, f"网络错误: {e}"
|
||||
|
||||
|
||||
def check_service(url: str, timeout: float = 8.0) -> tuple:
|
||||
"""检查服务是否可达(HTTP 请求检测,与测试实际行为一致)。
|
||||
返回 (reachable: bool, detail: str)。
|
||||
|
||||
Reference in new issue
Block a user