mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 16:13:24 +02:00
Add timeouts everywhere. Should help if the ADB socket gets stuck like it sometimes does.
This commit is contained in:
@@ -12,6 +12,7 @@ module.exports = syrup()
|
||||
|
||||
log.info('Fetching browser list')
|
||||
return input.getBrowsers()
|
||||
.timeout(15000)
|
||||
.then(function(browsers) {
|
||||
var icons = Object.create(null)
|
||||
|
||||
|
||||
@@ -27,12 +27,14 @@ module.exports = syrup.serial()
|
||||
function openService() {
|
||||
log.info('Launching HTTP API')
|
||||
return devutil.ensureUnusedPort(adb, options.serial, service.port)
|
||||
.timeout(10000)
|
||||
.then(function() {
|
||||
return adb.shell(options.serial, [
|
||||
remote.bin
|
||||
, '--lib', remote.lib
|
||||
, '--listen-http', service.port
|
||||
])
|
||||
.timeout(10000)
|
||||
.then(function(out) {
|
||||
lifecycle.share('Remote shell', out)
|
||||
streamutil.talk(log, 'Remote shell says: "%s"', out)
|
||||
@@ -40,6 +42,7 @@ module.exports = syrup.serial()
|
||||
.then(function() {
|
||||
return devutil.waitForPort(adb, options.serial, service.port)
|
||||
})
|
||||
.timeout(20000)
|
||||
.then(function(conn) {
|
||||
var ours = options.ports.pop()
|
||||
, everyones = options.ports.pop()
|
||||
@@ -62,6 +65,7 @@ module.exports = syrup.serial()
|
||||
, util.format('tcp:%d', ours)
|
||||
, util.format('tcp:%d', service.port)
|
||||
)
|
||||
.timeout(10000)
|
||||
.then(function() {
|
||||
log.info(
|
||||
'Opening HTTP API proxy on "http://%s:%s"'
|
||||
@@ -113,6 +117,7 @@ module.exports = syrup.serial()
|
||||
)
|
||||
, json: true
|
||||
})
|
||||
.timeout(10000)
|
||||
.then(function(args) {
|
||||
var display = args[1]
|
||||
assert.ok('id' in display, 'Invalid response from HTTP API')
|
||||
|
||||
@@ -37,9 +37,11 @@ module.exports = syrup.serial()
|
||||
function openAgent() {
|
||||
log.info('Launching input agent')
|
||||
return stopAgent()
|
||||
.timeout(15000)
|
||||
.then(function() {
|
||||
return devutil.ensureUnusedPort(adb, options.serial, agent.port)
|
||||
})
|
||||
.timeout(10000)
|
||||
.then(function() {
|
||||
return adb.shell(options.serial, util.format(
|
||||
"export CLASSPATH='%s'; exec app_process /system/bin '%s'"
|
||||
@@ -47,6 +49,7 @@ module.exports = syrup.serial()
|
||||
, apk.main
|
||||
))
|
||||
})
|
||||
.timeout(10000)
|
||||
.then(function(out) {
|
||||
lifecycle.share('InputAgent shell', out)
|
||||
streamutil.talk(log, 'InputAgent says: "%s"', out)
|
||||
@@ -54,6 +57,7 @@ module.exports = syrup.serial()
|
||||
.then(function() {
|
||||
return devutil.waitForPort(adb, options.serial, agent.port)
|
||||
})
|
||||
.timeout(10000)
|
||||
.then(function(conn) {
|
||||
agent.socket = conn
|
||||
agent.writer = new ms.DelimitingStream()
|
||||
@@ -76,22 +80,26 @@ module.exports = syrup.serial()
|
||||
'am startservice --user 0 %s'
|
||||
, intent
|
||||
))
|
||||
.timeout(15000)
|
||||
.then(function(out) {
|
||||
return streamutil.findLine(out, /^Error/)
|
||||
.finally(function() {
|
||||
out.end()
|
||||
})
|
||||
.timeout(10000)
|
||||
.then(function(line) {
|
||||
if (line.indexOf('--user') !== -1) {
|
||||
return adb.shell(options.serial, util.format(
|
||||
'am startservice %s'
|
||||
, intent
|
||||
))
|
||||
.timeout(15000)
|
||||
.then(function() {
|
||||
return streamutil.findLine(out, /^Error/)
|
||||
.finally(function() {
|
||||
out.end()
|
||||
})
|
||||
.timeout(10000)
|
||||
.then(function(line) {
|
||||
throw new Error(util.format(
|
||||
'Service had an error: "%s"'
|
||||
@@ -119,15 +127,18 @@ module.exports = syrup.serial()
|
||||
function openService() {
|
||||
log.info('Launching input service')
|
||||
return stopService()
|
||||
.timeout(15000)
|
||||
.then(function() {
|
||||
return devutil.waitForPortToFree(adb, options.serial, service.port)
|
||||
})
|
||||
.timeout(10000)
|
||||
.then(function() {
|
||||
return callService(util.format("-a '%s'", apk.startAction))
|
||||
})
|
||||
.then(function() {
|
||||
return devutil.waitForPort(adb, options.serial, service.port)
|
||||
})
|
||||
.timeout(15000)
|
||||
.then(function(conn) {
|
||||
service.socket = conn
|
||||
service.reader = conn.pipe(new ms.DelimitedStream())
|
||||
@@ -159,6 +170,7 @@ module.exports = syrup.serial()
|
||||
apk.serviceProto.RequestType.VERSION
|
||||
, new apk.serviceProto.VersionRequest()
|
||||
)
|
||||
.timeout(10000)
|
||||
.then(function(data) {
|
||||
var response = apk.serviceProto.VersionResponse.decode(data)
|
||||
if (response.success) {
|
||||
@@ -173,6 +185,7 @@ module.exports = syrup.serial()
|
||||
apk.serviceProto.RequestType.SET_KEYGUARD_STATE
|
||||
, new apk.serviceProto.SetKeyguardStateRequest(false)
|
||||
)
|
||||
.timeout(10000)
|
||||
.then(function(data) {
|
||||
var response = apk.serviceProto.SetKeyguardStateResponse.decode(data)
|
||||
if (!response.success) {
|
||||
@@ -186,6 +199,7 @@ module.exports = syrup.serial()
|
||||
apk.serviceProto.RequestType.SET_KEYGUARD_STATE
|
||||
, new apk.serviceProto.SetKeyguardStateRequest(true)
|
||||
)
|
||||
.timeout(10000)
|
||||
.then(function(data) {
|
||||
var response = apk.serviceProto.SetKeyguardStateResponse.decode(data)
|
||||
if (!response.success) {
|
||||
@@ -199,6 +213,7 @@ module.exports = syrup.serial()
|
||||
apk.serviceProto.RequestType.SET_WAKE_LOCK
|
||||
, new apk.serviceProto.SetWakeLockRequest(true)
|
||||
)
|
||||
.timeout(10000)
|
||||
.then(function(data) {
|
||||
var response = apk.serviceProto.SetWakeLockResponse.decode(data)
|
||||
if (!response.success) {
|
||||
@@ -212,6 +227,7 @@ module.exports = syrup.serial()
|
||||
apk.serviceProto.RequestType.SET_WAKE_LOCK
|
||||
, new apk.serviceProto.SetWakeLockRequest(false)
|
||||
)
|
||||
.timeout(10000)
|
||||
.then(function(data) {
|
||||
var response = apk.serviceProto.SetWakeLockResponse.decode(data)
|
||||
if (!response.success) {
|
||||
@@ -225,6 +241,7 @@ module.exports = syrup.serial()
|
||||
apk.serviceProto.RequestType.IDENTIFY
|
||||
, new apk.serviceProto.IdentifyRequest(options.serial)
|
||||
)
|
||||
.timeout(10000)
|
||||
.then(function(data) {
|
||||
var response = apk.serviceProto.IdentifyResponse.decode(data)
|
||||
if (!response.success) {
|
||||
@@ -241,6 +258,7 @@ module.exports = syrup.serial()
|
||||
, text
|
||||
)
|
||||
)
|
||||
.timeout(10000)
|
||||
.then(function(data) {
|
||||
var response = apk.serviceProto.SetClipboardResponse.decode(data)
|
||||
if (!response.success) {
|
||||
@@ -256,6 +274,7 @@ module.exports = syrup.serial()
|
||||
apk.serviceProto.ClipboardType.TEXT
|
||||
)
|
||||
)
|
||||
.timeout(10000)
|
||||
.then(function(data) {
|
||||
var response = apk.serviceProto.GetClipboardResponse.decode(data)
|
||||
if (response.success) {
|
||||
@@ -273,6 +292,7 @@ module.exports = syrup.serial()
|
||||
apk.serviceProto.RequestType.GET_BROWSERS
|
||||
, new apk.serviceProto.GetBrowsersRequest()
|
||||
)
|
||||
.timeout(15000)
|
||||
.then(function(data) {
|
||||
var response = apk.serviceProto.GetBrowsersResponse.decode(data)
|
||||
if (response.success) {
|
||||
|
||||
@@ -49,6 +49,7 @@ module.exports = syrup.serial()
|
||||
var target = '/data/local/tmp/_app.apk'
|
||||
|
||||
return adb.push(options.serial, source, target)
|
||||
.timeout(10000)
|
||||
.then(function(transfer) {
|
||||
var resolver = Promise.defer()
|
||||
|
||||
@@ -93,6 +94,7 @@ module.exports = syrup.serial()
|
||||
sendProgress('Installing app', 80)
|
||||
return adb.installRemote(options.serial, apk)
|
||||
})
|
||||
.timeout(10000)
|
||||
.then(function() {
|
||||
if (message.launchActivity) {
|
||||
log.info(
|
||||
@@ -105,6 +107,7 @@ module.exports = syrup.serial()
|
||||
return adb.startActivity(options.serial, message.launchActivity)
|
||||
}
|
||||
})
|
||||
.timeout(15000)
|
||||
.then(function() {
|
||||
push.send([
|
||||
channel
|
||||
|
||||
@@ -16,6 +16,7 @@ module.exports = syrup.serial()
|
||||
function openService() {
|
||||
log.info('Launching logcat service')
|
||||
return adb.openLogcat(options.serial)
|
||||
.timeout(10000)
|
||||
.then(function(logcat) {
|
||||
return lifecycle.share('Logcat', logcat)
|
||||
})
|
||||
|
||||
@@ -19,6 +19,7 @@ module.exports = syrup.serial()
|
||||
log.info('Running shell command "%s"', message.command)
|
||||
|
||||
adb.shell(options.serial, message.command)
|
||||
.timeout(10000)
|
||||
.then(function(stream) {
|
||||
var resolver = Promise.defer()
|
||||
, timer
|
||||
|
||||
@@ -17,6 +17,7 @@ module.exports = syrup.serial()
|
||||
|
||||
function openService() {
|
||||
return devutil.ensureUnusedPort(adb, options.serial, service.port)
|
||||
.timeout(10000)
|
||||
.then(function() {
|
||||
return adb.shell(options.serial, [
|
||||
remote.bin
|
||||
@@ -28,9 +29,11 @@ module.exports = syrup.serial()
|
||||
streamutil.talk(log, 'Stats shell says: "%s"', out)
|
||||
})
|
||||
})
|
||||
.timeout(10000)
|
||||
.then(function() {
|
||||
return devutil.waitForPort(adb, options.serial, service.port)
|
||||
})
|
||||
.timeout(15000)
|
||||
.then(function(conn) {
|
||||
return lifecycle.share('Stats connection', conn)
|
||||
})
|
||||
|
||||
@@ -22,6 +22,7 @@ module.exports = syrup.serial()
|
||||
function openService() {
|
||||
log.info('Launching touch service')
|
||||
return devutil.ensureUnusedPort(adb, options.serial, service.port)
|
||||
.timeout(10000)
|
||||
.then(function() {
|
||||
return adb.shell(options.serial, [
|
||||
remote.bin
|
||||
@@ -29,6 +30,7 @@ module.exports = syrup.serial()
|
||||
, '--listen-input', service.port
|
||||
])
|
||||
})
|
||||
.timeout(10000)
|
||||
.then(function(out) {
|
||||
lifecycle.share('Touch shell', out)
|
||||
streamutil.talk(log, 'Touch shell says: "%s"', out)
|
||||
@@ -36,6 +38,7 @@ module.exports = syrup.serial()
|
||||
.then(function() {
|
||||
return devutil.waitForPort(adb, options.serial, service.port)
|
||||
})
|
||||
.timeout(15000)
|
||||
.then(function(conn) {
|
||||
return Promise.promisifyAll(monkey.connectStream(conn))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user