Repository navigation
诊断模式切换不再把正在退出的旧 logcat 客户端当成外部采集;修两项偶发失败的测试 - #226
Merged
Merged
Conversation
TestDiagnosticCaptureSwitchAndReregisterPreserveOtherClients 偶发失败是产品代码里的竞争。 采集助手换流时结束旧的 adb 客户端,那个进程有一小段「正在退出」:还没变成已结束(Alive 为真), 程序路径和命令行却已经读不出。等待切换的一轮正好赶上这段,ownedCapture 和「助手的子进程」两条 判断都因为读不出路径而不认它,就按外部采集报了「已有其它程序采集 logcat」并提前返回: 打开时日志里多一条误报、命令在切换完成前就返回;关闭时不报,只是提前返回(11-28 CI 两种都出过)。 本机两核加一个空转进程跑 30 次复现了一次,当时打出的被判外部的进程就是状态文件里记的那个客户端, 路径读出来是「拒绝访问」,命令行是「已经退出」。现在扫描里读得到命令行、随后读不到路径的客户端 按「正在离开」处理,这一轮不下结论,下一轮再看。 TestPrepareForCloseFakeAdb 的 offline 几项:测试用的假 adb server 不回 host:version, 每次 adb 调用前的端口探测都要等满 500 ms,一次断开重连(reconnect、get-state、登记、get-state) 在 2 秒的上限里就很紧,本机不加负载 30 次也失败 3 次。假 server 现在照真 adb 回 host:version; offlineRecoverWait 改成变量,测「重试做了什么」的几项把上限挪开,改为等假 adb 记下登记以后又被问过 两次 get-state 再结束;测上限本身的两项只看用时和结果,不再数登记次数。产品里上限仍是 2 秒。 Refs ModAVD/ModAVD#295
假 adb 监听系统随机给的端口,偶尔落进 fakeNetshOut 假设的保留段 50000-50059,summary 就会说 adb server 的端口被保留,TestCollectManagerLogsAdbAndPorts 失败(11-29 合并队列里出过一次)。落进去时占住那个端口再换一个。 Refs ModAVD/ModAVD#295
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.
修两个偶发失败的测试。其中诊断模式那个是产品代码里的竞争,一并修了。
改了什么
诊断模式切换:正在退出的旧客户端不再算外部采集(产品代码)
TestDiagnosticCaptureSwitchAndReregisterPreserveOtherClients偶发失败(ModAVD/ModAVD#295)。采集助手换流时会结束旧的 adb 客户端。这个进程有一小段「正在退出」的时间:它还没变成已结束,
Alive()仍为真,可程序路径和命令行已经读不出来了。waitDiagnosticCaptureRuntime的某一轮正好赶上这段时,ownedCapture和「助手的子进程」两条判断都因为读不出路径而不认它,结果按外部采集处理,提前返回:Enabled:false);Enabled:true)。采集助手自己照样会换流,所以不会丢日志,只是等待提前结束、日志里多一条误报。
改法:扫描时命令行读得到、随后路径读不到的客户端按「正在离开」处理,这一轮不下结论,下一轮再看。真正的外部采集读得到路径,判断不变。
本机复现时临时在这条路径上打了日志:被判成外部的就是状态文件里记的那个客户端,它的父进程是我们的采集助手,读路径得到「拒绝访问」,读命令行得到「已经退出」,
Alive()为真。关机前 offline 重试的测试:不再依赖机器快慢(只改测试,产品里加了一个测试用的变量)
TestPrepareForCloseFakeAdb/offline,_adbd_does_not_answer在 CI 上失败过一次(dropped [kicked:emulator-20080], registered []: want one try),同一个测试的offline,_recovers也失败过一次。host:version。每次 adb 调用前的端口探测(adbProbe)都要等满 500 ms 超时,一次断开重连(reconnect、get-state、登记、get-state)放进 2 秒的上限里就很紧,慢机器上登记还没发出去上限就到了。本机不加负载跑 30 次也失败 3 次(还有offline,_the_try_fits_what_is_left_of_the_timeout的 800 ms 那项)。假 server 现在照真 adb 回host:version,这个测试从约 16 秒降到约 7 秒。offlineRecoverWait由常量改成变量,产品里仍是 2 秒。测「重试做了什么」的几项把上限挪开:offline, recovers等它连上;offline, adbd does not answer等假 adb 记下登记、之后又被问过两次 get-state,再取消,确认只断开一次、只登记一次。测上限本身的两项(新拆出的offline, the try ends after offlineRecoverWait,和offline, the try fits what is left of the timeout,后者的超时改成 3 秒、上限挪开)只看用时和结果,不再数登记次数。TestReregisterFakeAdb里同样写法的offline, adbd does not answer上限是 5 秒,假 server 回了host:version以后余量够,没有改。怎么验证的
gofmt -l .:无输出go vet ./...(windows),GOOS=darwin GOARCH=arm64 go vet ./...,GOOS=linux GOARCH=amd64 go vet ./...:都通过go test -count=1 ./internal/adb ./internal/emu ./internal/i18n:都通过go test -race -count=1 ./internal/adb:通过python -B -I -X utf8 scripts/repo_checks.py:0 failuresTestDiagnosticCaptureSwitchAndReregisterPreserveOtherClients-race30 次,都 0 失败TestPrepareForCloseFakeAdbTestReregisterFakeAdb、TestServerStartsAndScriptServer)、加负载 30 次、-race30 次,都 0 失败诊断模式那个本来就很少出,改前 120 次加负载只出了 1 次,所以改后 0 失败本身不算强证据;判断主要靠复现时拍到的那个进程状态,改法正好针对它。
没验证的
-b main,system,crash,events,kernel。Refs ModAVD/ModAVD#295
问题包测试:假 adb 的端口避开假的保留端口段(后加的一个提交)
TestCollectManagerLogsAdbAndPorts11-29 在合并队列里失败过一次。原因:测试里的假 adb 监听系统随机给的端口,而假的netsh输出把 50000–50059 说成保留段;随机端口正好落进去时(那次是 50054),summary 会写「adb server 的端口在保留范围里」,断言就不成立。现在假 adb 拿到这一段里的端口时先占住、再换一个。只动测试辅助代码;internal/report整包本机通过。