Skip to content

Commit

Permalink
disable upload when flag to disable present
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Adamczyk committed Nov 18, 2020
1 parent 8081540 commit d9565f7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
2 changes: 0 additions & 2 deletions test_runner/src/main/kotlin/ftl/gc/GcStorage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ internal fun List<Pair<TestExecution, String>>.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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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 {
Expand All @@ -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<AndroidDevice>(), any()) } returns false
val performanceMetrics = testExecutions.map {
GcToolResults.getPerformanceMetric(it.toolResultsStep)
}

mockkObject(GcStorage) {
val args = mockk<IArgs> {
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<TestExecution> {
every { projectId } returns "test"
Expand Down

0 comments on commit d9565f7

Please sign in to comment.