Repository navigation
test(billing): reuse rate resolver and isolate heap checks - #8598
Merged
Merged
Conversation
riofutab
added a commit
to riofutab/sub2api
that referenced
this pull request
Nov 10, 2026
共享 resolver 部分 fork 已有;这里补子进程隔离与 KeepAlive,避免其它测试的后台分配和被测对象提前回收影响断言。
riofutab
added a commit
to riofutab/sub2api
that referenced
this pull request
Nov 10, 2026
- 并入上游已合 PR:Wei-Shaw#8381 Wei-Shaw#8566 Wei-Shaw#8631 Wei-Shaw#8637 Wei-Shaw#8161 Wei-Shaw#8346 Wei-Shaw#8642 Wei-Shaw#8367 Wei-Shaw#8357 Wei-Shaw#8622,Wei-Shaw#8621 仅并测试 - 并入上游开放 PR:Wei-Shaw#8627 单请求最多冷却一个账号、Wei-Shaw#8619 Gemini 兼容下发思考、Wei-Shaw#8596 Wei-Shaw#8597 Wei-Shaw#8598 测试同步 - 新增迁移 249_add_usage_logs_api_key_cost_index_notx,与现有 249 迁移并存 - 后端 unit 测试、golangci-lint、前端 lint/typecheck/全部 vitest 通过;repository 集成测试未跑
Contributor
Author
|
补充一下关联进展:OpenAI 分配测试修复 #8603 已合并。本 PR 的单元、集成测试和 lint 均已通过,计费测试中遗漏共享倍率解析器的问题仍存在于当前 main。 补丁只涉及一个测试文件,保留原有 8 MiB 阈值和全部断言。方便时烦请审阅,谢谢! |
This was referenced Nov 13, 2026
Contributor
|
补充一份 Linux / Go 1.27.4 的独立对照,支持这里的夹具生命周期修复。测试基线为当前
编译与目标执行命令如下(分别设置 GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go test -c -tags=unit -o service.test ./internal/service
GOGC=off GOMAXPROCS=1 ./service.test -test.run='^(TestEstimateInflightReservationCost|TestInflightEstimate_)' -test.count=5 -test.v原 #8843 head 的默认 GC 隔离测试另有 20/20 通过; AI 自治源码核对及本地验证,无人工实施或审阅。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
计费预留的堆内存测试手工创建服务时,遗漏了正式构造函数中的共享倍率解析器,导致每次估算都新建一个带后台清理协程的缓存。20,000 次调用后,这些缓存及协程的异步回收时间会影响 8 MiB 断言;单独运行和整包运行因此可能得到不同结果。
本次只修改
billing_inflight_reservation_test.go:runtime.KeepAlive,让服务及请求对象在测量期间保持存活,防止遗漏附属缓存的真实增长。<8 MiB阈值,以及快照读取和禁止直接查库的全部断言。生产计费路径保持原样。修复前的堆快照指向
go-cache清理协程、ticker 和newUserGroupRateResolver中的缓存创建。验证
故障注入仅通过本地 overlay 运行,不进入提交。测试使用模拟数据、独立本机工具链和网络限制。
Closes #8595
相关独立修复:#8593, #8594。上述完整后端测试在三项修复组合后运行,各分支分别提交。