Skip to content

Commit

Permalink
feat(ios): dynamic provider (#975)
Browse files Browse the repository at this point in the history
* feat(ios): dynamic provider

* feat(ios): dynamic provider

* feat(ios): dynamic provider fixes

* feat(ios): dynamic provider fixes

* fix(ios): fix tests

* feat(ios): add debug info for simulator count

---------

Co-authored-by: eugene_matsyuk <[email protected]>
  • Loading branch information
Malinskiy and matzuk authored Oct 18, 2024
1 parent 56693c9 commit 16c55ad
Show file tree
Hide file tree
Showing 22 changed files with 740 additions and 60 deletions.
2 changes: 2 additions & 0 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ object Versions {
val apacheCommonsText = "1.12.0"
val apacheCommonsIO = "2.17.0"
val okhttp = "4.12.0"
val ktor = "2.3.6"
val influxDbClient = "2.24"
val influxDb2Client = "7.2.0"
val clikt = "5.0.0"
Expand Down Expand Up @@ -95,6 +96,7 @@ object Libraries {
val bugsnag = "com.bugsnag:bugsnag:${Versions.bugsnag}"
val kotlinProcess = "com.github.pgreze:kotlin-process:${Versions.kotlinProcess}"
val okhttp = "com.squareup.okhttp3:okhttp:${Versions.okhttp}"
val ktorNetwork = "io.ktor:ktor-network:${Versions.ktor}"
}

object TestLibraries {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.malinskiy.marathon.config.vendor.android.TestAccessConfiguration
import com.malinskiy.marathon.config.vendor.android.TestParserConfiguration
import com.malinskiy.marathon.config.vendor.android.ThreadingConfiguration
import com.malinskiy.marathon.config.vendor.apple.AppleTestBundleConfiguration
import com.malinskiy.marathon.config.vendor.apple.DeviceProvider
import com.malinskiy.marathon.config.vendor.apple.ios.LifecycleConfiguration
import com.malinskiy.marathon.config.vendor.apple.ios.PermissionsConfiguration
import com.malinskiy.marathon.config.vendor.apple.RsyncConfiguration
Expand Down Expand Up @@ -155,6 +156,7 @@ sealed class VendorConfiguration {
*/
data class IOSConfiguration(
@JsonProperty("bundle") val bundle: AppleTestBundleConfiguration? = null,
@JsonProperty("deviceProvider") val deviceProvider: DeviceProvider = DeviceProvider.Static(),
@JsonProperty("devices") val devicesFile: File? = null,
@JsonProperty("ssh") val ssh: SshConfiguration = SshConfiguration(),

Expand Down Expand Up @@ -186,6 +188,7 @@ sealed class VendorConfiguration {

data class MacosConfiguration(
@JsonProperty("bundle") val bundle: AppleTestBundleConfiguration? = null,
@JsonProperty("deviceProvider") val deviceProvider: DeviceProvider = DeviceProvider.Static(),
@JsonProperty("devices") val devicesFile: File? = null,
@JsonProperty("ssh") val ssh: SshConfiguration = SshConfiguration(),

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.malinskiy.marathon.config.vendor.apple

import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonSubTypes
import com.fasterxml.jackson.annotation.JsonTypeInfo
import java.io.File

@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type"
)
@JsonSubTypes(
JsonSubTypes.Type(value = DeviceProvider.Static::class, names = arrayOf("static", "marathondevices")),
JsonSubTypes.Type(value = DeviceProvider.Dynamic::class, name = "dynamic"),
)
sealed class DeviceProvider {
data class Static(
@JsonProperty("path") val path: File? = null
) : DeviceProvider()

data class Dynamic(
@JsonProperty("host") val host: String = "127.0.0.1",
@JsonProperty("port") val port: Int = 5037,
) : DeviceProvider()
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,11 @@ sealed interface Transport {
@JsonProperty("authentication") val authentication: SshAuthentication? = null,
@JsonProperty("checkReachability") val checkReachability: Boolean = true,
) : Transport

fun id(): String {
return when (this) {
Local -> "local"
is Ssh -> "${addr}:${port}"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator
import com.fasterxml.jackson.module.kotlin.KotlinFeature
import com.fasterxml.jackson.module.kotlin.KotlinModule
import com.fasterxml.jackson.module.kotlin.readValue
import com.malinskiy.marathon.apple.configuration.AppleTarget
import com.malinskiy.marathon.apple.configuration.Marathondevices
import com.malinskiy.marathon.apple.configuration.Transport
import com.malinskiy.marathon.apple.configuration.Worker
import com.malinskiy.marathon.config.vendor.apple.SshAuthentication
import org.amshove.kluent.shouldBeEqualTo
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import java.io.File

class MarathondevicesTest {
class StaticTest {
lateinit var mapper: ObjectMapper

@BeforeEach
Expand All @@ -36,7 +32,7 @@ class MarathondevicesTest {

@Test
fun testSample1() {
val src = File(MarathondevicesTest::class.java.getResource("/fixtures/marathondevices/sample_1.yaml").file)
val src = File(StaticTest::class.java.getResource("/fixtures/marathondevices/sample_1.yaml").file)
val actual = mapper.readValue<Marathondevices>(src)

actual shouldBeEqualTo Marathondevices(
Expand Down
8 changes: 8 additions & 0 deletions vendor/vendor-apple/ios/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ plugins {

dependencies {
implementation(project(":vendor:vendor-apple:base"))
implementation(Libraries.ktorNetwork)

testImplementation(TestLibraries.kluent)
testImplementation(TestLibraries.assertk)
testImplementation(TestLibraries.mockitoKotlin)
testImplementation(TestLibraries.junit5)
testImplementation(TestLibraries.coroutinesTest)
testRuntimeOnly(TestLibraries.jupiterEngine)
}

setupDeployment()
Expand Down
Loading

0 comments on commit 16c55ad

Please sign in to comment.