-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #1601 ## Test Plan > How do we know the code works? When use ```--dump-shards```, flank should create dump shard file without errors. ## Checklist - [X] Unit tested - [X] Integration tests updated
- Loading branch information
1 parent
d476321
commit 68166db
Showing
11 changed files
with
150 additions
and
6 deletions.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
integration_tests/src/test/kotlin/integration/DumpShardsIT.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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package integration | ||
|
||
import FlankCommand | ||
import com.google.common.truth.Truth | ||
import flank.common.isWindows | ||
import org.junit.Assume | ||
import org.junit.Test | ||
import run | ||
import utils.containsAll | ||
import utils.loadAndroidDumpShards | ||
import utils.loadIosDumpShards | ||
import java.io.File | ||
|
||
class DumpShardsIT { | ||
private val name = this::class.java.simpleName | ||
|
||
@Test | ||
fun `dump shards - android`() { | ||
val name = "$name-android" | ||
val result = FlankCommand( | ||
flankPath = FLANK_JAR_PATH, | ||
ymlPath = "$CONFIGS_PATH/dump_shards_android.yml", | ||
params = androidRunCommands + "--dump-shards" | ||
).run( | ||
workingDirectory = "./", | ||
testSuite = name | ||
) | ||
|
||
assertExitCode(result, 0) | ||
|
||
val resOutput = result.output.removeUnicode() | ||
Truth.assertThat(resOutput).containsMatch(findInCompare(name)) | ||
assertNoOutcomeSummary(resOutput) | ||
|
||
val matrix = File("android_shards.json").loadAndroidDumpShards() | ||
|
||
Truth.assertThat(matrix.shards.count()).isEqualTo(2) | ||
|
||
Truth.assertThat(matrix.shards.values.flatten()).containsAll( | ||
"class com.example.test_app.parametrized.EspressoParametrizedClassParameterizedNamed", | ||
"class com.example.test_app.parametrized.EspressoParametrizedClassTestParameterized", | ||
"class com.example.test_app.ParameterizedTest", | ||
"class com.example.test_app.parametrized.EspressoParametrizedMethodTestJUnitParamsRunner", | ||
) | ||
|
||
Truth.assertThat(matrix.junitIgnored.count()).isEqualTo(4) | ||
Truth.assertThat(matrix.junitIgnored).containsNoDuplicates() | ||
|
||
Truth.assertThat(matrix.junitIgnored) | ||
.containsExactly( | ||
"class com.example.test_app.InstrumentedTest#ignoredTestWitSuppress", | ||
"class com.example.test_app.InstrumentedTest#ignoredTestWithIgnore", | ||
"class com.example.test_app.bar.BarInstrumentedTest#ignoredTestBar", | ||
"class com.example.test_app.foo.FooInstrumentedTest#ignoredTestFoo" | ||
) | ||
} | ||
|
||
@Test | ||
fun `dump shards - ios`() { | ||
Assume.assumeFalse(isWindows) | ||
val name = "$name-ios" | ||
val result = FlankCommand( | ||
flankPath = FLANK_JAR_PATH, | ||
ymlPath = "$CONFIGS_PATH/dump_shards_ios.yml", | ||
params = iosRunCommands + "--dump-shards" | ||
).run( | ||
workingDirectory = "./", | ||
testSuite = name | ||
) | ||
|
||
assertExitCode(result, 0) | ||
|
||
val resOutput = result.output.removeUnicode() | ||
Truth.assertThat(resOutput).containsMatch(findInCompare(name)) | ||
assertNoOutcomeSummary(resOutput) | ||
|
||
val shards = File("ios_shards.json").loadIosDumpShards() | ||
|
||
Truth.assertThat(shards.count()).isEqualTo(2) | ||
|
||
shards.first().let { firstShard -> | ||
Truth.assertThat(firstShard.count()).isEqualTo(8) | ||
Truth.assertThat(firstShard) | ||
.contains("EarlGreyExampleSwiftTests/testWithCustomFailureHandler") | ||
} | ||
} | ||
} |
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,9 +1,19 @@ | ||
package utils | ||
|
||
import com.fasterxml.jackson.databind.json.JsonMapper | ||
import com.fasterxml.jackson.dataformat.xml.XmlMapper | ||
import com.fasterxml.jackson.module.kotlin.KotlinModule | ||
import com.fasterxml.jackson.module.kotlin.readValue | ||
import utils.testResults.TestSuites | ||
import java.io.File | ||
|
||
fun File.loadAsTestSuite(): TestSuites = | ||
XmlMapper().registerModule(KotlinModule()).readValue(this, TestSuites::class.java) | ||
|
||
fun File.loadAndroidDumpShards() = jsonMapper | ||
.readValue<AndroidMatrixTestShards>(this).entries.first().value | ||
|
||
fun File.loadIosDumpShards() = jsonMapper | ||
.readValue<IosMatrixTestShards>(this) | ||
|
||
private val jsonMapper by lazy { JsonMapper().registerModule(KotlinModule()) } |
15 changes: 15 additions & 0 deletions
15
integration_tests/src/test/kotlin/utils/MatrixTestShards.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package utils | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
|
||
typealias AndroidMatrixTestShards = Map<String, AndroidTestShards> | ||
|
||
data class AndroidTestShards( | ||
val app: String, | ||
val test: String, | ||
val shards: Map<String, List<String>> = emptyMap(), | ||
@JsonProperty("junit-ignored") | ||
val junitIgnored: List<String> = emptyList() | ||
) | ||
|
||
typealias IosMatrixTestShards = List<List<String>> |
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
9 changes: 9 additions & 0 deletions
9
integration_tests/src/test/resources/cases/dump_shards_android.yml
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 @@ | ||
gcloud: | ||
app: ../test_runner/src/test/kotlin/ftl/fixtures/tmp/apk/app-debug.apk | ||
test: ../test_runner/src/test/kotlin/ftl/fixtures/tmp/apk/app-multiple-success-debug-androidTest.apk | ||
use-orchestrator: false | ||
|
||
flank: | ||
disable-sharding: false | ||
max-test-shards: 2 | ||
output-style: single |
8 changes: 8 additions & 0 deletions
8
integration_tests/src/test/resources/cases/dump_shards_ios.yml
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,8 @@ | ||
gcloud: | ||
test: ../test_runner/src/test/kotlin/ftl/fixtures/tmp/ios/EarlGreyExample/EarlGreyExample.zip | ||
xctestrun-file: ../test_runner/src/test/kotlin/ftl/fixtures/tmp/ios/EarlGreyExample/EarlGreyExampleSwiftTests.xctestrun | ||
|
||
flank: | ||
disable-sharding: false | ||
max-test-shards: 2 | ||
output-style: single |
1 change: 1 addition & 0 deletions
1
integration_tests/src/test/resources/compare/DumpShardsIT-android-compare
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 @@ | ||
Saved 2 shards to android_shards.json |
1 change: 1 addition & 0 deletions
1
integration_tests/src/test/resources/compare/DumpShardsIT-ios-compare
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 @@ | ||
Saved 2 shards to ios_shards.json |
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