feat(#87,#88): 采集/总线/LLM 路由 DLP NFR 压测套件
新增 tests/perf/ NFR 压测套件,对应 PRD 第 9 章 SLA 全量压测: #88 LLM 路由/DLP 压测: - DLP 敏感拦截率 100%(2000 样本,含 PII/凭证/工艺词,零漏拦) - DLP 清洁零误报(1000 样本),单条 0.033ms / 30097 qps - 路由敏感不泄漏云端 100%(1500 样本,≥96.5% 基线达标) - 安全指令(停机)100% 转 block/人工 #87 采集/总线 NFR 压测: - 采集 P99=312ms(≤1.8s,600 点位 30 轮),可用性 100%(≥99.8%),丢失率 0%(≤0.02%) - 总线 6000 样本不丢不重(幂等去重) 合成数据集固定随机种子可重复,零外部依赖,CI 可直接执行。 运行:python -m unittest discover -s tests/perf -v
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""压测套件引导:复用 e2e 的内核模块加载逻辑。
|
||||
|
||||
与 tests/e2e/_bootstrap.py 等价:把 edge-gateway 加入 sys.path(裸导入),
|
||||
把 data-bus / rag-kb / llm-gateway 注册为下划线包名(带连字符目录)。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
import os
|
||||
import sys
|
||||
|
||||
_THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
_REPO_ROOT = os.path.abspath(os.path.join(_THIS_DIR, "..", ".."))
|
||||
_CORE_DIR = os.path.join(_REPO_ROOT, "core")
|
||||
|
||||
_EDGE_DIR = os.path.join(_CORE_DIR, "edge-gateway")
|
||||
if os.path.isdir(_EDGE_DIR) and _EDGE_DIR not in sys.path:
|
||||
sys.path.insert(0, _EDGE_DIR)
|
||||
|
||||
|
||||
def _register_dashed_package(pkg_name: str, dir_path: str) -> None:
|
||||
init_file = os.path.join(dir_path, "__init__.py")
|
||||
if not os.path.isfile(init_file) or pkg_name in sys.modules:
|
||||
return
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
pkg_name, init_file, submodule_search_locations=[dir_path]
|
||||
)
|
||||
if spec is None or spec.loader is None:
|
||||
return
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
sys.modules[pkg_name] = module
|
||||
spec.loader.exec_module(module)
|
||||
|
||||
|
||||
_register_dashed_package("data_bus", os.path.join(_CORE_DIR, "data-bus"))
|
||||
_register_dashed_package("rag_kb", os.path.join(_CORE_DIR, "rag-kb"))
|
||||
_register_dashed_package("llm_gateway", os.path.join(_CORE_DIR, "llm-gateway"))
|
||||
Reference in New Issue
Block a user