Skip to content

Commit

Permalink
Merge pull request #925 from MarathonLabs/feature/cap-install-paralle…
Browse files Browse the repository at this point in the history
…lism

feat(android): limit installation push parallelism
  • Loading branch information
Malinskiy authored Apr 26, 2024
2 parents b1f4fd6 + 7eaaf10 commit e23adf3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ package com.malinskiy.marathon.config.vendor.android

data class ThreadingConfiguration(
val bootWaitingThreads: Int = 4,
val adbIoThreads: Int = 4
val adbIoThreads: Int = 4,
val installThreads: Int = 8,
)
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,15 @@ import java.awt.image.BufferedImage
import java.io.File
import java.time.Duration
import java.util.concurrent.CopyOnWriteArrayList
import kotlin.coroutines.CoroutineContext
import com.malinskiy.marathon.android.model.ShellCommandResult as MarathonShellCommandResult

class AdamAndroidDevice(
internal val client: AndroidDebugBridgeClient,
private val deviceStateTracker: DeviceStateTracker,
private val logcatManager: LogcatManager,
private val testBundleIdentifier: AndroidTestBundleIdentifier,
private val installContext: CoroutineContext,
adbSerial: String,
configuration: Configuration,
androidConfiguration: VendorConfiguration.AndroidConfiguration,
Expand Down Expand Up @@ -199,7 +201,7 @@ class AdamAndroidDevice(
try {
measureFileTransfer(File(localFilePath)) {
val channel = client.execute(
CompatPushFileRequest(file, remoteFilePath, supportedFeatures, coroutineScope = this),
CompatPushFileRequest(file, remoteFilePath, supportedFeatures, coroutineScope = this, mode = "0777", coroutineContext = installContext),
serial = adbSerial
)
for (update in channel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.malinskiy.marathon.exceptions.NoDevicesException
import com.malinskiy.marathon.log.MarathonLogging
import com.malinskiy.marathon.time.Timer
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancel
Expand Down Expand Up @@ -53,6 +54,7 @@ class AdamDeviceProvider(
private val channel: Channel<DeviceProvider.DeviceEvent> = unboundedChannel()

private val dispatcher = newFixedThreadPoolContext(1, "DeviceMonitor")
private val installDispatcher = Dispatchers.IO.limitedParallelism(vendorConfiguration.threadingConfiguration.installThreads)
override val coroutineContext = dispatcher + newCoroutineExceptionHandler(logger)

private val setupSupervisor = SupervisorJob()
Expand Down Expand Up @@ -142,6 +144,7 @@ class AdamDeviceProvider(
multiServerDeviceStateTracker.getTracker(client),
logcatManager,
testBundleIdentifier,
installDispatcher,
serial,
configuration,
vendorConfiguration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.malinskiy.marathon.config.Configuration
import com.malinskiy.marathon.config.vendor.VendorConfiguration
import com.malinskiy.marathon.config.vendor.android.SerialStrategy
import com.malinskiy.marathon.time.SystemTimer
import kotlinx.coroutines.Dispatchers
import java.time.Clock

object TestDeviceFactory {
Expand All @@ -17,6 +18,7 @@ object TestDeviceFactory {
deviceStateTracker = DeviceStateTracker(),
logcatManager = logcatManager,
AndroidTestBundleIdentifier(),
Dispatchers.IO,
"emulator-5554",
configuration,
configuration.vendorConfiguration as VendorConfiguration.AndroidConfiguration,
Expand Down

0 comments on commit e23adf3

Please sign in to comment.