Skip to content

Commit

Permalink
#1634 - Fixed issue when JUnitReport.xml only contained 50 test results
Browse files Browse the repository at this point in the history
  • Loading branch information
ddanylyk committed Mar 1, 2021
1 parent 2584eeb commit 70e871e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
20 changes: 18 additions & 2 deletions test_runner/src/main/kotlin/ftl/gc/GcToolResults.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.google.api.services.toolresults.model.ListEnvironmentsResponse
import com.google.api.services.toolresults.model.ListStepsResponse
import com.google.api.services.toolresults.model.ListTestCasesResponse
import com.google.api.services.toolresults.model.Step
import com.google.api.services.toolresults.model.TestCase
import com.google.testing.model.TestExecution
import com.google.testing.model.ToolResultsExecution
import com.google.testing.model.ToolResultsHistory
Expand Down Expand Up @@ -123,7 +124,10 @@ object GcToolResults {
.executeWithRetry()

// Lists Test Cases attached to a Step
fun listTestCases(toolResultsStep: ToolResultsStep): ListTestCasesResponse {
fun listTestCases(
toolResultsStep: ToolResultsStep,
pageToken: String? = null
): ListTestCasesResponse {
return service
.projects()
.histories()
Expand All @@ -135,7 +139,19 @@ object GcToolResults {
toolResultsStep.historyId,
toolResultsStep.executionId,
toolResultsStep.stepId
).executeWithRetry()
)
.setPageToken(pageToken)
.executeWithRetry()
}

fun listAllTestCases(results: ToolResultsStep): List<TestCase> {
var response = listTestCases(results)
val testCases = response.testCases.toMutableList()
while (response.nextPageToken != null) {
response = listTestCases(results, response.nextPageToken)
testCases += response.testCases ?: emptyList()
}
return testCases
}

fun getDefaultBucket(projectId: String, source: String? = null): String? = try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ftl.reports.api

import com.google.api.services.toolresults.model.ListTestCasesResponse
import com.google.api.services.toolresults.model.Step
import com.google.api.services.toolresults.model.TestCase
import com.google.api.services.toolresults.model.Timestamp
Expand All @@ -26,12 +25,10 @@ internal fun List<TestExecution>.createTestExecutionDataListAsync(): List<TestEx

private suspend fun TestExecution.createTestExecutionData(): TestExecutionData {
val (
response: ListTestCasesResponse,
testCases: List<TestCase>,
step: Step
) = getAsync(toolResultsStep)

val testCases = response.testCases ?: emptyList()

return TestExecutionData(
testExecution = this@createTestExecutionData,
testCases = testCases,
Expand All @@ -41,7 +38,7 @@ private suspend fun TestExecution.createTestExecutionData(): TestExecutionData {
}

private suspend fun getAsync(toolResultsStep: ToolResultsStep) = coroutineScope {
val response = async { GcToolResults.listTestCases(toolResultsStep) }
val response = async { GcToolResults.listAllTestCases(toolResultsStep) }
val step = async { GcToolResults.getStepResult(toolResultsStep) }
response.await() to step.await()
}
Expand Down

0 comments on commit 70e871e

Please sign in to comment.