解决 openstf 只能识别75台设备的问题

via https://github.com/openstf/stf/issues/693

Openstf 只能识别75台可用设备,而 adb 能识别到120个。后来查到错误日志如下:

```text
19-03-01T09:36:07.858Z FTL/device 1052 [048e0dc8251bd9fd] Setup had an error RangeError: "port" argument must be >= 0 and < 65536 at assertPort (internal/net.js:17:11) at Server.listen (net.js:1394:5) at WebSocketServer (/app/node_modules/ws/lib/WebSocketServer.js:76:20) at createServer (/app/lib/units/device/plugins/screen/stream.js:427:17) at /app/lib/units/device/plugins/screen/stream.js:451:12 at SerialSyrup.ParallelSyrup.invoke (/app/node_modules/stf-syrup/lib/parallel.js:54:24) at /app/node_modules/stf-syrup/lib/serial.js:43:33 at tryCatch1 (/app/node_modules/stf-syrup/node_modules/bluebird/js/main/util.js:63:19) at Promise$_callHandler [as _callHandler] (/app/node_modules/stf-syrup/node_modules/bluebird/js/main/promise.js:708:13) at Promise$_settlePromiseFromHandler [as _settlePromiseFromHandler] (/app/node_modules/stf-syrup/node_modules/bluebird/js/main/promise.js:724:18) at Promise$_settlePromiseAt [as _settlePromiseAt] (/app/node_modules/stf-syrup/node_modules/bluebird/js/main/promise.js:896:14) at Promise$_fulfillPromises [as _fulfillPromises] (/app/node_modules/stf-syrup/node_modules/bluebird/js/main/promise.js:1041:14) at Async$_consumeFunctionBuffer [as _consumeFunctionBuffer] (/app/node_modules/stf-syrup/node_modules/bluebird/js/main/async.js:74:12) at Async$consumeFunctionBuffer (/app/node_modules/stf-syrup/node_modules/bluebird/js/main/async.js:37:14) at _combinedTickCallback (internal/process/next_tick.js:73:7) at process._tickCallback (internal/process/next_tick.js:104:9) 2019-03-01T09:36:07.860Z FTL/util:lifecycle 1052 [048e0dc8251bd9fd] Shutting down due to fatal error
```

跟踪到一个 issue,问题应该是可用端口数不足,一个设备默认需要4个端口,stf 默认的端口数是300,解决办法是修改参数,或者修改代码中的默认值。

lib/cli/local/index.js
```js
 .option('provider-max-port', { describe: 'Highest port number for device workers to use.' , type: 'number' , default: 7900 }) .option('provider-min-port', { describe: 'Lowest port number for device workers to use.' , type: 'number' , default: 7400 })
```

发表评论

电子邮件地址不会被公开。