alibaba / macaca

Automation solution for multi-platform. 多端自动化解决方案
https://macacajs.github.io
MIT License
3.17k stars 419 forks source link

macaca-ios升级到最新版本后socket hang up问题仍然存在 #571

Closed bluesky12345 closed 7 years ago

bluesky12345 commented 7 years ago

端口修改前:

index.js:17:12 [master] pid:34698 webdriver server start with config: { port: 3456, verbose: true, always: true, ip: '10.2.98.140', host: 'ranlideMacBook-Pro.local', loaded_time: '2017-05-21 18:37:38' } middlewares.js:17:10 [master] pid:34698 base middlewares attached router.js:127:10 [master] pid:34698 router set webdriver sdk launched


省略部分日志


macaca-ios.js:151:10 [master] pid:34698 Trying to start xctestwd server... BundleId XCTestWD.XCTestWD does not exist. xctestwd start with port: 8900 xctest-client.js:226:14 [master] pid:34698 xcode version: 8.3.2 XCTestWD version: 1.0.21 xctest-client.js:174:14 [master] pid:34698 2017-05-21 18:37:48.705 xcodebuild[34711:2168292] IDETestOperationsObserverDebug: Writing diagnostic log for test session to: /Users/ranli/Library/Developer/Xcode/DerivedData/XCTestWD-csksfttfbygcrbamoobfasiylmgb/Logs/Test/26A1A138-2396-4A74-8763-85F69922ADD0/Session-XCTestWDUITests-2017-05-21_183748-ojuNLI.log

xctest-client.js:175:14 [master] pid:34698 please check project: /usr/local/lib/node_modules/macaca-ios/node_modules/xctestwd/XCTestWD/XCTestWD.xcodeproj


省略部分日志


xctest-client.js:175:14 [master] pid:34698 please check project: /usr/local/lib/node_modules/macaca-ios/node_modules/xctestwd/XCTestWD/XCTestWD.xcodeproj xctest-client.js:174:14 [master] pid:34698 writeDictToFile:1278 ==== Successfully wrote Manifest cache to /var/folders/_n/sp1mz07j39df6tb2g37v0b4r0000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/5a9aae719511bb65661b0db67cb0cc95/40911ef567d57fcff5813d774fdeb108eaefde1b/ManifestCache.plist

xctest-client.js:175:14 [master] pid:34698 please check project: /usr/local/lib/node_modules/macaca-ios/node_modules/xctestwd/XCTestWD/XCTestWD.xcodeproj xctest-client.js:174:14 [master] pid:34698 2017-05-21 18:38:35.665 xcodebuild[34711:2168287] Error Domain=IDETestOperationsObserverErrorDomain Code=13 "Failed to background test runner. If you believe this error represents a bug, please attach the log file at /Users/ranli/Library/Developer/Xcode/DerivedData/XCTestWD-csksfttfbygcrbamoobfasiylmgb/Logs/Test/26A1A138-2396-4A74-8763-85F69922ADD0/Session-XCTestWDUITests-2017-05-21_183748-ojuNLI.log" UserInfo={NSLocalizedDescription=Failed to background test runner. If you believe this error represents a bug, please attach the log file at /Users/ranli/Library/Developer/Xcode/DerivedData/XCTestWD-csksfttfbygcrbamoobfasiylmgb/Logs/Test/26A1A138-2396-4A74-8763-85F69922ADD0/Session-XCTestWDUITests-2017-05-21_183748-ojuNLI.log}

xctest-client.js:175:14 [master] pid:34698 please check project: /usr/local/lib/node_modules/macaca-ios/node_modules/xctestwd/XCTestWD/XCTestWD.xcodeproj xctest-client.js:174:14 [master] pid:34698 Testing failed: Test target XCTestWDUITests encountered an error (Failed to background test runner. If you believe this error represents a bug, please attach the log file at /Users/ranli/Library/Developer/Xcode/DerivedData/XCTestWD-csksfttfbygcrbamoobfasiylmgb/Logs/Test/26A1A138-2396-4A74-8763-85F69922ADD0/Session-XCTestWDUITests-2017-05-21_183748-ojuNLI.log)

xctest-client.js:175:14 [master] pid:34698 please check project: /usr/local/lib/node_modules/macaca-ios/node_modules/xctestwd/XCTestWD/XCTestWD.xcodeproj xctest-client.js:174:14 [master] pid:34698 TEST FAILED

xctest-client.js:175:14 [master] pid:34698 please check project: /usr/local/lib/node_modules/macaca-ios/node_modules/xctestwd/XCTestWD/XCTestWD.xcodeproj xctest-client.js:257:14 [master] pid:34698 killing deviceLogProc pid: 34708 xctest-client.js:262:14 [master] pid:34698 killing runnerProc pid: 34711 xctest-client.js:268:14 [master] pid:34698 killing iproxyProc pid: 34710 xctest-client.js:185:14 [master] pid:34698 xctest client exit with code: 65, signal: null xctest-client.js:213:14 [master] pid:34698 iproxy exit with code: null, signal: SIGKILL xctest-client.js:147:16 [master] pid:34698 deviceconsole exit with code: null, signal: SIGKILL xctest-client.js:249:14 [master] pid:34698 Fail to start xctest: undefined responseHandler.js:54:12 [master] pid:34698 Send Error Respone to Client: undefined

