新增了插件相关的完整领域模型、应用服务、基础设施实现,包括: 1. 插件状态、注册模式、来源等基础枚举和数据结构 2. 插件清单解析、发现、加载工具类 3. 插件注册表领域服务和内存存储实现 4. 插件相关的命令、查询、事件定义 5. 插件REST API接口和DTO映射 6. 集成了原有通道适配器到插件系统 7. 新增内置插件注册和自动发现能力
58 lines
2.0 KiB
Python
58 lines
2.0 KiB
Python
"""
|
|
Integration tests for channel health endpoints (/healthz, /readyz).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
pytestmark = [pytest.mark.asyncio, pytest.mark.integration]
|
|
|
|
|
|
async def test_healthz_returns_ok(test_client):
|
|
response = await test_client.get("/healthz")
|
|
assert response.status_code == 200, response.text
|
|
payload = response.json()
|
|
assert payload["status"] == "ok"
|
|
|
|
|
|
async def test_healthz_includes_startup_timeline(test_client):
|
|
response = await test_client.get("/healthz")
|
|
assert response.status_code == 200, response.text
|
|
payload = response.json()
|
|
timeline = payload.get("startup_timeline")
|
|
if timeline is not None:
|
|
assert isinstance(timeline, list)
|
|
if timeline:
|
|
assert "name" in timeline[0]
|
|
assert "status" in timeline[0]
|
|
|
|
|
|
async def test_readyz_returns_200_when_services_ready(test_client):
|
|
response = await test_client.get("/readyz")
|
|
if response.status_code == 503:
|
|
pytest.skip("Channel services not fully ready in this environment")
|
|
assert response.status_code == 200, response.text
|
|
payload = response.json()
|
|
assert payload["status"] == "ready"
|
|
|
|
|
|
async def test_readyz_includes_component_checks(test_client):
|
|
response = await test_client.get("/readyz")
|
|
payload = response.json()
|
|
for key in ("redis", "postgres", "workers", "channels", "ws_connections"):
|
|
component = payload.get(key)
|
|
if component is not None:
|
|
assert "status" in component, f"component {key} missing 'status' field"
|
|
|
|
|
|
async def test_readyz_returns_503_when_degraded(test_client):
|
|
response = await test_client.get("/readyz")
|
|
if response.status_code == 503:
|
|
payload = response.json()
|
|
assert payload["status"] == "not_ready"
|
|
components = {k: v for k, v in payload.items() if isinstance(v, dict) and "status" in v}
|
|
assert any(v["status"] != "ok" for v in components.values()), (
|
|
"503 returned but all components report ok"
|
|
)
|