Skip to content

Commit

Permalink
Merge branch 'master' into #943-last-fixes-for-release-process
Browse files Browse the repository at this point in the history
  • Loading branch information
piotradamczyk5 authored Aug 7, 2020
2 parents a1dbb46 + 17b5d8b commit e2187dd
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 24 deletions.
2 changes: 1 addition & 1 deletion release_notes.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## next (unreleased)
- [#952](https://github.com/Flank/flank/pull/952) Fix version printing on Flank release
- [#950](https://github.com/Flank/flank/pull/950) Fix crash when --legacy-junit-result set. ([adamfilipow92](https://github.com/adamfilipow92))
- [#948](https://github.com/Flank/flank/pull/948) Increment retry tries and change sync tag for jfrogSync. ([piotradamczyk5](https://github.com/piotradamczyk5))
-
-
-

## v20.08.0
- [#890](https://github.com/Flank/flank/pull/890) Convert bitrise ubuntu workflow into GitHub actions. ([piotradamczyk5](https://github.com/piotradamczyk5))
Expand Down
11 changes: 11 additions & 0 deletions test_runner/src/main/kotlin/ftl/reports/util/MatrixPath.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package ftl.reports.util

import java.io.File
import java.nio.file.Paths

fun File.getMatrixPath(objectName: String) = getShardName()?.asObjectPath(objectName)

private fun File.getShardName() = shardNameRegex.find(toString())?.value?.removePrefix("/")?.removeSuffix("/")
private val shardNameRegex = "/.*(shard_|matrix_)\\d+(-rerun_\\d+)?/".toRegex()

private fun String.asObjectPath(objectName: String) = Paths.get(objectName, this).toString()
26 changes: 6 additions & 20 deletions test_runner/src/main/kotlin/ftl/reports/util/ReportManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import ftl.shard.createTestMethodDurationMap
import ftl.util.Artifacts
import ftl.util.resolveLocalRunPath
import java.io.File
import java.nio.file.Paths
import kotlin.math.roundToInt

object ReportManager {
Expand All @@ -40,25 +39,8 @@ object ReportManager {
return xmlFiles
}

private fun getWebLink(matrices: MatrixMap, xmlFile: File): String {
// xmlFile path changes based on if local-result-dir is used. may or may not contain objName
// 2019-03-22_17-20-53.594000_ftrh/shard_0/test_result_1.xml or shard_0/test_result_1.xml
val objName = matrices.runPath // 2019-03-22_17-20-53.594000_ftrh

// shard location in path changes based on iOS or Android.
val matchResult = Regex("/.*(shard_\\d+)(-rerun_\\d+)?/").find(xmlFile.toString())
val shardName = matchResult?.value?.removePrefix("/")?.removeSuffix("/") // shard_0 || shard_0-rerun_1
val matrixPath = Paths.get(objName, shardName).toString() // 2019-03-22_17-20-53.594000_ftrh/shard_0

var webLink = ""
val savedMatrix = matrices.map.values.firstOrNull { it.gcsPath.endsWith(matrixPath) }
if (savedMatrix != null) {
webLink = savedMatrix.webLink
} else {
println("WARNING: Matrix path not found in JSON. $matrixPath")
}
return webLink
}
private fun getWebLink(matrices: MatrixMap, xmlFile: File): String = xmlFile.getMatrixPath(matrices.runPath)
?.findMatrixPath(matrices) ?: "".also { println("WARNING: Matrix path not found in JSON.") }

private val deviceStringRgx = Regex("([^-]+-[^-]+-[^-]+-[^-]+).*")

Expand Down Expand Up @@ -215,3 +197,7 @@ object ReportManager {
GcStorage.uploadJunitXml(newTestResult, args)
}
}

private fun String.findMatrixPath(matrices: MatrixMap) =
matrices.map.values.firstOrNull { savedMatrix -> savedMatrix.gcsPath.endsWith(this) }?.webLink
?: "".also { println("WARNING: Matrix path not found in JSON. $this") }
7 changes: 4 additions & 3 deletions test_runner/src/test/kotlin/Debug.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ fun main() {
val projectId = System.getenv("GOOGLE_CLOUD_PROJECT")
?: "YOUR PROJECT ID"

val quantity = "single"
val type = "error"
val quantity = "multiple"
val type = "success"
// Bugsnag keeps the process alive so we must call exitProcess
// https://github.com/bugsnag/bugsnag-java/issues/151
withGlobalExceptionHandling {
Expand All @@ -23,7 +23,8 @@ fun main() {
// "--dry",
// "--dump-shards",
// "--output-style=single",
"--full-junit-result",
// "--full-junit-result",
// "--legacy-junit-result",
"-c=src/test/kotlin/ftl/fixtures/test_app_cases/flank-$quantity-$type.yml",
"--project=$projectId"
// "--client-details=key1=value1,key2=value2"
Expand Down
12 changes: 12 additions & 0 deletions test_runner/src/test/kotlin/ftl/reports/utils/ReportManagerTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ftl.reports.FullJUnitReport
import ftl.reports.JUnitReport
import ftl.reports.MatrixResultsReport
import ftl.reports.util.ReportManager
import ftl.reports.util.getMatrixPath
import ftl.reports.xml.model.JUnitTestCase
import ftl.reports.xml.model.JUnitTestResult
import ftl.reports.xml.model.JUnitTestSuite
Expand All @@ -21,11 +22,13 @@ import io.mockk.mockkObject
import io.mockk.unmockkAll
import io.mockk.verify
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Rule
import org.junit.Test
import org.junit.contrib.java.lang.system.SystemErrRule
import org.junit.contrib.java.lang.system.SystemOutRule
import org.junit.runner.RunWith
import java.io.File

@RunWith(FlankTestRunner::class)
class ReportManagerTest {
Expand Down Expand Up @@ -196,4 +199,13 @@ class ReportManagerTest {
assertThat(ReportManager.getDeviceString(""))
.isEqualTo("")
}

@Test
fun `should get weblink from legacy path and ios path`() {
val legacyPath = File("results/2020-08-06_12-08-55.641213_jGpY/matrix_0/NexusLowRes-28-en-portrait/test_result_1.xml")
val iosPath = File("results/test_dir/shard_0/iphone8-12.0-en-portrait/test_result_0.xml")
val objectName = "object_name"
assertEquals("object_name/2020-08-06_12-08-55.641213_jGpY/matrix_0", legacyPath.getMatrixPath(objectName))
assertEquals("object_name/test_dir/shard_0", iosPath.getMatrixPath(objectName))
}
}

0 comments on commit e2187dd

Please sign in to comment.