From 6c62fea69c2733bab73618f06daa23122c2d56b8 Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Tue, 19 May 2020 11:38:41 +0200 Subject: [PATCH 1/4] Fix overlapping results --- .../docs/ascii/flank.jar_-android-run.adoc | 2 +- .../flank.jar_-firebase-test-android-run.adoc | 2 +- .../ascii/flank.jar_-firebase-test-ios-run.adoc | 2 +- test_runner/docs/ascii/flank.jar_-ios-run.adoc | 2 +- .../main/kotlin/ftl/run/common/FetchArtifacts.kt | 1 + .../kotlin/ftl/run/platform/RunAndroidTests.kt | 6 +++--- test_runner/src/main/kotlin/ftl/util/ObjPath.kt | 16 ++++++++++------ test_runner/src/main/kotlin/ftl/util/Utils.kt | 2 -- .../src/test/kotlin/ftl/run/TestRunnerTest.kt | 4 +++- .../src/test/kotlin/ftl/util/ObjPathTest.kt | 6 ++---- .../src/test/kotlin/ftl/util/UtilsTest.kt | 2 +- 11 files changed, 24 insertions(+), 21 deletions(-) diff --git a/test_runner/docs/ascii/flank.jar_-android-run.adoc b/test_runner/docs/ascii/flank.jar_-android-run.adoc index 423c4e6ff3..d066e6df36 100644 --- a/test_runner/docs/ascii/flank.jar_-android-run.adoc +++ b/test_runner/docs/ascii/flank.jar_-android-run.adoc @@ -144,7 +144,7 @@ Configuration is read from flank.yml Keeps the full path of downloaded files. Required when file names are not unique. *--output-style*=__:: - Output style of execution status. Maybe be one of [verbose, multi, single]For runs with only one test execution default value is 'verbose', in other cases'multi' is used as default. Output style 'multi' is not displayed correctly on consoleswhich not supports ansi codes, to avoid corrupted output use `single` or `verbose`. + Output style of execution status. May be one of [verbose, multi, single]. For runs with only one test execution the default value is 'verbose', in other cases 'multi' is used as the default. The output style 'multi' is not displayed correctly on consoles which don't support ansi codes, to avoid corrupted output use `single` or `verbose`. *--dump-shards*:: Dumps the shards to android_shards.json for debugging diff --git a/test_runner/docs/ascii/flank.jar_-firebase-test-android-run.adoc b/test_runner/docs/ascii/flank.jar_-firebase-test-android-run.adoc index 61e053632f..0f56493d15 100644 --- a/test_runner/docs/ascii/flank.jar_-firebase-test-android-run.adoc +++ b/test_runner/docs/ascii/flank.jar_-firebase-test-android-run.adoc @@ -156,7 +156,7 @@ Configuration is read from flank.yml Keeps the full path of downloaded files. Required when file names are not unique. *--output-style*=__:: - Output style of execution status. Maybe be one of [verbose, multi, single]For runs with only one test execution default value is 'verbose', in other cases'multi' is used as default. Output style 'multi' is not displayed correctly on consoleswhich not supports ansi codes, to avoid corrupted output use `single` or `verbose`. + Output style of execution status. May be one of [verbose, multi, single]. For runs with only one test execution the default value is 'verbose', in other cases 'multi' is used as the default. The output style 'multi' is not displayed correctly on consoles which don't support ansi codes, to avoid corrupted output use `single` or `verbose`. *--dump-shards*:: Dumps the shards to android_shards.json for debugging diff --git a/test_runner/docs/ascii/flank.jar_-firebase-test-ios-run.adoc b/test_runner/docs/ascii/flank.jar_-firebase-test-ios-run.adoc index 0534901280..e8b59f7bf7 100644 --- a/test_runner/docs/ascii/flank.jar_-firebase-test-ios-run.adoc +++ b/test_runner/docs/ascii/flank.jar_-firebase-test-ios-run.adoc @@ -136,7 +136,7 @@ Configuration is read from flank.yml Keeps the full path of downloaded files. Required when file names are not unique. *--output-style*=__:: - Output style of execution status. Maybe be one of [verbose, multi, single]For runs with only one test execution default value is 'verbose', in other cases'multi' is used as default. Output style 'multi' is not displayed correctly on consoleswhich not supports ansi codes, to avoid corrupted output use `single` or `verbose`. + Output style of execution status. May be one of [verbose, multi, single]. For runs with only one test execution the default value is 'verbose', in other cases 'multi' is used as the default. The output style 'multi' is not displayed correctly on consoles which don't support ansi codes, to avoid corrupted output use `single` or `verbose`. *--dump-shards*:: Dumps the shards to ios_shards.json for debugging diff --git a/test_runner/docs/ascii/flank.jar_-ios-run.adoc b/test_runner/docs/ascii/flank.jar_-ios-run.adoc index 08e2755ac9..f03ddd35cc 100644 --- a/test_runner/docs/ascii/flank.jar_-ios-run.adoc +++ b/test_runner/docs/ascii/flank.jar_-ios-run.adoc @@ -128,7 +128,7 @@ Configuration is read from flank.yml Keeps the full path of downloaded files. Required when file names are not unique. *--output-style*=__:: - Output style of execution status. Maybe be one of [verbose, multi, single]For runs with only one test execution default value is 'verbose', in other cases'multi' is used as default. Output style 'multi' is not displayed correctly on consoleswhich not supports ansi codes, to avoid corrupted output use `single` or `verbose`. + Output style of execution status. May be one of [verbose, multi, single]. For runs with only one test execution the default value is 'verbose', in other cases 'multi' is used as the default. The output style 'multi' is not displayed correctly on consoles which don't support ansi codes, to avoid corrupted output use `single` or `verbose`. *--dump-shards*:: Dumps the shards to ios_shards.json for debugging diff --git a/test_runner/src/main/kotlin/ftl/run/common/FetchArtifacts.kt b/test_runner/src/main/kotlin/ftl/run/common/FetchArtifacts.kt index 21977b7412..267ed59676 100644 --- a/test_runner/src/main/kotlin/ftl/run/common/FetchArtifacts.kt +++ b/test_runner/src/main/kotlin/ftl/run/common/FetchArtifacts.kt @@ -72,6 +72,7 @@ internal fun getDownloadPath(args: IArgs, blobPath: String): Path { return Paths.get( localDir, if (args.useLocalResultDir().not()) p.objName else "", + p.matrixName, p.shardName, p.deviceName, if (args.keepFilePath) p.filePathName else "", diff --git a/test_runner/src/main/kotlin/ftl/run/platform/RunAndroidTests.kt b/test_runner/src/main/kotlin/ftl/run/platform/RunAndroidTests.kt index 14859c5689..4af82e4302 100644 --- a/test_runner/src/main/kotlin/ftl/run/platform/RunAndroidTests.kt +++ b/test_runner/src/main/kotlin/ftl/run/platform/RunAndroidTests.kt @@ -38,7 +38,7 @@ internal suspend fun runAndroidTests(args: AndroidArgs): TestResult = coroutineS val history = GcToolResults.createToolResultsHistory(args) val otherGcsFiles = args.uploadOtherFiles(runGcsPath) - args.resolveApks().forEach { apks: ResolvedApks -> + args.resolveApks().forEachIndexed { index: Int, apks: ResolvedApks -> val testShards = apks.test?.let { test -> AndroidTestShard.getTestShardChunks(args, test) } @@ -47,7 +47,7 @@ internal suspend fun runAndroidTests(args: AndroidArgs): TestResult = coroutineS val shardsWithAtLeastOneTest = testShards.filterAtLeastOneTest() if (shardsWithAtLeastOneTest.isEmpty()) { // No tests to run, skipping the execution. - return@forEach + return@forEachIndexed } allTestShardChunks += shardsWithAtLeastOneTest } @@ -67,7 +67,7 @@ internal suspend fun runAndroidTests(args: AndroidArgs): TestResult = coroutineS testMatrices += executeAndroidTestMatrix(runCount = args.repeatTests) { GcAndroidTestMatrix.build( androidTestConfig = androidTestConfig, - runGcsPath = runGcsPath, + runGcsPath = "$runGcsPath/matrix_$index/", additionalApkGcsPaths = uploadedApks.additionalApks, androidDeviceList = androidDeviceList, args = args, diff --git a/test_runner/src/main/kotlin/ftl/util/ObjPath.kt b/test_runner/src/main/kotlin/ftl/util/ObjPath.kt index 3352ee36a8..211465723c 100644 --- a/test_runner/src/main/kotlin/ftl/util/ObjPath.kt +++ b/test_runner/src/main/kotlin/ftl/util/ObjPath.kt @@ -7,7 +7,8 @@ data class ObjPath( val objName: String, val shardName: String, val deviceName: String, - val filePathName: String + val filePathName: String, + val matrixName: String ) { companion object { fun parse(path: String): ObjPath { @@ -15,12 +16,13 @@ data class ObjPath( val fileName = parsed.fileName.toString() val objName = parsed.getName(0).toString() - val (deviceName, shardNumber) = parsed.getName(1).toString().split("-shard_").run { + val matrixName = parsed.getName(1).toString() + val (deviceName, shardNumber) = parsed.getName(2).toString().split("-shard_").run { first() to getOrElse(1) { "0" } } val shardName = "shard_$shardNumber" - val filePathName = if (parsed.nameCount > 3) { - parsed.parent.drop(2).joinToString("/") + val filePathName = if (parsed.nameCount > 4) { + parsed.parent.drop(3).joinToString("/") } else { "" } return ObjPath( @@ -28,7 +30,8 @@ data class ObjPath( objName = objName, shardName = shardName, deviceName = deviceName, - filePathName = filePathName + filePathName = filePathName, + matrixName = matrixName ) } @@ -48,7 +51,8 @@ data class ObjPath( objName = objName, shardName = shardName, deviceName = deviceName, - filePathName = filePathName + filePathName = filePathName, + matrixName = "" ) } } diff --git a/test_runner/src/main/kotlin/ftl/util/Utils.kt b/test_runner/src/main/kotlin/ftl/util/Utils.kt index e90c98157e..6d2e94bc63 100644 --- a/test_runner/src/main/kotlin/ftl/util/Utils.kt +++ b/test_runner/src/main/kotlin/ftl/util/Utils.kt @@ -84,8 +84,6 @@ fun uniqueObjectName(): String { bucketName.append(letter) } - bucketName.append("/") - return bucketName.toString() } diff --git a/test_runner/src/test/kotlin/ftl/run/TestRunnerTest.kt b/test_runner/src/test/kotlin/ftl/run/TestRunnerTest.kt index d5fd910ce7..8526a49824 100644 --- a/test_runner/src/test/kotlin/ftl/run/TestRunnerTest.kt +++ b/test_runner/src/test/kotlin/ftl/run/TestRunnerTest.kt @@ -35,7 +35,7 @@ class TestRunnerTest { private val gcsIosPath = "2019-03-22_15-30-02.189000_frjt/shard_0/iphone8-12.0-en-portrait/TestLogs/Test-Transient Testing-2019.03.22_08-29-41--0700.xcresult/1_Test/Diagnostics/EarlGreyExampleSwiftTests-C6803D8C-4BDB-4C84-8945-9AC64056FBA4/EarlGreyExampleSwiftTests-EDBFF942-A88A-46A5-87CA-A1E29555C2CA/StandardOutputAndStandardError.txt" private val gcsAndroidPath = - "2019-03-22_15-30-02.189000_frjt/iphone8-12.0-en-portrait-shard_0/StandardOutputAndStandardError.txt" + "2019-03-22_15-30-02.189000_frjt/matrix_1/iphone8-12.0-en-portrait-shard_0/StandardOutputAndStandardError.txt" private val localResultDir = "results" private val iosArgs = mockk() private val androidArgs = mockk() @@ -138,6 +138,7 @@ class TestRunnerTest { assertThat(downloadFile).isEqualTo( Paths.get( localResultDir, + parsed.matrixName, parsed.shardName, parsed.deviceName, parsed.filePathName, @@ -159,6 +160,7 @@ class TestRunnerTest { Paths.get( localResultDir, parsed.objName, + parsed.matrixName, parsed.shardName, parsed.deviceName, parsed.filePathName, diff --git a/test_runner/src/test/kotlin/ftl/util/ObjPathTest.kt b/test_runner/src/test/kotlin/ftl/util/ObjPathTest.kt index 7bafa9a671..cc00575b68 100644 --- a/test_runner/src/test/kotlin/ftl/util/ObjPathTest.kt +++ b/test_runner/src/test/kotlin/ftl/util/ObjPathTest.kt @@ -1,16 +1,13 @@ package ftl.util import com.google.common.truth.Truth.assertThat -import ftl.test.util.FlankTestRunner import org.junit.Test -import org.junit.runner.RunWith -@RunWith(FlankTestRunner::class) class ObjPathTest { @Test fun parse() { - val path = "2019-03-22_15-39-20.400000_ESdl/NexusLowRes-28-en-portrait-shard_0/com/package/name/b.txt" + val path = "2019-03-22_15-39-20.400000_ESdl/matrix_1/NexusLowRes-28-en-portrait-shard_0/com/package/name/b.txt" val parsed = ObjPath.parse(path) assertThat(parsed.objName).isEqualTo("2019-03-22_15-39-20.400000_ESdl") @@ -18,6 +15,7 @@ class ObjPathTest { assertThat(parsed.shardName).isEqualTo("shard_0") assertThat(parsed.deviceName).isEqualTo("NexusLowRes-28-en-portrait") assertThat(parsed.filePathName).isEqualTo("com/package/name") + assertThat(parsed.matrixName).isEqualTo("matrix_1") } @Test diff --git a/test_runner/src/test/kotlin/ftl/util/UtilsTest.kt b/test_runner/src/test/kotlin/ftl/util/UtilsTest.kt index b4b8fc5a65..267e78e88f 100644 --- a/test_runner/src/test/kotlin/ftl/util/UtilsTest.kt +++ b/test_runner/src/test/kotlin/ftl/util/UtilsTest.kt @@ -69,7 +69,7 @@ class UtilsTest { @Test fun `uniqueObjectName verifyPattern`() { val randomName = uniqueObjectName() - assertThat(randomName.length).isEqualTo(32) + assertThat(randomName.length).isEqualTo(31) assertThat(randomName[4]).isEqualTo('-') assertThat(randomName[7]).isEqualTo('-') assertThat(randomName[10]).isEqualTo('_') From c8c007d78f4f8094198af9b55c5daac61d964602 Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Thu, 21 May 2020 12:32:26 +0200 Subject: [PATCH 2/4] Refactor and remove ObjPath class --- .../kotlin/ftl/reports/util/ReportManager.kt | 2 +- .../kotlin/ftl/run/common/FetchArtifacts.kt | 29 ++--- .../src/main/kotlin/ftl/util/ObjPath.kt | 59 --------- .../src/test/kotlin/ftl/run/TestRunnerTest.kt | 117 +++++------------- .../src/test/kotlin/ftl/util/ObjPathTest.kt | 32 ----- 5 files changed, 41 insertions(+), 198 deletions(-) delete mode 100644 test_runner/src/main/kotlin/ftl/util/ObjPath.kt delete mode 100644 test_runner/src/test/kotlin/ftl/util/ObjPathTest.kt diff --git a/test_runner/src/main/kotlin/ftl/reports/util/ReportManager.kt b/test_runner/src/main/kotlin/ftl/reports/util/ReportManager.kt index 847ffea302..15f8719c7b 100644 --- a/test_runner/src/main/kotlin/ftl/reports/util/ReportManager.kt +++ b/test_runner/src/main/kotlin/ftl/reports/util/ReportManager.kt @@ -41,7 +41,7 @@ object ReportManager { 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 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 diff --git a/test_runner/src/main/kotlin/ftl/run/common/FetchArtifacts.kt b/test_runner/src/main/kotlin/ftl/run/common/FetchArtifacts.kt index 267ed59676..f9dc80e3f8 100644 --- a/test_runner/src/main/kotlin/ftl/run/common/FetchArtifacts.kt +++ b/test_runner/src/main/kotlin/ftl/run/common/FetchArtifacts.kt @@ -1,20 +1,18 @@ package ftl.run.common import com.google.cloud.storage.Storage -import ftl.args.AndroidArgs import ftl.args.IArgs import ftl.config.FtlConstants -import ftl.gc.GcStorage import ftl.json.MatrixMap +import ftl.gc.GcStorage import ftl.util.Artifacts import ftl.util.MatrixState -import ftl.util.ObjPath +import java.nio.file.Path +import java.nio.file.Paths import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.joinAll import kotlinx.coroutines.launch -import java.nio.file.Path -import java.nio.file.Paths internal suspend fun fetchArtifacts(matrixMap: MatrixMap, args: IArgs) = coroutineScope { println("FetchArtifacts") @@ -64,18 +62,13 @@ internal suspend fun fetchArtifacts(matrixMap: MatrixMap, args: IArgs) = corouti internal fun getDownloadPath(args: IArgs, blobPath: String): Path { val localDir = args.localResultDir - val p = if (args is AndroidArgs) - ObjPath.parse(blobPath) else - ObjPath.legacyParse(blobPath) + val parsed = Paths.get(blobPath) + val objName = if (args.useLocalResultDir()) "" else parsed.getName(0).toString() + // for iOS it is shardName, remove this comment after FTL introduce server side sharding for iOS + val matrixName = parsed.getName(1).toString() + val deviceName = parsed.getName(2).toString() + val filePathName = if (parsed.nameCount > 4 && args.keepFilePath) parsed.parent.drop(3).joinToString("/") else "" + val fileName = parsed.fileName.toString() - // Store downloaded artifacts at device root. - return Paths.get( - localDir, - if (args.useLocalResultDir().not()) p.objName else "", - p.matrixName, - p.shardName, - p.deviceName, - if (args.keepFilePath) p.filePathName else "", - p.fileName - ) + return Paths.get("$localDir/$objName/$matrixName/$deviceName/$filePathName/$fileName") } diff --git a/test_runner/src/main/kotlin/ftl/util/ObjPath.kt b/test_runner/src/main/kotlin/ftl/util/ObjPath.kt deleted file mode 100644 index 211465723c..0000000000 --- a/test_runner/src/main/kotlin/ftl/util/ObjPath.kt +++ /dev/null @@ -1,59 +0,0 @@ -package ftl.util - -import java.nio.file.Paths - -data class ObjPath( - val fileName: String, - val objName: String, - val shardName: String, - val deviceName: String, - val filePathName: String, - val matrixName: String -) { - companion object { - fun parse(path: String): ObjPath { - val parsed = Paths.get(path) - - val fileName = parsed.fileName.toString() - val objName = parsed.getName(0).toString() - val matrixName = parsed.getName(1).toString() - val (deviceName, shardNumber) = parsed.getName(2).toString().split("-shard_").run { - first() to getOrElse(1) { "0" } - } - val shardName = "shard_$shardNumber" - val filePathName = if (parsed.nameCount > 4) { - parsed.parent.drop(3).joinToString("/") - } else { "" } - - return ObjPath( - fileName = fileName, - objName = objName, - shardName = shardName, - deviceName = deviceName, - filePathName = filePathName, - matrixName = matrixName - ) - } - - fun legacyParse(path: String): ObjPath { - val parsed = Paths.get(path) - - val fileName = parsed.fileName.toString() - val objName = parsed.getName(0).toString() - val shardName = parsed.getName(1).toString() - val deviceName = parsed.getName(2).toString() - val filePathName = if (parsed.nameCount > 4) { - parsed.parent.drop(3).joinToString("/") - } else { "" } - - return ObjPath( - fileName = fileName, - objName = objName, - shardName = shardName, - deviceName = deviceName, - filePathName = filePathName, - matrixName = "" - ) - } - } -} diff --git a/test_runner/src/test/kotlin/ftl/run/TestRunnerTest.kt b/test_runner/src/test/kotlin/ftl/run/TestRunnerTest.kt index 8526a49824..65e0770d3e 100644 --- a/test_runner/src/test/kotlin/ftl/run/TestRunnerTest.kt +++ b/test_runner/src/test/kotlin/ftl/run/TestRunnerTest.kt @@ -12,7 +12,6 @@ import ftl.config.FtlConstants.isWindows import ftl.http.executeWithRetry import ftl.run.common.getDownloadPath import ftl.test.util.FlankTestRunner -import ftl.util.ObjPath import io.mockk.every import io.mockk.mockk import io.mockk.mockkStatic @@ -29,14 +28,19 @@ import org.junit.Test import org.junit.contrib.java.lang.system.SystemOutRule import org.junit.runner.RunWith +private const val OBJECT_NAME = "2019-03-22_15-30-02.189000_frjt" +private const val FILE_NAME = "StandardOutputAndStandardError.txt" +private const val SHARD = "shard_0" +private const val MATRIX = "matrix_1" +private const val ANDROID_DEVICE = "NexusLowRes-27-en-portrait-shard_0-rerun_1" +private const val IOS_DEVICE = "iphone8-12.0-en-portrait" +private const val LOCAL_DIR = "results" +private const val TEST_FILE_PATH = "any/path/that/is/possible" +private const val FULL_IOS_PATH = "$OBJECT_NAME/$SHARD/$IOS_DEVICE/$TEST_FILE_PATH/$FILE_NAME" +private const val FULL_ANDROID_PATH = "$OBJECT_NAME/$MATRIX/$ANDROID_DEVICE/$TEST_FILE_PATH/$FILE_NAME" + @RunWith(FlankTestRunner::class) class TestRunnerTest { - - private val gcsIosPath = - "2019-03-22_15-30-02.189000_frjt/shard_0/iphone8-12.0-en-portrait/TestLogs/Test-Transient Testing-2019.03.22_08-29-41--0700.xcresult/1_Test/Diagnostics/EarlGreyExampleSwiftTests-C6803D8C-4BDB-4C84-8945-9AC64056FBA4/EarlGreyExampleSwiftTests-EDBFF942-A88A-46A5-87CA-A1E29555C2CA/StandardOutputAndStandardError.txt" - private val gcsAndroidPath = - "2019-03-22_15-30-02.189000_frjt/matrix_1/iphone8-12.0-en-portrait-shard_0/StandardOutputAndStandardError.txt" - private val localResultDir = "results" private val iosArgs = mockk() private val androidArgs = mockk() @@ -48,125 +52,62 @@ class TestRunnerTest { @Test fun `Verify getDownloadPath localResultDir false and keepFilePath false - ios`() { - val parsed = ObjPath.legacyParse(gcsIosPath) - - every { iosArgs.localResultDir } returns localResultDir + every { iosArgs.localResultDir } returns LOCAL_DIR every { iosArgs.useLocalResultDir() } returns false every { iosArgs.keepFilePath } returns false - val downloadFile = getDownloadPath(iosArgs, gcsIosPath) - assertThat(downloadFile).isEqualTo( - Paths.get( - localResultDir, - parsed.objName, - parsed.shardName, - parsed.deviceName, - parsed.fileName - ) - ) + val downloadFile = getDownloadPath(iosArgs, FULL_IOS_PATH) + assertThat(downloadFile).isEqualTo(Paths.get("$LOCAL_DIR/$OBJECT_NAME/$SHARD/$IOS_DEVICE/$FILE_NAME")) } @Test fun `Verify getDownloadPath localResultDir false and keepFilePath true - ios`() { - val parsed = ObjPath.legacyParse(gcsIosPath) - - every { iosArgs.localResultDir } returns localResultDir + every { iosArgs.localResultDir } returns LOCAL_DIR every { iosArgs.useLocalResultDir() } returns false every { iosArgs.keepFilePath } returns true - val downloadFile = getDownloadPath(iosArgs, gcsIosPath) - assertThat(downloadFile).isEqualTo( - Paths.get( - localResultDir, - parsed.objName, - parsed.shardName, - parsed.deviceName, - parsed.filePathName, - parsed.fileName - ) - ) + val downloadFile = getDownloadPath(iosArgs, FULL_IOS_PATH) + assertThat(downloadFile).isEqualTo(Paths.get("$LOCAL_DIR/$FULL_IOS_PATH")) } @Test fun `Verify getDownloadPath localResultDir true and keepFilePath false - ios`() { - val parsed = ObjPath.legacyParse(gcsIosPath) - - every { iosArgs.localResultDir } returns localResultDir + every { iosArgs.localResultDir } returns LOCAL_DIR every { iosArgs.useLocalResultDir() } returns true every { iosArgs.keepFilePath } returns false - val downloadFile = getDownloadPath(iosArgs, gcsIosPath) - assertThat(downloadFile).isEqualTo( - Paths.get( - localResultDir, - parsed.shardName, - parsed.deviceName, - parsed.fileName - ) - ) + val downloadFile = getDownloadPath(iosArgs, FULL_IOS_PATH) + assertThat(downloadFile).isEqualTo(Paths.get("$LOCAL_DIR/$SHARD/$IOS_DEVICE/$FILE_NAME")) } @Test fun `Verify getDownloadPath localResultDir true and keepFilePath true - ios`() { - val parsed = ObjPath.legacyParse(gcsIosPath) - - every { iosArgs.localResultDir } returns localResultDir + every { iosArgs.localResultDir } returns LOCAL_DIR every { iosArgs.useLocalResultDir() } returns true every { iosArgs.keepFilePath } returns true - val downloadFile = getDownloadPath(iosArgs, gcsIosPath) - assertThat(downloadFile).isEqualTo( - Paths.get( - localResultDir, - parsed.shardName, - parsed.deviceName, - parsed.filePathName, - parsed.fileName - ) - ) + val downloadFile = getDownloadPath(iosArgs, FULL_IOS_PATH) + assertThat(downloadFile).isEqualTo(Paths.get("$LOCAL_DIR/$SHARD/$IOS_DEVICE/$TEST_FILE_PATH/$FILE_NAME")) } @Test fun `Verify getDownloadPath localResultDir true and keepFilePath true - android`() { - val parsed = ObjPath.parse(gcsAndroidPath) - - every { androidArgs.localResultDir } returns localResultDir + every { androidArgs.localResultDir } returns LOCAL_DIR every { androidArgs.useLocalResultDir() } returns true every { androidArgs.keepFilePath } returns true - val downloadFile = getDownloadPath(androidArgs, gcsAndroidPath) - assertThat(downloadFile).isEqualTo( - Paths.get( - localResultDir, - parsed.matrixName, - parsed.shardName, - parsed.deviceName, - parsed.filePathName, - parsed.fileName - ) - ) + val downloadFile = getDownloadPath(androidArgs, FULL_ANDROID_PATH) + assertThat(downloadFile).isEqualTo(Paths.get("$LOCAL_DIR/$MATRIX/$ANDROID_DEVICE/$TEST_FILE_PATH/$FILE_NAME")) } @Test fun `Verify getDownloadPath localResultDir false and keepFilePath true`() { - val parsed = ObjPath.parse(gcsAndroidPath) - - every { androidArgs.localResultDir } returns localResultDir + every { androidArgs.localResultDir } returns LOCAL_DIR every { androidArgs.useLocalResultDir() } returns false every { androidArgs.keepFilePath } returns true - val downloadFile = getDownloadPath(androidArgs, gcsAndroidPath) - assertThat(downloadFile).isEqualTo( - Paths.get( - localResultDir, - parsed.objName, - parsed.matrixName, - parsed.shardName, - parsed.deviceName, - parsed.filePathName, - parsed.fileName - ) - ) + val downloadFile = getDownloadPath(androidArgs, FULL_ANDROID_PATH) + assertThat(downloadFile).isEqualTo(Paths.get("$LOCAL_DIR/$FULL_ANDROID_PATH")) } @Test diff --git a/test_runner/src/test/kotlin/ftl/util/ObjPathTest.kt b/test_runner/src/test/kotlin/ftl/util/ObjPathTest.kt deleted file mode 100644 index cc00575b68..0000000000 --- a/test_runner/src/test/kotlin/ftl/util/ObjPathTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -package ftl.util - -import com.google.common.truth.Truth.assertThat -import org.junit.Test - -class ObjPathTest { - - @Test - fun parse() { - val path = "2019-03-22_15-39-20.400000_ESdl/matrix_1/NexusLowRes-28-en-portrait-shard_0/com/package/name/b.txt" - val parsed = ObjPath.parse(path) - - assertThat(parsed.objName).isEqualTo("2019-03-22_15-39-20.400000_ESdl") - assertThat(parsed.fileName).isEqualTo("b.txt") - assertThat(parsed.shardName).isEqualTo("shard_0") - assertThat(parsed.deviceName).isEqualTo("NexusLowRes-28-en-portrait") - assertThat(parsed.filePathName).isEqualTo("com/package/name") - assertThat(parsed.matrixName).isEqualTo("matrix_1") - } - - @Test - fun legacyParse() { - val path = "2019-03-22_15-39-20.400000_ESdl/shard_0/NexusLowRes-28-en-portrait/com/package/name/b.txt" - val parsed = ObjPath.legacyParse(path) - - assertThat(parsed.objName).isEqualTo("2019-03-22_15-39-20.400000_ESdl") - assertThat(parsed.fileName).isEqualTo("b.txt") - assertThat(parsed.shardName).isEqualTo("shard_0") - assertThat(parsed.deviceName).isEqualTo("NexusLowRes-28-en-portrait") - assertThat(parsed.filePathName).isEqualTo("com/package/name") - } -} From ae5ba7df72fcc8f17c288ae78497c0d4fcbabb25 Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Thu, 21 May 2020 12:54:06 +0200 Subject: [PATCH 3/4] Refactor fetching --- test_runner/src/main/kotlin/ftl/run/common/FetchArtifacts.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_runner/src/main/kotlin/ftl/run/common/FetchArtifacts.kt b/test_runner/src/main/kotlin/ftl/run/common/FetchArtifacts.kt index f9dc80e3f8..5e93f0ae7f 100644 --- a/test_runner/src/main/kotlin/ftl/run/common/FetchArtifacts.kt +++ b/test_runner/src/main/kotlin/ftl/run/common/FetchArtifacts.kt @@ -67,7 +67,7 @@ internal fun getDownloadPath(args: IArgs, blobPath: String): Path { // for iOS it is shardName, remove this comment after FTL introduce server side sharding for iOS val matrixName = parsed.getName(1).toString() val deviceName = parsed.getName(2).toString() - val filePathName = if (parsed.nameCount > 4 && args.keepFilePath) parsed.parent.drop(3).joinToString("/") else "" + val filePathName = if (args.keepFilePath) parsed.parent.drop(3).joinToString("/") else "" val fileName = parsed.fileName.toString() return Paths.get("$localDir/$objName/$matrixName/$deviceName/$filePathName/$fileName") From 454db9d5f1cb64ee888c42ac72ea331d8477959c Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Thu, 21 May 2020 13:05:00 +0200 Subject: [PATCH 4/4] Update release notes --- release_notes.md | 12 ++++++------ test_runner/src/test/kotlin/ftl/util/UtilsTest.kt | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/release_notes.md b/release_notes.md index 3b6a7ce09e..539f93bb3a 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,15 +1,15 @@ ## next (unreleased) -- [#784](https://github.com/Flank/flank/pull/784) Add output-style option. ([jan-gogo](https://github.com/jan-gogo)) +- [#784](https://github.com/Flank/flank/pull/784) Add output-style option. ([jan-gogo](https://github.com/jan-gogo)) - [#779](https://github.com/Flank/flank/pull/779) Print retries & display additional info. ([jan-gogo](https://github.com/jan-gogo)) -- [#793](https://github.com/Flank/flank/issues/793) Better error message on file not found. ([adamfilipow92](https://github.com/adamfilipow92)) -- [#808](https://github.com/Flank/flank/issues/808) Fixed dry run crashes. ([piotradamczyk5](https://github.com/piotradamczyk5)) -- [#807](https://github.com/Flank/flank/issues/807) Fix Bugsnag being initialized during tests. ([piotradamczyk5](https://github.com/piotradamczyk5)) -- +- [#793](https://github.com/Flank/flank/issues/793) Better error message on file not found. ([adamfilipow92](https://github.com/adamfilipow92)) +- [#808](https://github.com/Flank/flank/issues/808) Fixed dry run crashes. ([piotradamczyk5](https://github.com/piotradamczyk5)) +- [#807](https://github.com/Flank/flank/issues/807) Fix Bugsnag being initialized during tests. ([piotradamczyk5](https://github.com/piotradamczyk5)) +- [#805](https://github.com/Flank/flank/pull/805) Fix overlapping results. ([pawelpasterz](https://github.com/pawelpasterz)) ## v20.05.2 -- [#781](https://github.com/Flank/flank/pull/781) Remove local exists check on cloud results-dir. Fixes crash when results-dir is set by the user. ([adamfilipow92](https://github.com/adamfilipow92)) +- [#781](https://github.com/Flank/flank/pull/781) Remove local exists check on cloud results-dir. Fixes crash when results-dir is set by the user. ([adamfilipow92](https://github.com/adamfilipow92)) - [#656](https://github.com/Flank/flank/issues/656) Improve error message reporting. ([adamfilipow92](https://github.com/adamfilipow92)) - [#783](https://github.com/Flank/flank/pull/783) Use legacy results for iOS by default. ([pawelpasterz](https://github.com/pawelpasterz)) diff --git a/test_runner/src/test/kotlin/ftl/util/UtilsTest.kt b/test_runner/src/test/kotlin/ftl/util/UtilsTest.kt index 267e78e88f..0a08d034ec 100644 --- a/test_runner/src/test/kotlin/ftl/util/UtilsTest.kt +++ b/test_runner/src/test/kotlin/ftl/util/UtilsTest.kt @@ -77,6 +77,7 @@ class UtilsTest { assertThat(randomName[16]).isEqualTo('-') assertThat(randomName[19]).isEqualTo('.') assertThat(randomName[26]).isEqualTo('_') + assertThat(randomName.last()).isNotEqualTo('/') } @Test(expected = FailedMatrix::class)