diff --git a/test_runner/src/main/kotlin/ftl/gc/GcToolResults.kt b/test_runner/src/main/kotlin/ftl/gc/GcToolResults.kt index dd0c3cd39a..da302cb0b5 100644 --- a/test_runner/src/main/kotlin/ftl/gc/GcToolResults.kt +++ b/test_runner/src/main/kotlin/ftl/gc/GcToolResults.kt @@ -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 @@ -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() @@ -135,7 +139,19 @@ object GcToolResults { toolResultsStep.historyId, toolResultsStep.executionId, toolResultsStep.stepId - ).executeWithRetry() + ) + .setPageToken(pageToken) + .executeWithRetry() + } + + fun listAllTestCases(results: ToolResultsStep): List { + 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 { diff --git a/test_runner/src/main/kotlin/ftl/reports/api/CreateTestExecutionData.kt b/test_runner/src/main/kotlin/ftl/reports/api/CreateTestExecutionData.kt index ca95374006..2a020e2048 100644 --- a/test_runner/src/main/kotlin/ftl/reports/api/CreateTestExecutionData.kt +++ b/test_runner/src/main/kotlin/ftl/reports/api/CreateTestExecutionData.kt @@ -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 @@ -26,12 +25,10 @@ internal fun List.createTestExecutionDataListAsync(): List, step: Step ) = getAsync(toolResultsStep) - val testCases = response.testCases ?: emptyList() - return TestExecutionData( testExecution = this@createTestExecutionData, testCases = testCases, @@ -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() } diff --git a/test_runner/src/test/kotlin/ftl/reports/api/CreateTestExecutionDataKtTest.kt b/test_runner/src/test/kotlin/ftl/reports/api/CreateTestExecutionDataKtTest.kt index 7ee875d6eb..d20eda9206 100644 --- a/test_runner/src/test/kotlin/ftl/reports/api/CreateTestExecutionDataKtTest.kt +++ b/test_runner/src/test/kotlin/ftl/reports/api/CreateTestExecutionDataKtTest.kt @@ -67,7 +67,7 @@ class CreateTestExecutionDataKtTest { fun `should not throw is ListTestCasesResponse testCases are null`() { // given every { GcToolResults.getStepResult(any()) } returns Step() - every { GcToolResults.listTestCases(any()) } returns ListTestCasesResponse() + every { GcToolResults.listAllTestCases(any()) } returns emptyList() val testExecution = TestExecution().apply { toolResultsStep = ToolResultsStep()