diff --git a/test_runner/src/main/kotlin/ftl/gc/GcStorage.kt b/test_runner/src/main/kotlin/ftl/gc/GcStorage.kt index 49e61b41de..246dd16949 100644 --- a/test_runner/src/main/kotlin/ftl/gc/GcStorage.kt +++ b/test_runner/src/main/kotlin/ftl/gc/GcStorage.kt @@ -90,8 +90,6 @@ object GcStorage { ) }.onFailure { println("Cannot upload performance metrics ${it.message}") - }.onSuccess { - println("Performance metrics uploaded to https://console.developers.google.com/storage/browser/$resultsBucket/$resultDir") }.getOrNull() fun uploadReportResult(testResult: String, args: IArgs, fileName: String) { diff --git a/test_runner/src/main/kotlin/ftl/reports/api/PerformanceMetrics.kt b/test_runner/src/main/kotlin/ftl/reports/api/PerformanceMetrics.kt index 22188cafb9..5f4e6a85b4 100644 --- a/test_runner/src/main/kotlin/ftl/reports/api/PerformanceMetrics.kt +++ b/test_runner/src/main/kotlin/ftl/reports/api/PerformanceMetrics.kt @@ -21,7 +21,9 @@ internal fun List>.getAndUploadPerformanceMetrics( async(Dispatchers.IO) { val performanceMetrics = testExecution.getPerformanceMetric() performanceMetrics.save(gcsStoragePath, args) - performanceMetrics.upload(resultBucket = args.resultsBucket, resultDir = gcsStoragePath) + if (args.disableResultsUpload.not()) { + performanceMetrics.upload(resultBucket = args.resultsBucket, resultDir = gcsStoragePath) + } } } .awaitAll() diff --git a/test_runner/src/test/kotlin/ftl/reports/api/PerformanceMetricsTest.kt b/test_runner/src/test/kotlin/ftl/reports/api/PerformanceMetricsTest.kt index 08f233b87a..664d76330d 100644 --- a/test_runner/src/test/kotlin/ftl/reports/api/PerformanceMetricsTest.kt +++ b/test_runner/src/test/kotlin/ftl/reports/api/PerformanceMetricsTest.kt @@ -37,7 +37,7 @@ class PerformanceMetricsTest { } @Test - fun `should get and upload performance metrics for physical devices`() { + fun `should get and upload performance metrics for physical devices if results upload enabled`() { val expectedBucket = "bucket" val expectedPath = "path" @@ -52,6 +52,7 @@ class PerformanceMetricsTest { every { resultsBucket } returns expectedBucket every { useLocalResultDir() } returns false every { localResultDir } returns "local" + every { disableResultsUpload } returns false } testExecutions.map { it to expectedPath }.getAndUploadPerformanceMetrics(args) performanceMetrics.forEach { @@ -61,6 +62,32 @@ class PerformanceMetricsTest { } } + @Test + fun `should get and not upload performance metrics for physical devices if results upload disabled`() { + val expectedBucket = "bucket" + val expectedPath = "path" + + mockkObject(AndroidCatalog) { + every { AndroidCatalog.isVirtualDevice(any(), any()) } returns false + val performanceMetrics = testExecutions.map { + GcToolResults.getPerformanceMetric(it.toolResultsStep) + } + + mockkObject(GcStorage) { + val args = mockk { + every { resultsBucket } returns expectedBucket + every { useLocalResultDir() } returns false + every { localResultDir } returns "local" + every { disableResultsUpload } returns true + } + testExecutions.map { it to expectedPath }.getAndUploadPerformanceMetrics(args) + performanceMetrics.forEach { + verify(exactly = 0) { GcStorage.uploadPerformanceMetrics(it, expectedBucket, expectedPath) } + } + } + } + } + private val testExecutions = (1..5).map { mockk { every { projectId } returns "test"