From d27525ec05cd449d4c17dcfcf88300959957c627 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 29 May 2020 14:24:49 +0200 Subject: [PATCH] update release_notes, add tests and solution --- release_notes.md | 2 ++ .../src/main/kotlin/ftl/args/AndroidArgs.kt | 2 +- test_runner/src/main/kotlin/ftl/args/IArgs.kt | 6 ++++++ test_runner/src/main/kotlin/ftl/args/IosArgs.kt | 2 +- .../src/test/kotlin/ftl/args/AndroidArgsTest.kt | 5 +++-- .../src/test/kotlin/ftl/args/IosArgsTest.kt | 15 ++++++++++++++- .../test_app_cases/flank-single-errorFlaky.yml | 2 +- 7 files changed, 28 insertions(+), 6 deletions(-) diff --git a/release_notes.md b/release_notes.md index e19e58c41d..4532aba999 100644 --- a/release_notes.md +++ b/release_notes.md @@ -11,6 +11,8 @@ - [#799](https://github.com/Flank/flank/pull/799) Refactor Shared object by splitting it into smaller functions. ([piotradamczyk5](https://github.com/piotradamczyk5)) - [#798](https://github.com/Flank/flank/pull/798) Remove failure nodes from tests that passed on retry so that Jenkins JUnit plugin marks them as successful. ([adamfilipow92](https://github.com/adamfilipow92)) - [#822](https://github.com/Flank/flank/pull/822) Allow runtime test discovery when sharding is disabled by not setting test-targets. This unblocks cucumber testing. ([adamfilipow92](https://github.com/adamfilipow92)) +- [#825](https://github.com/Flank/flank/pull/825) Automatically convert -1 in maximum-test-shards to the maximum shard amount. ([adamfilipow92](https://github.com/adamfilipow92)) +- ## v20.05.2 diff --git a/test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt b/test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt index cf2e0bad74..10ba089aef 100644 --- a/test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt +++ b/test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt @@ -78,7 +78,7 @@ class AndroidArgs( val devices = cli?.device ?: androidGcloud.device private val flank = flankYml.flank - override val maxTestShards = cli?.maxTestShards ?: flank.maxTestShards + override val maxTestShards = fixMaxTestShardsValue(cli?.maxTestShards ?: flank.maxTestShards) override val shardTime = cli?.shardTime ?: flank.shardTime override val repeatTests = cli?.repeatTests ?: flank.repeatTests override val smartFlankGcsPath = cli?.smartFlankGcsPath ?: flank.smartFlankGcsPath diff --git a/test_runner/src/main/kotlin/ftl/args/IArgs.kt b/test_runner/src/main/kotlin/ftl/args/IArgs.kt index 9a3d2e4d2e..1dd1050574 100644 --- a/test_runner/src/main/kotlin/ftl/args/IArgs.kt +++ b/test_runner/src/main/kotlin/ftl/args/IArgs.kt @@ -51,6 +51,12 @@ interface IArgs { fun useLocalResultDir() = localResultDir != FlankYmlParams.defaultLocalResultsDir + fun fixMaxTestShardsValue(inputValue: Int): Int = if (inputValue == -1) { + AVAILABLE_SHARD_COUNT_RANGE.last + } else { + inputValue + } + companion object { // num_shards must be >= 1, and <= 50 val AVAILABLE_SHARD_COUNT_RANGE = 1..50 diff --git a/test_runner/src/main/kotlin/ftl/args/IosArgs.kt b/test_runner/src/main/kotlin/ftl/args/IosArgs.kt index 367b9b7d3f..7eade47916 100644 --- a/test_runner/src/main/kotlin/ftl/args/IosArgs.kt +++ b/test_runner/src/main/kotlin/ftl/args/IosArgs.kt @@ -56,7 +56,7 @@ class IosArgs( val devices = cli?.device ?: iosGcloud.device private val flank = flankYml.flank - override val maxTestShards = cli?.maxTestShards ?: flank.maxTestShards + override val maxTestShards = fixMaxTestShardsValue(cli?.maxTestShards ?: flank.maxTestShards) override val shardTime = cli?.shardTime ?: flank.shardTime override val repeatTests = cli?.repeatTests ?: flank.repeatTests override val smartFlankGcsPath = cli?.smartFlankGcsPath ?: flank.smartFlankGcsPath diff --git a/test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt b/test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt index 427517457b..1d9a6e4c6a 100644 --- a/test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt +++ b/test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt @@ -1,6 +1,7 @@ package ftl.args import com.google.common.truth.Truth.assertThat +import ftl.args.IArgs.Companion.AVAILABLE_SHARD_COUNT_RANGE import ftl.args.yml.AppTestPair import ftl.cli.firebase.test.android.AndroidRunCommand import ftl.config.Device @@ -456,7 +457,7 @@ AndroidArgs val testShardChunks = getAndroidShardChunks(androidArgs, androidArgs.testApk!!) with(androidArgs) { - assert(maxTestShards, -1) + assert(maxTestShards, AVAILABLE_SHARD_COUNT_RANGE.last) assert(testShardChunks.size, 2) testShardChunks.forEach { chunk -> assert(chunk.size, 1) } } @@ -1407,7 +1408,7 @@ AndroidArgs max-test-shards: -1 """.trimIndent() val args = AndroidArgs.load(yaml) - assertEquals(50, args.maxTestShards) + assertEquals(AVAILABLE_SHARD_COUNT_RANGE.last, args.maxTestShards) } } diff --git a/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt b/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt index 82135c2a09..7e4f09512e 100644 --- a/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt +++ b/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt @@ -345,7 +345,7 @@ IosArgs ) with(args) { - assert(maxTestShards, -1) + assert(maxTestShards, IArgs.AVAILABLE_SHARD_COUNT_RANGE.last) assert(testShardChunks.size, 17) testShardChunks.forEach { chunk -> assert(chunk.size, 1) } } @@ -904,6 +904,19 @@ IosArgs val iosArgs = IosArgs.load(simpleFlankPath) assertFalse(iosArgs.keepFilePath) } + + @Test + fun `if set max-test-shards to -1 should give maximum amount`() { + val yaml = """ + gcloud: + test: $testPath + xctestrun-file: $testPath + flank: + max-test-shards: -1 + """.trimIndent() + val args = IosArgs.load(yaml) + assertEquals(IArgs.AVAILABLE_SHARD_COUNT_RANGE.last, args.maxTestShards) + } } private fun IosArgs.Companion.load(yamlData: String, cli: IosRunCommand? = null): IosArgs = load(StringReader(yamlData), cli) diff --git a/test_runner/src/test/kotlin/ftl/fixtures/test_app_cases/flank-single-errorFlaky.yml b/test_runner/src/test/kotlin/ftl/fixtures/test_app_cases/flank-single-errorFlaky.yml index 8455b90fa3..044d04afbb 100644 --- a/test_runner/src/test/kotlin/ftl/fixtures/test_app_cases/flank-single-errorFlaky.yml +++ b/test_runner/src/test/kotlin/ftl/fixtures/test_app_cases/flank-single-errorFlaky.yml @@ -5,4 +5,4 @@ gcloud: flank: disable-sharding: false - max-test-shards: 1 + max-test-shards: -1