Repository navigation
修复两个与时间有关的测试在慢机器上偶发失败 - #170
Merged
Merged
Conversation
TestCaptureWaitIgnoresUnreadablePolicy 的等待上限 10 秒、TestInstallHoldsAllStartLocksThroughCommit 的 5 秒都卡得太紧,改为 2 分钟,仅作防卡死。 后者的轮询还每 10 毫秒打开一次 sdk/emulator 下的文件,会让安装器改名该目录时被拒绝(Access is denied)。改为只用 stat 等待目录换好,再读一次内容;安装线程提前结束时立刻报错。 Refs ModAVD/ModAVD#207
This was referenced Nov 15, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Refs ModAVD/ModAVD#207
为什么失败
两个测试都对时间敏感,慢的 CI 机器上会偶发失败:
internal/emu的TestCaptureWaitIgnoresUnreadablePolicy:waitDiagnosticCapture的上限只给了 10 秒。这个等待每一轮都要扫进程、读状态,那次 CI 里internal/emu整包 121 秒(平常约一半),一轮扫描就能拖到秒级,10 秒不够就返回超时。internal/update的TestInstallHoldsAllStartLocksThroughCommit:有两个原因。os.ReadFile一次sdk/emulator/emulator.exe,文件被打开的瞬间,安装器去改名sdk/emulator目录会被拒绝(Access is denied),安装提前失败。本地-count=30里 0.25 秒就复现了一次,和机器快慢无关,只是慢机器上撞上的概率更大。产品代码没有问题,只改测试。
怎么改
TestInstallHoldsAllStartLocksThroughCommit等待安装推进时不再打开sdk/emulator下的任何文件:改成只用os.Stat看.update/previous/emulator出现、新的sdk/emulator/emulator.exe到位(stat 不持有句柄),之后只读一次内容核对。验证
Windows 本机,
GOCACHE、临时目录都放 E 盘:go vet ./...通过go test ./internal/emu/ ./internal/update/通过-run <名字> -count=30:通过GOMAXPROCS=1,同时另一个进程跑go test -count=1 ./internal/update/ ./internal/avd/,两个测试各-count=30:通过-count=30里失败过一次,就是上面第 2 点的改名被拒,所以才改了轮询方式。