Skip to content

Commit

Permalink
update release_notes, add tests and solution
Browse files Browse the repository at this point in the history
  • Loading branch information
adamfilipow92 committed Jun 1, 2020
1 parent 50d74cf commit d27525e
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 6 deletions.
2 changes: 2 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test_runner/src/main/kotlin/ftl/args/IArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test_runner/src/main/kotlin/ftl/args/IosArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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) }
}
Expand Down Expand Up @@ -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)
}
}

Expand Down
15 changes: 14 additions & 1 deletion test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
Expand Down Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ gcloud:

flank:
disable-sharding: false
max-test-shards: 1
max-test-shards: -1

0 comments on commit d27525e

Please sign in to comment.