InternalServerError: Internal Server Error at Object.throw (/usr/local/lib/node_modules/macaca-cli/node_modules/koa/lib/context.js:91:23) at Object.module.exports (/usr/local/lib/node_modules/macaca-cli/node_modules/webdriver-server/lib/server/responseHandler.js:57:17) at module.exports.throw () at onRejected (/usr/local/lib/node_modules/macaca-cli/node_modules/co/index.js:81:24) at process._tickCallback (internal/process/next_tick.js:103:7)

在case代码中初始化webdriverclient时更改端口后仍然出现高概率的连接失败,app-inspector也存在高概率失败: porps.put("proxyPort", 8001);

bluesky12345 commented 7 years ago

补充端口号更改以后概率性失败日志:

xctest-client.js:175:14 [master] pid:39085 please check project: /usr/local/lib/node_modules/macaca-ios/node_modules/xctestwd/XCTestWD/XCTestWD.xcodeproj proxy.js:55:14 [master] pid:39085 Proxy: /wd/hub/session:POST to http://127.0.0.1:8001/wd/hub/session:POST with body: {"desiredCapabilities":{"bundleId":"com.test.iphone","platformName":"ios"}} proxy.js:61:22 [master] pid:39085 xctest client proxy error with: Error: socket hang up proxy.js:61:22 [master] pid:39085 xctest client proxy error with: Error: socket hang up proxy.js:61:22 [master] pid:39085 xctest client proxy error with: Error: socket hang up proxy.js:61:22 [master] pid:39085 xctest client proxy error with: Error: socket hang up proxy.js:61:22 [master] pid:39085 xctest client proxy error with: Error: socket hang up xctest-client.js:174:14 [master] pid:39085 writeDictToFile:1278 ==== Successfully wrote Manifest cache to /var/folders/_n/sp1mz07j39df6tb2g37v0b4r0000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/5a9aae719511bb65661b0db67cb0cc95/40911ef567d57fcff5813d774fdeb108eaefde1b/ManifestCache.plist

xctest-client.js:175:14 [master] pid:39085 please check project: /usr/local/lib/node_modules/macaca-ios/node_modules/xctestwd/XCTestWD/XCTestWD.xcodeproj proxy.js:61:22 [master] pid:39085 xctest client proxy error with: Error: socket hang up proxy.js:61:22 [master] pid:39085 xctest client proxy error with: Error: socket hang up proxy.js:61:22 [master] pid:39085 xctest client proxy error with: Error: socket hang up proxy.js:61:22 [master] pid:39085 xctest client proxy error with: Error: socket hang up proxy.js:61:22 [master] pid:39085 xctest client proxy error with: Error: socket hang up proxy.js:61:22 [master] pid:39085 xctest client proxy error with: Error: socket hang up xctest-client.js:249:14 [master] pid:39085 Fail to start xctest: Error: socket hang up xctest-client.js:257:14 [master] pid:39085 killing deviceLogProc pid: 39094 xctest-client.js:262:14 [master] pid:39085 killing runnerProc pid: 39097 xctest-client.js:268:14 [master] pid:39085 killing iproxyProc pid: 39096 responseHandler.js:54:12 [master] pid:39085 Send Error Respone to Client: Error: socket hang up responseHandler.js:60:14 [master] pid:39085 Error: socket hang up at createHangUpError (_http_client.js:253:15) at Socket.socketOnEnd (_http_client.js:345:23) at emitNone (events.js:91:20) at Socket.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9)

Error: socket hang up at createHangUpError (_http_client.js:253:15) at Socket.socketOnEnd (_http_client.js:345:23) at emitNone (events.js:91:20) at Socket.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9)

xctest-client.js:147:16 [master] pid:39085 deviceconsole exit with code: null, signal: SIGKILL xctest-client.js:213:14 [master] pid:39085 iproxy exit with code: null, signal: SIGKILL xctest-client.js:185:14 [master] pid:39085 xctest client exit with code: null, signal: SIGKILL

SamuelZhaoY commented 7 years ago

@bluesky12345 麻烦查找一下模拟器的错误日志, 这样可以进一步定位问题, 谢谢啦

leemony commented 7 years ago

/usr/local/lib/node_modules/macaca-ios/node_modules/.1.0.22@xctestwd/lib/proxy.js 第13行: proxyPort: 8100, 改为: proxyPort: 8001,

