-
Notifications
You must be signed in to change notification settings - Fork 315
Description
概述
运行完整测试套件后出现 17 个测试失败 + 1 个错误。经分析,根因为 4 个生产代码 bug 和 5 个测试代码 bug。
生产代码 Bug
1. L2 向量搜索结果排序方向反了(严重)
失败测试:
tests/vectordb/test_recall.py::TestRecall::test_exact_match_recalltests/vectordb/test_recall.py::TestRecall::test_l2_recall_topktests/vectordb/test_openviking_vectordb.py::TestOpenVikingVectorDB::test_filters_update_delete_recall
位置: openviking/storage/vectordb/index/local_index.py:97-100
C++ 引擎对所有距离类型都按 score 降序返回结果。对 IP(内积)这是正确的,但对 L2(欧氏距离)是错误的 —— L2 应按升序排列(距离越小越相似)。Python 层 IndexEngineProxy.search() 直接透传结果,没有做任何修正。
影响: 所有基于 L2 距离的本地向量搜索返回的是最不相关的结果。Recall@10 = 0.0。
2. active_count 更新使用了错误的 ID 计算公式
失败测试:
tests/session/test_session_commit.py::TestCommit::test_active_count_incremented_after_commit
位置: openviking/session/session.py:313 vs openviking/storage/collection_schemas.py:204-208
记录存储时 ID = md5(f"{account_id}:{owner_space}:{uri}"),但 _update_active_counts() 查找时用的是 ID = md5(uri)。两个 ID 永远不匹配,storage.get() 始终返回空列表。
影响: session commit 后 active_count 永远不会递增。
3. AddResourceRequest.path 错误标记为 Optional
失败测试:
tests/server/test_error_scenarios.py::test_missing_required_field
位置: openviking/server/routers/resources.py:25
path: Optional[str] = None —— Pydantic 视为可选字段,缺少 path 的请求不会被拒绝,返回 200 而非 422。
4. get_queue_manager() 调用 init_queue_manager() 时缺少必选参数 agfs
失败测试:
tests/misc/test_debug_service.py::TestObserverService::test_system_property_without_dependencies
位置: openviking/storage/queuefs/queue_manager.py:58 + openviking/service/debug_service.py:82-84
QueueManager 单例未初始化时,get_queue_manager() 无参调用 init_queue_manager(),但 agfs 是必选参数。同时 debug_service.py 的 queue 属性缺少 vikingdb/vlm 属性那样的 "未初始化" 防御性检查。
测试代码 Bug
5. test_read_content —— URI 重复拼接
失败测试:
tests/server/test_api_content.py::test_read_content
ls(simple=True) 现在返回完整 URI,但测试仍在做 parent_uri + "/" + children[0] 拼接,导致路径变成 viking://resources/sample/viking://resources/sample/sample.md。
6. test_mkdir —— _make_viking_fs() 绕过了 __init__
失败测试:
tests/misc/test_mkdir.py::TestMkdir::test_mkdir_calls_agfs_mkdirtests/misc/test_mkdir.py::TestMkdir::test_mkdir_exist_ok_true_existingtests/misc/test_mkdir.py::TestMkdir::test_mkdir_exist_ok_true_not_existingtests/misc/test_mkdir.py::TestMkdir::test_mkdir_exist_ok_false_defaulttests/misc/test_mkdir.py::TestMkdir::test_mkdir_ensures_parents_first
使用 VikingFS.__new__() 跳过了 __init__,导致 _bound_ctx(contextvars.ContextVar)从未被创建。
7. test_tree_builder_dedup —— mock _stat 函数签名不匹配
失败测试:
tests/misc/test_tree_builder_dedup.py::TestResolveUniqueUri::test_single_conflicttests/misc/test_tree_builder_dedup.py::TestResolveUniqueUri::test_multiple_conflictstests/misc/test_tree_builder_dedup.py::TestResolveUniqueUri::test_max_attempts_exceededtests/misc/test_tree_builder_dedup.py::TestResolveUniqueUri::test_gap_in_sequence
mock 函数 _stat(uri) 不接受 ctx 关键字参数。生产代码调用 stat(u, ctx=ctx) 时触发 TypeError,被 except Exception 静默吞掉,导致 _exists() 始终返回 False。
8. test_full_workflow —— 访问不存在的 is_leaf 属性
失败测试:
tests/integration/test_full_workflow.py::TestResourceToSearchWorkflow::test_add_search_read_workflow
测试访问 search_result.resources[0].is_leaf,但 MatchedContext 类没有 is_leaf 字段。
9. test_http_integration —— event loop 已关闭
错误:
tests/integration/test_http_integration.py::TestAsyncHTTPClientIntegration::test_session_via_client
RuntimeError: Event loop is closed —— 异步测试基础设施的生命周期管理问题。
Metadata
Metadata
Assignees
Labels
Type
Projects
Status