From 5e76aee4173f6991b2e15256743eb331ba54f44b Mon Sep 17 00:00:00 2001 From: abergfeld Date: Wed, 13 Nov 2019 17:35:07 -0600 Subject: [PATCH] Install sequentially since parallel installs aren't reliable with a lot of devices --- .../kotlin/com/banno/gordon/AdbExtensions.kt | 33 +++++++++---------- .../kotlin/com/banno/gordon/GordonTestTask.kt | 1 - 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/gordon-plugin/src/main/kotlin/com/banno/gordon/AdbExtensions.kt b/gordon-plugin/src/main/kotlin/com/banno/gordon/AdbExtensions.kt index a33f0c4..425bdc2 100644 --- a/gordon-plugin/src/main/kotlin/com/banno/gordon/AdbExtensions.kt +++ b/gordon-plugin/src/main/kotlin/com/banno/gordon/AdbExtensions.kt @@ -52,8 +52,12 @@ internal fun JadbDevice.installApk(apk: File, vararg options: String) = IO.fx { PackageManager(this@installApk).remove(remoteFile) - if (result == null || !result.contains("Success")) { - raiseError(IllegalStateException("Failed to install ${apk.name} on $serial\n$result")).bind() + when { + result == null -> raiseError(IllegalStateException("Install timed out for ${apk.name} on $serial")).bind() + + !result.contains("Success") -> raiseError(IllegalStateException("Failed to install ${apk.name} on $serial\n$result")).bind() + + else -> Unit } } @@ -80,26 +84,21 @@ internal fun List.uninstall( } internal fun List.reinstall( - dispatcher: CoroutineDispatcher, logger: Logger, applicationPackage: String, instrumentationPackage: String, applicationApk: File, instrumentationApk: File ) = IO { - runBlocking { - map { device -> - async(context = dispatcher, start = CoroutineStart.LAZY) { - val packageManager = PackageManager(device) - logger.lifecycle("${device.serial}: installing $applicationPackage") - packageManager.safeUninstall(applicationPackage) - device.installApk(applicationApk, "-d", "-r").unsafeRunSync() - if (instrumentationApk != applicationApk) { - logger.lifecycle("${device.serial}: installing $instrumentationPackage") - packageManager.safeUninstall(instrumentationPackage) - device.installApk(instrumentationApk, "-d", "-r", "-t").unsafeRunSync() - } - } - }.awaitAll() + forEach { device -> + val packageManager = PackageManager(device) + logger.lifecycle("${device.serial}: installing $applicationPackage") + packageManager.safeUninstall(applicationPackage) + device.installApk(applicationApk, "-d", "-r").unsafeRunSync() + if (instrumentationApk != applicationApk) { + logger.lifecycle("${device.serial}: installing $instrumentationPackage") + packageManager.safeUninstall(instrumentationPackage) + device.installApk(instrumentationApk, "-d", "-r", "-t").unsafeRunSync() + } } } diff --git a/gordon-plugin/src/main/kotlin/com/banno/gordon/GordonTestTask.kt b/gordon-plugin/src/main/kotlin/com/banno/gordon/GordonTestTask.kt index 8c711b4..9eb3d3d 100644 --- a/gordon-plugin/src/main/kotlin/com/banno/gordon/GordonTestTask.kt +++ b/gordon-plugin/src/main/kotlin/com/banno/gordon/GordonTestTask.kt @@ -85,7 +85,6 @@ internal abstract class GordonTestTask : DefaultTask() { } pools.flatMap { it.devices }.reinstall( - dispatcher = Dispatchers.Default, logger = logger, applicationPackage = applicationPackage, instrumentationPackage = instrumentationPackage,