/usr/local/lib/node_modules/macaca-ios/node_modules/.1.0.22@xctestwd/lib/xctest-client.js 第157行: XCTESTWD_PORT=8001 改为 XCTESTWD_PORT=${this.proxyPort}

bluesky12345 commented 7 years ago

@leemony 这个需要我本地修改吗?

leemony commented 7 years ago

嗯我本地改过之后,可以运行了;之前报错跟你一样的

bluesky12345 commented 7 years ago

@leemony macaca再次升级会不会覆盖掉本次修改?

leemony commented 7 years ago

macaca-doctor version: 2.0.0

Node.js checklist:

node env: /usr/local/bin/node node version: v7.6.0

iOS checklist:

Xcode is installed at: /Applications/Xcode.app/Contents/Developer Xcode Command Line Tools is ready, version: 2347. xcodebuild version: 8.3.2 iproxy[usbmuxd] is installed at: /usr/local/bin/iproxy ios_webkit_debug_proxy is installed at: /usr/local/bin/ios_webkit_debug_proxy carthage is installed, version: 0.23.0

Installed driver list: ios: 2.0.9

leemony commented 7 years ago

会的覆盖的,这应该是个bug

bluesky12345 commented 7 years ago

@leemony 好的,我本地先尝试按照你的修改试一下,升级之后再看情况处理吧。谢谢!

Only7 commented 7 years ago

@leemony 我照着改了,仍然有同样的报错

leemony commented 7 years ago

@bluesky12345 @Only7 macaca-ios 和macaca-cli 有重新安装至最新嘛,上面有贴我的环境,都更新到最新了(xctestwd 已更新到1.0.22)

bluesky12345 commented 7 years ago

@leemony 抱歉前一段时间再忙其它事情,没有验证。我参照你的建议修改后出现了InternalServerError错误。我这边macaca的版本是2.0.1。我现在准备卸载重装macaca再验证,谢谢。

xudafeng commented 7 years ago

npm i macaca-ios@2.0.10 -g

Only7 commented 7 years ago

@leemony 是的我的xctestwd是最新1.0.22 之前运行成功过一次,测试机连了次代理关闭后,又开始报同样的错了呢,有解决办法吗?

leemony commented 7 years ago

@Only7 1.0.26

Only7 commented 7 years ago

@leemony 有1.0.26了?怎么更新呢?

leemony commented 7 years ago

@Only7 npm i macaca-ios@2.0.11 -g

Only7 commented 7 years ago

@leemony 升级了 照着您的方法做了两处的修改 运行成功过几次后 又开始报之前同样的错误,您对这个情况了解吗

leemony commented 7 years ago

@Only7 最新版本已经修正了那两处,不用再改了;如果你发现还能改,那你的环境还没有升级

Only7 commented 7 years ago

@leemony 现在发现有时手机重启 可以解决monkey运行问题,有时重启无效,您遇到过这个问题吗?

Only7 commented 7 years ago

找到了解决办法,给大家分享下: brew unlink ios-webkit-debug-proxy brew install ios-webkit-debug-proxy brew link ios-webkit-debug-proxy

zsmjluo commented 7 years ago

@Only7 应该还有问题。我都升级到最新版本还是有这个问题,执行第二个用例就会出现socket hang up。

Only7 commented 7 years ago

@zsmjluo 我多次操作都是成功的呢~

zsmjluo commented 7 years ago

@Only7 你新版本跑真机没问题?

bluesky12345 commented 7 years ago

@Only7 通过对ios-webkit-debug-proxy解决socket hang up问题的原理是什么?不理解。没太懂它和macaca-ios的关系。

lvyanju commented 7 years ago

xctest-client.js:173:14 [master] pid:28978 please check project: /usr/local/lib/node_modules/macaca-ios/node_modules/xctestwd/XCTestWD/XCTestWD.xcodeproj responseHandler.js:11:12 [master] pid:28978 Recieve HTTP Request from Client[2017-07-13 15:46:37]: method: POST url: /wd/hub/session, jsonBody: {"desiredCapabilities":{"proxyPort":8900,"reuse":3,"bundleId":"xxxxx","platformName":"ios","udid":"74fb0836e738b57b44b52da131856d46d661677f","autoAcceptAlerts":true},"port":3456,"host":"127.0.0.1"} session.js:47:10 [master] pid:28978 Creating session, sessionId: 82b103b5-41ea-482e-bd91-8a09ace9ab2f. macaca-ios.js:245:12 [master] pid:28978 App "xxxxx" is already installed. xctest-client.js:52:14 [master] pid:28978 project path: /usr/local/lib/node_modules/macaca-ios/node_modules/xctestwd/XCTestWD/XCTestWD.xcodeproj macaca-ios.js:159:10 [master] pid:28978 { "bundleId": "xxxxxx", "platformName": "ios" } BundleId XCTestWD.XCTestWD does not exist.

macaca client 2.0.4 启动后一直提示 XCTestWD.XCTestWD does not exist.