Skip to content

Commit 2b90a55

Browse files
committed
Add a way to pass in orchestrator option when calling FTL
Test: usage in androidx.dev
1 parent 09b9ac4 commit 2b90a55

File tree

6 files changed

+27
-11
lines changed

6 files changed

+27
-11
lines changed

AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/testRunner/FirebaseTestLabController.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import dev.androidx.ci.firebase.FirebaseTestLabApi
2121
import dev.androidx.ci.firebase.dto.EnvironmentType
2222
import dev.androidx.ci.generated.ftl.AndroidDevice
2323
import dev.androidx.ci.generated.ftl.AndroidDeviceList
24+
import dev.androidx.ci.generated.ftl.AndroidInstrumentationTest.OrchestratorOption
2425
import dev.androidx.ci.generated.ftl.ClientInfo
2526
import dev.androidx.ci.generated.ftl.EnvironmentMatrix
2627
import dev.androidx.ci.generated.ftl.ShardingOption
@@ -112,7 +113,8 @@ internal class FirebaseTestLabController(
112113
cachedTestMatrixFilter: CachedTestMatrixFilter,
113114
testTargets: List<String>? = null,
114115
flakyTestAttempts: Int = 2,
115-
testTimeoutSeconds: Int = 2700
116+
testTimeoutSeconds: Int = 2700,
117+
orchestratorOption: OrchestratorOption = OrchestratorOption.DO_NOT_USE_ORCHESTRATOR,
116118
): List<TestMatrix> {
117119
val devices = (devicePicker ?: defaultDevicePicker).pickDevices()
118120
logger.info {
@@ -131,7 +133,8 @@ internal class FirebaseTestLabController(
131133
cachedTestMatrixFilter = cachedTestMatrixFilter,
132134
testTargets = testTargets,
133135
flakyTestAttempts = flakyTestAttempts,
134-
testTimeoutSeconds = testTimeoutSeconds
136+
testTimeoutSeconds = testTimeoutSeconds,
137+
orchestratorOption = orchestratorOption,
135138
)
136139
}
137140
}

AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/testRunner/TestMatrixStore.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import dev.androidx.ci.firebase.FirebaseTestLabApi
2222
import dev.androidx.ci.firebase.ToolsResultApi
2323
import dev.androidx.ci.gcloud.GcsPath
2424
import dev.androidx.ci.generated.ftl.AndroidInstrumentationTest
25+
import dev.androidx.ci.generated.ftl.AndroidInstrumentationTest.OrchestratorOption
2526
import dev.androidx.ci.generated.ftl.ClientInfo
2627
import dev.androidx.ci.generated.ftl.EnvironmentMatrix
2728
import dev.androidx.ci.generated.ftl.FileReference
@@ -72,7 +73,8 @@ internal class TestMatrixStore(
7273
cachedTestMatrixFilter: CachedTestMatrixFilter = { true },
7374
testTargets: List<String>? = null,
7475
flakyTestAttempts: Int = 2,
75-
testTimeoutSeconds: Int = 2700
76+
testTimeoutSeconds: Int = 2700,
77+
orchestratorOption: OrchestratorOption? = null,
7678
): TestMatrix {
7779

7880
val testRunId = TestRun.createId(
@@ -82,7 +84,8 @@ internal class TestMatrixStore(
8284
sharding = sharding,
8385
appApk = appApk.apkInfo,
8486
testApk = testApk.apkInfo,
85-
deviceSetup = deviceSetup
87+
deviceSetup = deviceSetup,
88+
orchestratorOption = orchestratorOption,
8689
)
8790
logger.trace {
8891
"test run id: $testRunId"
@@ -263,7 +266,8 @@ internal class TestMatrixStore(
263266
pullScreenshots: Boolean = false,
264267
testTargets: List<String>? = null,
265268
flakyTestAttempts: Int = 2,
266-
testTimeoutSeconds: Int = 2700
269+
testTimeoutSeconds: Int = 2700,
270+
orchestratorOption: OrchestratorOption? = null,
267271
): TestMatrix {
268272
val packageName = firebaseTestLabApi.getApkDetails(
269273
FileReference(
@@ -302,7 +306,8 @@ internal class TestMatrixStore(
302306
gcsPath = testApk.gcsPath.path
303307
),
304308
shardingOption = sharding,
305-
testTargets = testTargets
309+
testTargets = testTargets,
310+
orchestratorOption = orchestratorOption
306311
),
307312
testSetup = testSetup
308313
)

AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/testRunner/TestRunnerService.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import dev.androidx.ci.firebase.ToolsResultApi
99
import dev.androidx.ci.gcloud.GcsPath
1010
import dev.androidx.ci.gcloud.GoogleCloudApi
1111
import dev.androidx.ci.generated.ftl.AndroidDevice
12+
import dev.androidx.ci.generated.ftl.AndroidInstrumentationTest.OrchestratorOption
1213
import dev.androidx.ci.generated.ftl.ClientInfo
1314
import dev.androidx.ci.generated.ftl.ShardingOption
1415
import dev.androidx.ci.generated.ftl.TestEnvironmentCatalog
@@ -83,7 +84,8 @@ interface TestRunnerService {
8384
cachedTestMatrixFilter: CachedTestMatrixFilter = { true },
8485
testTargets: List<String>? = null,
8586
flakyTestAttempts: Int = 2,
86-
testTimeoutSeconds: Int = 2700
87+
testTimeoutSeconds: Int = 2700,
88+
orchestratorOption: OrchestratorOption = OrchestratorOption.DO_NOT_USE_ORCHESTRATOR,
8789
): ScheduleTestsResponse
8890

8991
/**

AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/testRunner/TestRunnerServiceImpl.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import dev.androidx.ci.gcloud.BlobVisitor
2222
import dev.androidx.ci.gcloud.GcsPath
2323
import dev.androidx.ci.gcloud.GoogleCloudApi
2424
import dev.androidx.ci.generated.ftl.AndroidDevice
25+
import dev.androidx.ci.generated.ftl.AndroidInstrumentationTest.OrchestratorOption
2526
import dev.androidx.ci.generated.ftl.ClientInfo
2627
import dev.androidx.ci.generated.ftl.ShardingOption
2728
import dev.androidx.ci.generated.ftl.TestEnvironmentCatalog
@@ -103,7 +104,8 @@ internal class TestRunnerServiceImpl internal constructor(
103104
cachedTestMatrixFilter: CachedTestMatrixFilter,
104105
testTargets: List<String>?,
105106
flakyTestAttempts: Int,
106-
testTimeoutSeconds: Int
107+
testTimeoutSeconds: Int,
108+
orchestratorOption: OrchestratorOption,
107109
): TestRunnerService.ScheduleTestsResponse {
108110
val testMatrices = testLabController.submitTests(
109111
appApk = appApk ?: apkStore.getPlaceholderApk(),

AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/testRunner/dto/TestRun.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import com.google.cloud.datastore.Key
2323
import com.squareup.moshi.Moshi
2424
import com.squareup.moshi.Types
2525
import dev.androidx.ci.datastore.DatastoreApi
26+
import dev.androidx.ci.generated.ftl.AndroidInstrumentationTest.OrchestratorOption
2627
import dev.androidx.ci.generated.ftl.ClientInfo
2728
import dev.androidx.ci.generated.ftl.EnvironmentMatrix
2829
import dev.androidx.ci.generated.ftl.ShardingOption
@@ -72,7 +73,8 @@ internal class TestRun(
7273
appApk: ApkInfo,
7374
testApk: ApkInfo,
7475
deviceSetup: DeviceSetup?,
75-
sharding: ShardingOption?
76+
sharding: ShardingOption?,
77+
orchestratorOption: OrchestratorOption?,
7678
): Id {
7779
val json = adapter.toJson(
7880
mapOf(
@@ -88,7 +90,7 @@ internal class TestRun(
8890
it.gcsPath.path
8991
}, // The order we install additional apks is important, so we do not sort here.
9092
"directoriesToPull" to deviceSetup?.directoriesToPull?.sorted()
91-
)
93+
) + if (orchestratorOption != null) mapOf("orchestratorOption" to orchestratorOption) else mapOf()
9294
)
9395
val sha = sha256(json.toByteArray(Charsets.UTF_8))
9496
return Id(datastoreApi.createKey(datastoreApi.testRunObjectKind, sha))

AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/testRunner/TestMatrixStoreTest.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import dev.androidx.ci.fake.FakeToolsResultApi
2323
import dev.androidx.ci.gcloud.GcsPath
2424
import dev.androidx.ci.generated.ftl.AndroidDevice
2525
import dev.androidx.ci.generated.ftl.AndroidDeviceList
26+
import dev.androidx.ci.generated.ftl.AndroidInstrumentationTest.OrchestratorOption
2627
import dev.androidx.ci.generated.ftl.ClientInfo
2728
import dev.androidx.ci.generated.ftl.ClientInfoDetail
2829
import dev.androidx.ci.generated.ftl.EnvironmentMatrix
@@ -340,7 +341,8 @@ internal class TestMatrixStoreTest {
340341
sharding = ShardingOption(),
341342
appApk = createFakeApk("app.pak").apkInfo,
342343
testApk = createFakeApk("test.apk").apkInfo,
343-
deviceSetup = DeviceSetup()
344+
deviceSetup = DeviceSetup(),
345+
orchestratorOption = OrchestratorOption.DO_NOT_USE_ORCHESTRATOR,
344346
)
345347

346348
val resultGcsPath1 = store.createUniqueResultGcsPath(testRunId)

0 commit comments

Comments
 (0)