Skip to content

Commit

Permalink
Merge branch 'develop' into docs/split
Browse files Browse the repository at this point in the history
  • Loading branch information
austyh committed Nov 14, 2023
2 parents 7bd6e0b + 6cff8e2 commit 3a663f3
Show file tree
Hide file tree
Showing 32 changed files with 241 additions and 140 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ buildscript {


plugins {
id("io.gitlab.arturbosch.detekt") version "1.23.1"
id("com.github.ben-manes.versions") version "0.47.0"
id("io.gitlab.arturbosch.detekt") version "1.23.3"
id("com.github.ben-manes.versions") version "0.49.0"
}

configure<DetektExtension> {
Expand Down
6 changes: 3 additions & 3 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repositories {
}

dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10")
implementation("com.squareup:kotlinpoet:1.12.0")
implementation("com.google.code.gson:gson:2.10")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10")
implementation("com.squareup:kotlinpoet:1.14.2")
implementation("com.google.code.gson:gson:2.10.1")
}
44 changes: 22 additions & 22 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
object Versions {
val marathon = System.getenv("GIT_TAG_NAME") ?: "0.8.5"

val kotlin = "1.8.20"
val kotlin = "1.9.10"
val coroutines = "1.7.3"
val coroutinesTest = coroutines

val androidCommon = "31.1.0"
val adam = "0.5.1"
val androidCommon = "31.1.3"
val adam = "0.5.2"
val dexTestParser = "2.3.4"
val kotlinLogging = "3.0.5"
val logbackClassic = "1.4.8"
val logbackClassic = "1.4.11"
val axmlParser = "1.0"
val bugsnag = "3.7.0"
val bugsnag = "3.7.1"

val junitGradle = "1.2.0"
val androidGradleVersion = "7.4.1"
val gradlePluginPublish = "1.2.0"
val androidGradleVersion = "8.1.3"
val gradlePluginPublish = "1.2.1"
val gradlePluginShadow = "8.1.1"

val junit5 = "5.10.0"
val junit5 = "5.10.1"
val kluent = "1.73"

val kakao = "3.0.2"
Expand All @@ -27,37 +27,37 @@ object Versions {
val espressoRunner = "1.0.1"
val junit = "4.13.2"
val gson = "2.10.1"
val apacheCommonsText = "1.10.0"
val apacheCommonsText = "1.11.0"
val apacheCommonsIO = "2.11.0"
val apacheCommonsCodec = "1.15"
val okhttp = "4.11.0"
val okhttp = "4.12.0"
val influxDbClient = "2.23"
val influxDb2Client = "6.10.0"
val clikt = "4.1.0"
val jacksonDatabind = "2.15.2"
val clikt = "4.2.1"
val jacksonDatabind = "2.15.3"
val jacksonKotlin = jacksonDatabind
val jacksonYaml = jacksonDatabind
val jacksonJSR310 = jacksonDatabind
val jacksonAnnotations = jacksonDatabind
val ddPlist = "1.27"
val guava = "32.1.1-jre"
val rsync4j = "3.2.7-1"
val sshj = "0.35.0"
val guava = "32.1.3-jre"
val rsync4j = "3.2.7-5"
val sshj = "0.37.0"
val kotlinProcess = "1.4.1"
val testContainers = "1.18.3"
val testContainers = "1.19.1"
val jupiterEngine = junit5
val jansi = "2.4.0"
val jansi = "2.4.1"
val scalr = "4.2"
val allureTestFilter = "2.23.0"
val allureJava = "2.23.0"
val allureTestFilter = "2.24.0"
val allureJava = "2.24.0"
val allureKotlin = "2.4.0"
val allureEnvironment = "1.0.0"
val mockitoKotlin = "2.2.0"
val dokka = "1.8.10"
val koin = "3.4.3"
val dokka = "1.9.10"
val koin = "3.5.0"
val jsonAssert = "1.5.1"
val xmlUnit = "2.9.1"
val assertk = "0.26.1"
val assertk = "0.27.0"
}

object BuildPlugins {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class LogicalConfigurationValidator : ConfigurationValidator {
is VendorConfiguration.IOSConfiguration -> {
configuration.vendorConfiguration.validate()
}
is VendorConfiguration.AndroidConfiguration -> {
configuration.vendorConfiguration.validate()
}

else -> Unit
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ sealed class VendorConfiguration {
@JsonProperty("disableWindowAnimation") val disableWindowAnimation: Boolean = DEFAULT_DISABLE_WINDOW_ANIMATION,
) : VendorConfiguration() {
fun safeAndroidSdk(): File = androidSdk ?: throw ConfigurationException("No android SDK path specified")

fun validate() {
validateFile(applicationOutput)
validateFile(testApplicationOutput)
splitApks?.forEach { validateFile(it) }
extraApplicationsOutput?.forEach { validateFile(it) }
outputs?.forEach {
validateFile(it.application)
validateFile(it.testApplication)
it.splitApks?.forEach { apk -> validateFile(apk) }
it.extraApplications?.forEach { apk -> validateFile(apk) }
}
}

private fun validateFile(file: File?) {
if (file != null) {
if (!file.exists()) throw ConfigurationException("${file.absolutePath} does not exist")
if (!file.isFile) throw ConfigurationException("${file.absolutePath} must be a regular file")
}
}
}

class AndroidConfigurationBuilder {
Expand Down Expand Up @@ -142,6 +162,7 @@ sealed class VendorConfiguration {
@JsonProperty("compactOutput") val compactOutput: Boolean = false,
@JsonProperty("rsync") val rsync: RsyncConfiguration = RsyncConfiguration(),
@JsonProperty("xcodebuildTestArgs") val xcodebuildTestArgs: Map<String, String> = emptyMap(),
@JsonProperty("dataContainerClear") val dataContainerClear: Boolean = false,
@JsonProperty("testParserConfiguration") val testParserConfiguration: com.malinskiy.marathon.config.vendor.ios.TestParserConfiguration = com.malinskiy.marathon.config.vendor.ios.TestParserConfiguration.NmTestParserConfiguration(),

@JsonProperty("signing") val signing: SigningConfiguration = SigningConfiguration(),
Expand Down
11 changes: 10 additions & 1 deletion docs/runner/ios/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ timeoutConfiguration:
screenshot: PT10S
video: PT300S
erase: PT30S
shutdown: PT30S
shutdown: PT30S
delete: PT30S
create: PT30S
boot: PT30S
Expand Down Expand Up @@ -454,6 +454,15 @@ rsync:
remotePath: "/usr/bin/rsync-custom"
```

### Clear state between test batch executions
By default, marathon does not clear state between test batch executions. To mitigate potential test side effects, one could add an option to
clear the container data between test runs. Keep in mind that test side effects might still be present.
If you want to isolate tests even further, then you should consider reducing the batch size.

```yaml
dataContainerClear: true
```

### Test parser

:::tip
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion sample/android-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
}

plugins {
id("com.github.ben-manes.versions") version "0.47.0"
id("com.github.ben-manes.versions") version "0.49.0"
}

fun isNonStable(version: String): Boolean {
Expand Down
10 changes: 5 additions & 5 deletions sample/android-app/buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
object Versions {
val kotlin = "1.8.10"
val coroutines = "1.6.4"
val kotlin = "1.9.10"
val coroutines = "1.7.3"

val androidGradleVersion = "7.4.1"
val androidGradleVersion = "8.1.3"

val kakao = "3.2.3"
val kakao = "3.4.1"
val espresso = "3.5.1"
val espressoRules = "1.5.0"
val espressoRunner = "1.5.2"
Expand All @@ -13,7 +13,7 @@ object Versions {
val appCompat = "1.6.1"
val constraintLayout = "2.1.4"
val allure = "2.4.0"
val adam = "0.5.0"
val adam = "0.5.2"
}

object BuildPlugins {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 1 addition & 0 deletions sample/android-cucumber-app/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
}

android {
namespace = "com.example.cucumber"
buildToolsVersion = "30.0.3"
compileSdk = 33

Expand Down
2 changes: 1 addition & 1 deletion sample/android-cucumber-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
}

plugins {
id("com.github.ben-manes.versions") version "0.47.0"
id("com.github.ben-manes.versions") version "0.49.0"
}

fun isNonStable(version: String): Boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object Versions {
val kotlin = "1.8.10"
val kotlin = "1.9.10"

val androidGradleVersion = "7.4.1"
val androidGradleVersion = "8.1.3"

val cucumber = "4.9.0"
val cucumberPicocontainer = "4.8.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion sample/android-library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
}

plugins {
id("com.github.ben-manes.versions") version "0.47.0"
id("com.github.ben-manes.versions") version "0.49.0"
}

fun isNonStable(version: String): Boolean {
Expand Down
7 changes: 3 additions & 4 deletions sample/android-library/buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
object Versions {
val kotlin = "1.8.10"
val coroutines = "1.6.4"

val androidGradleVersion = "7.4.1"
val kotlin = "1.9.10"
val coroutines = "1.7.3"
val androidGradleVersion = "8.1.3"
val espressoRunner = "1.5.2"
val testJunit = "1.1.5"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 1 addition & 0 deletions sample/android-library/library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
}

android {
namespace = "com.example.library"
buildToolsVersion = "30.0.3"
compileSdk = 33

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,15 @@ abstract class BaseAndroidDevice(
}

private suspend fun detectFeatures(): List<DeviceFeature> {
val hasScreenRecord = when {
val screenRecordSupport = when {
!version.isGreaterOrEqualThan(19) -> false
else -> hasBinary("/system/bin/screenrecord")
}
val videoSupport = hasScreenRecord && manufacturer != "Genymotion"
val screenshotSupport = version.isGreaterOrEqualThan(AndroidVersion.VersionCodes.JELLY_BEAN)

val features = mutableListOf<DeviceFeature>()

if (videoSupport) features.add(DeviceFeature.VIDEO)
if (screenRecordSupport) features.add(DeviceFeature.VIDEO)
if (screenshotSupport) features.add(DeviceFeature.SCREENSHOT)
return features
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class AdamDeviceProvider(
private val socketFactory = VertxSocketFactory(idleTimeout = vendorConfiguration.timeoutConfiguration.socketIdleTimeout.toMillis())
private val logcatManager: LogcatManager = LogcatManager()
private lateinit var deviceEventsChannel: ReceiveChannel<Pair<AndroidDebugBridgeClient, List<Device>>>
private var deviceEventsChannelInitialized = false
private val deviceEventsChannelMutex = Mutex()
private val multiServerDeviceStateTracker = MultiServerDeviceStateTracker()

Expand Down Expand Up @@ -132,6 +133,7 @@ class AdamDeviceProvider(
}
}
}
deviceEventsChannelInitialized = true
}
for ((client, currentDeviceList) in deviceEventsChannel) {
multiServerDeviceStateTracker.update(client, currentDeviceList).forEach { update ->
Expand Down Expand Up @@ -160,6 +162,7 @@ class AdamDeviceProvider(
devices[serial] = ProvidedDevice(device, job)
}
}

TrackingUpdate.DISCONNECTED -> {
devices[serial]?.let { (device, job) ->
if (job.isActive) {
Expand All @@ -169,6 +172,7 @@ class AdamDeviceProvider(
device.dispose()
}
}

TrackingUpdate.NOTHING_TO_DO -> Unit
}
logger.debug { "Device $serial changed state to $state" }
Expand All @@ -180,7 +184,7 @@ class AdamDeviceProvider(

override suspend fun borrow(): AdamAndroidDevice {
var availableDevices = devices.filter { it.value.setupJob.isCompleted && !it.value.setupJob.isCancelled }
while(availableDevices.isEmpty()) {
while (availableDevices.isEmpty()) {
delay(200)
availableDevices = devices.filter { it.value.setupJob.isCompleted && !it.value.setupJob.isCancelled }
}
Expand All @@ -198,7 +202,9 @@ class AdamDeviceProvider(
providerJob?.cancel()
channel.close()
deviceEventsChannelMutex.withLock {
deviceEventsChannel.cancel()
if (deviceEventsChannelInitialized) {
deviceEventsChannel.cancel()
}
}
logcatManager.close()
socketFactory.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.malinskiy.marathon.config.vendor.VendorConfiguration
import com.malinskiy.marathon.config.vendor.ios.TestType
import com.malinskiy.marathon.exceptions.DeviceSetupException
import com.malinskiy.marathon.execution.withRetry
import com.malinskiy.marathon.ios.extensions.testBundle
import com.malinskiy.marathon.ios.model.Sdk
import com.malinskiy.marathon.ios.xctestrun.TestRootFactory
import com.malinskiy.marathon.log.MarathonLogging
Expand All @@ -18,14 +19,13 @@ class AppleApplicationInstaller(
private val logger = MarathonLogging.logger {}

suspend fun prepareInstallation(device: AppleSimulatorDevice, useXctestParser: Boolean = false) {
val bundle = vendorConfiguration.bundle ?: throw ConfigurationException("no xctest found for configuration")
val bundle = vendorConfiguration.testBundle() ?: throw ConfigurationException("no xctest found for configuration")

val xctest = bundle.xctest
val xctest = bundle.testApplication
logger.debug { "Moving xctest to ${device.serialNumber}" }
val remoteXctest = device.remoteFileManager.remoteXctestFile()
withRetry(3, 1000L) {
device.remoteFileManager.createRemoteDirectory()
val remoteDirectory = device.remoteFileManager.remoteDirectory()
if (!device.pushFolder(xctest, remoteXctest)) {
throw DeviceSetupException("Error transferring $xctest to ${device.serialNumber}")
}
Expand All @@ -47,7 +47,7 @@ class AppleApplicationInstaller(
TestRootFactory(device, vendorConfiguration).generate(testType, bundle, useXctestParser)
grantPermissions(device)

bundle.extraApplications?.forEach {
vendorConfiguration.bundle?.extraApplications?.forEach {
if (it.isDirectory && it.extension == "app") {
logger.debug { "Installing extra application $it to ${device.serialNumber}" }
val remoteExtraApplication = device.remoteFileManager.remoteExtraApplication(it.name)
Expand Down
Loading

0 comments on commit 3a663f3

Please sign in to comment.