Skip to content

Commit df4d134

Browse files
authored
Updating sharding for retries (#76)
1 parent b440b0b commit df4d134

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,18 @@ internal class TestMatrixStore(
135135
checkNotNull(testMatrix.testMatrixId) {
136136
"Test matrix id for the base test matrix should not be null"
137137
}
138-
check(testTargets.isNotEmpty()) {
139-
"The test targets should not be empty"
138+
val sharding = if (testTargets.isEmpty()) {
139+
// It's beneficial to keep sharding same as base testMatrix
140+
// when we are running all the tests instead of a subset
141+
testMatrix.testSpecification.androidInstrumentationTest?.shardingOption
142+
} else {
143+
null
140144
}
141145
val testRunId = TestRun.createId(
142146
datastoreApi = datastoreApi,
143147
environment = testMatrix.environmentMatrix,
144148
clientInfo = testMatrix.clientInfo,
145-
sharding = testMatrix.testSpecification.androidInstrumentationTest?.shardingOption,
149+
sharding = sharding,
146150
testSetup = testMatrix.testSpecification.testSetup,
147151
testTargets = testTargets,
148152
baseTestMatrixId = testMatrix.testMatrixId
@@ -160,7 +164,8 @@ internal class TestMatrixStore(
160164
testRunKey = testRunId,
161165
testMatrix = testMatrix,
162166
testTargets = testTargets,
163-
flakyTestAttempts = flakyTestAttempts
167+
flakyTestAttempts = flakyTestAttempts,
168+
sharding = sharding
164169
)
165170
logger.info {
166171
"created test matrix: $newTestMatrix"
@@ -324,15 +329,17 @@ internal class TestMatrixStore(
324329
testRunKey: TestRun.Id,
325330
testMatrix: TestMatrix,
326331
testTargets: List<String>? = null,
327-
flakyTestAttempts: Int = 0
332+
flakyTestAttempts: Int = 0,
333+
sharding: ShardingOption?
328334
): TestMatrix {
329335
logger.trace {
330336
"test matrix id: ${testMatrix.testMatrixId}"
331337
}
332338

333339
val testSpecification = testMatrix.testSpecification.copy(
334340
androidInstrumentationTest = testMatrix.testSpecification.androidInstrumentationTest?.copy(
335-
testTargets = testTargets
341+
testTargets = testTargets,
342+
shardingOption = sharding
336343
)
337344
)
338345

0 commit comments

Comments
 (0)