-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Shards and Tests count do not match #1059
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
b476766
Initial test
pawelpasterz 46a21e2
Change TestFlankMethod
pawelpasterz c5f020c
Modify args
pawelpasterz 68151a1
Changes in shard
pawelpasterz 784b638
Modify context
pawelpasterz 8f762fe
Platform
pawelpasterz 74e8a6d
Turn off tests
pawelpasterz 572deb1
Revert "Turn off tests"
pawelpasterz e44e5f1
Make tests compile again
pawelpasterz 57fd995
Extract Chunk into separate file
pawelpasterz cd4ee4e
Update tests
pawelpasterz 776fcb5
Linting
pawelpasterz db6aa06
Refactor names
pawelpasterz 6dbbf62
Implement missing tests
pawelpasterz e46b623
reorder params in asserts
adamfilipow92 9b7285b
Update BeforeRunMessage.kt
adamfilipow92 336469d
Create 986_test_count_and_smart_sharding_ count_dont_match.md
adamfilipow92 eff2f90
Update 986_test_count_and_smart_sharding_ count_dont_match.md
adamfilipow92 3eaa51a
default class test time
adamfilipow92 1950b2d
added command for class timeout and fix some tests
adamfilipow92 a0c84ad
resolve conflicts
adamfilipow92 ac90cc2
update tests
adamfilipow92 b7da950
update docs and add tests for test time
adamfilipow92 5defcf8
small refractor
adamfilipow92 9dd3587
Address review comments
pawelpasterz e1e149b
Update tests
pawelpasterz 2e7328a
Update doc
pawelpasterz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
docs/bugs/986_test_count_and_smart_sharding_ count_dont_match.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Test count and smart sharding count don't match | ||
|
||
Bug reported in [this issue](https://github.com/Flank/flank/issues/986) | ||
|
||
## The problem | ||
|
||
Flank does not support parameterized tests sharding. Every class with parameterized is considered as one test during shard calculation. | ||
|
||
Flank is using [DEX parser](https://github.com/linkedin/dex-test-parser) to decompile apks and gather info about all the tests inside. As for now, Flank is unable to determine how many times a test in a parameterized class is invoked. Due to this fact scans apks for any class with an annotation that contains `JUnitParamsRunner` or `Parameterized`: | ||
|
||
```kotlin | ||
|
||
@RunWith(JUnitParamsRunner::class) | ||
... | ||
@RunWith(Parameterized::class) | ||
|
||
``` | ||
|
||
## Solution | ||
|
||
1. Flank knows how many tests and classes are being sent to Firebase. So we can inform the user of how many classes we have. Example: | ||
|
||
```txt | ||
|
||
Smart Flank cache hit: 0% (0 / 9) | ||
Shard times: 240s, 240s, 240s, 360s | ||
|
||
Uploading app-debug.apk . | ||
Uploading app-multiple-flaky-debug-androidTest.apk . | ||
5 tests + 4 parameterized classes / 4 shards | ||
|
||
``` | ||
|
||
1. Default test time for classes should be different from the default time for test | ||
1. You can set default test time for class with ```--default-class-test-time``` command | ||
2. If you did not set this time, the default value is 240s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
package ftl.args | ||
|
||
data class CalculateShardsResult(val shardChunks: ShardChunks, val ignoredTestCases: IgnoredTestCases) | ||
import ftl.shard.Chunk | ||
|
||
data class CalculateShardsResult(val shardChunks: List<Chunk>, val ignoredTestCases: IgnoredTestCases) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
test_runner/src/main/kotlin/ftl/run/model/AndroidTestContext.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 25 additions & 12 deletions
37
test_runner/src/main/kotlin/ftl/run/platform/common/BeforeRunMessage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,46 @@ | ||
package ftl.run.platform.common | ||
|
||
import ftl.args.IArgs | ||
import ftl.args.ShardChunks | ||
import ftl.config.FtlConstants | ||
import ftl.shard.Chunk | ||
import ftl.shard.TestMethod | ||
|
||
internal fun beforeRunMessage(args: IArgs, testShardChunks: ShardChunks): String { | ||
internal fun beforeRunMessage(args: IArgs, testShardChunks: List<Chunk>): String { | ||
val runCount = args.repeatTests | ||
val shardCount = testShardChunks.size | ||
val testsCount = testShardChunks.sumBy { it.size } | ||
val (classesCount, testsCount) = testShardChunks.partitionedTestCases.testAndClassesCount | ||
|
||
val result = StringBuilder() | ||
val testString = if (testsCount > 0) "$testsCount test${s(testsCount)}" else "" | ||
val classString = if (classesCount > 0) "$classesCount parameterized class${es(classesCount)}" else "" | ||
|
||
result.appendLine( | ||
" $testsCount test${s(testsCount)} / $shardCount shard${s(shardCount)}" | ||
"${FtlConstants.indent}$testString${if (testsCount * classesCount > 0) " + " else ""}$classString / $shardCount shard${s(shardCount)}" | ||
) | ||
|
||
if (runCount > 1) { | ||
result.appendLine(" Running ${runCount}x") | ||
val runDevices = runCount * shardCount | ||
val runTests = runCount * testsCount | ||
val runClasses = runCount * classesCount | ||
result.appendLine(" $runDevices total shard${s(runDevices)}") | ||
result.appendLine(" $runTests total test${s(runTests)}") | ||
if (runTests > 0) result.appendLine(" $runTests total test${s(runTests)}") | ||
if (runClasses > 0) result.appendLine(" $runClasses total parameterized class${es(runClasses)}") | ||
} | ||
|
||
return result.toString() | ||
} | ||
|
||
private fun s(amount: Int): String { | ||
return if (amount > 1) { | ||
"s" | ||
} else { | ||
"" | ||
} | ||
} | ||
private val List<Chunk>.partitionedTestCases | ||
get() = flatMap { it.testMethods }.partition { it.isParameterized } | ||
|
||
private val Pair<List<TestMethod>, List<TestMethod>>.testAndClassesCount | ||
get() = first.count() to second.count() | ||
|
||
private fun s(amount: Int): String = | ||
if (amount > 1) "s" | ||
else "" | ||
|
||
private fun es(amount: Int): String = | ||
if (amount > 1) "es" | ||
else "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package ftl.shard | ||
|
||
data class Chunk(val testMethods: List<TestMethod>) { | ||
val testMethodNames = testMethods.map { it.name } | ||
val size get() = testMethods.size | ||
} | ||
|
||
val List<Chunk>.testCases | ||
get() = map { it.testMethodNames } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does
keys
list need this new value to be able to be checked by flank doctor?defaultTestTime
is also missing inkey
list.