Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cleanup device script #61

Merged
merged 3 commits into from
Jul 3, 2024
Merged

Add cleanup device script #61

merged 3 commits into from
Jul 3, 2024

Conversation

idyatlov
Copy link

@idyatlov idyatlov commented Jul 1, 2024

It will launch if amount of space on device will be less than specified percentage

@@ -4,7 +4,7 @@ object Versions {
val coroutines = "1.7.3"
val ktor = "2.0.3"

val ddmlib = "31.0.2"
val ddmlib = "31.4.2"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use ddmlib similar to our AGP version

info.instrumentationPackage,
info.testRunnerClass,
device.ddmsDevice,
StatusReporterMode.PROTO_STD
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StatusReporterMode.TEXT is deprecated from API 26 and used by default in 3 arguments constructor. StatusReporterMode.PROTO_STD should be better as it will use less data because of binary format rather than text.

import com.malinskiy.marathon.log.MarathonLogConfigurator
import com.malinskiy.marathon.report.logs.LogsProvider
import org.koin.dsl.module

val androidModule = module {
single<TestParser?> { AndroidTestParser() }
single<ComponentInfoExtractor?> { AndroidComponentInfoExtractor() }
single<ComponentCacheKeyProvider?> { AndroidComponentCacheKeyProvider(CachedFileHasher(ApkFileHasher())) }
single<ComponentCacheKeyProvider?> { AndroidComponentCacheKeyProvider(CachedFileHasher(Md5FileHasher())) }
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use MD5 in AndroidAppInstaller.isApkInstalled and in AndroidAppInstaller.getHashOnDevice, so ApkFileHasher is doing nothing. Checking MD5 is really fast and I don't see that it takes even more than a second on the build. We also have a hashmap so it is calculated only once.

logger.info("Installing $appPackage, ${appApk.absolutePath} to ${device.serialNumber}")
val installationStarted = Instant.now()
val installMessage = device.safeInstallPackage(appApk.absolutePath, true, optionalParams(device))
installMessage?.let { logger.debug { it } }
installMessage?.let { logger.info { it } }
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to see as much as we can in the logs related to installation

@idyatlov idyatlov marked this pull request as ready for review July 3, 2024 11:41
@idyatlov idyatlov requested a review from technoir42 July 3, 2024 13:09
@@ -55,6 +55,8 @@ open class MarathonExtension {
//Android specific for now
var autoGrantPermission: Boolean? = null
var instrumentationArgs: MutableMap<String, String> = mutableMapOf()
var cleanupDeviceScript: String? = null
val usedStorageThresholdInPercents: Int? = null

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a var?

@@ -96,6 +97,8 @@ private fun createAndroidConfiguration(
}
}
?: SerialStrategy.AUTOMATIC
val cleanupDeviceScript = extension.cleanupDeviceScript

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this have to be customisable? or is nullability a way to disable the cleanup?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can put default variant here which will remove all test apks

@idyatlov idyatlov merged commit 3881f8d into develop Jul 3, 2024
2 checks passed
@idyatlov idyatlov deleted the add_cleanup_device_script branch July 3, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants