Skip to content

Commit

Permalink
Update to use dash naming on flank yml params
Browse files Browse the repository at this point in the history
FlankYmlParams
    maxTestShards -> max-test-shards
    shardTime -> shard-time
    repeatTests -> repeat-tests
    smartFlankGcsPath -> smart-flank-gcs-path
    disableSharding -> disable-sharding
  • Loading branch information
bootstraponline committed Mar 13, 2019
1 parent 569e1dd commit 516b5c4
Show file tree
Hide file tree
Showing 17 changed files with 136 additions and 91 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,25 +117,25 @@ gcloud:
flank:
# -- FlankYml --

## test shards - the maxmimum amount of groups to split the test suite into
## test shards - the amount of groups to split the test suite into
## set to -1 to use one shard per test. default: 1
# maxTestShards: 1
# max-test-shards: 1

## shard time - the amount of time tests within a shard should take
## when set to > 0, the shard count is dynamically set based on time up to the maxmimum limit defined by maxTestShards
## when set to > 0, the shard count is dynamically set based on time up to the maxmimum limit defined by max-test-shards
## 2 minutes (120) is recommended.
## default: -1 (unlimited)
# shardTime: -1
# shard-time: -1

## repeat tests - the amount of times to run the tests.
## 1 runs the tests once. 10 runs all the tests 10x
# repeatTests: 1
# repeat-tests: 1

## Google cloud storage path to store the JUnit XML results from the last run.
# smartFlankGcsPath: gs://tmp_flank/flank/test_app_ios.xml
# smart-flank-gcs-path: gs://tmp_flank/flank/test_app_ios.xml

## Disables sharding. Useful for parameterized tests.
# disableSharding: false
# disable-sharding: false

## always run - these tests are inserted at the beginning of every shard
## useful if you need to grant permissions or login before other tests run
Expand Down Expand Up @@ -259,23 +259,23 @@ flank:

## test shards - the amount of groups to split the test suite into
## set to -1 to use one shard per test. default: 1
# maxTestShards: 1
# max-test-shards: 1

## shard time - the amount of time tests within a shard should take
## when set to > 0, the shard count is dynamically set based on time up to the maxmimum limit defined by maxTestShards
## when set to > 0, the shard count is dynamically set based on time up to the maxmimum limit defined by max-test-shards
## 2 minutes (120) is recommended.
## default: -1 (unlimited)
# shardTime: -1
# shard-time: -1

## repeat tests - the amount of times to run the tests.
## 1 runs the tests once. 10 runs all the tests 10x
# repeatTests: 1
# repeat-tests: 1

## Google cloud storage path to store the JUnit XML results from the last run.
# smartFlankGcsPath: gs://tmp_flank/flank/test_app_android.xml
# smart-flank-gcs-path: gs://tmp_flank/flank/test_app_android.xml

## Disables sharding. Useful for parameterized tests.
# disableSharding: false
# disable-sharding: false

## always run - these tests are inserted at the beginning of every shard
## useful if you need to grant permissions or login before other tests run
Expand Down
12 changes: 6 additions & 6 deletions test_runner/flank.ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,23 @@ flank:

## test shards - the amount of groups to split the test suite into
## set to -1 to use one shard per test. default: 1
# maxTestShards: 1
# max-test-shards: 1

## shard time - the amount of time tests within a shard should take
## when set to > 0, the shard count is dynamically set based on time up to the maxmimum limit defined by maxTestShards
## when set to > 0, the shard count is dynamically set based on time up to the maxmimum limit defined by max-test-shards
## 2 minutes (120) is recommended.
## default: -1 (unlimited)
# shardTime: -1
# shard-time: -1

## repeat tests - the amount of times to run the tests.
## 1 runs the tests once. 10 runs all the tests 10x
# repeatTests: 1
# repeat-tests: 1

## Google cloud storage path to store the JUnit XML results from the last run.
# smartFlankGcsPath: gs://tmp_flank/flank/test_app_ios.xml
# smart-flank-gcs-path: gs://tmp_flank/flank/test_app_ios.xml

## Disables sharding. Useful for parameterized tests.
# disableSharding: false
# disable-sharding: false

## always run - these tests are inserted at the beginning of every shard
## useful if you need to grant permissions or login before other tests run
Expand Down
12 changes: 6 additions & 6 deletions test_runner/flank.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,23 @@ flank:

## test shards - the amount of groups to split the test suite into
## set to -1 to use one shard per test. default: 1
# maxTestShards: 1
# max-test-shards: 1

## shard time - the amount of time tests within a shard should take
## when set to > 0, the shard count is dynamically set based on time up to the maxmimum limit defined by maxTestShards
## when set to > 0, the shard count is dynamically set based on time up to the maxmimum limit defined by max-test-shards
## 2 minutes (120) is recommended.
## default: -1 (unlimited)
# shardTime: -1
# shard-time: -1

## repeat tests - the amount of times to run the tests.
## 1 runs the tests once. 10 runs all the tests 10x
# repeatTests: 1
# repeat-tests: 1

## Google cloud storage path to store the JUnit XML results from the last run.
# smartFlankGcsPath: gs://tmp_flank/flank/test_app_android.xml
# smart-flank-gcs-path: gs://tmp_flank/flank/test_app_android.xml

## Disables sharding. Useful for parameterized tests.
# disableSharding: false
# disable-sharding: false

## always run - these tests are inserted at the beginning of every shard
## useful if you need to grant permissions or login before other tests run
Expand Down
10 changes: 5 additions & 5 deletions test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ ${devicesToString(devices)}
flaky-test-attempts: $flakyTestAttempts
flank:
maxTestShards: $maxTestShards
shardTime: $shardTime
repeatTests: $repeatTests
smartFlankGcsPath: $smartFlankGcsPath
max-test-shards: $maxTestShards
shard-time: $shardTime
repeat-tests: $repeatTests
smart-flank-gcs-path: $smartFlankGcsPath
files-to-download:
${listToString(filesToDownload)}
test-targets-always-run:
${listToString(testTargetsAlwaysRun)}
disableSharding: $disableSharding
disable-sharding: $disableSharding
""".trimIndent()
}

Expand Down
10 changes: 5 additions & 5 deletions test_runner/src/main/kotlin/ftl/args/IosArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,18 @@ ${devicesToString(devices)}
flaky-test-attempts: $flakyTestAttempts
flank:
maxTestShards: $maxTestShards
shardTime: $shardTime
repeatTests: $repeatTests
smartFlankGcsPath: $smartFlankGcsPath
max-test-shards: $maxTestShards
shard-time: $shardTime
repeat-tests: $repeatTests
smart-flank-gcs-path: $smartFlankGcsPath
test-targets-always-run:
${listToString(testTargetsAlwaysRun)}
files-to-download:
${listToString(filesToDownload)}
# iOS flank
test-targets:
${listToString(testTargets)}
disableSharding: $disableSharding
disable-sharding: $disableSharding
""".trimIndent()
}

Expand Down
22 changes: 16 additions & 6 deletions test_runner/src/main/kotlin/ftl/args/yml/FlankYml.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@ import ftl.util.Utils.fatalError
/** Flank specific parameters for both iOS and Android */
@JsonIgnoreProperties(ignoreUnknown = true)
class FlankYmlParams(
@field:JsonProperty("max-test-shards")
val maxTestShards: Int = 1,

@field:JsonProperty("shard-time")
val shardTime: Int = -1,

@field:JsonProperty("repeat-tests")
val repeatTests: Int = 1,

@field:JsonProperty("smart-flank-gcs-path")
val smartFlankGcsPath: String = "",

@field:JsonProperty("disable-sharding")
val disableSharding: Boolean = false,

@field:JsonProperty("test-targets-always-run")
Expand All @@ -22,21 +31,22 @@ class FlankYmlParams(
) {
companion object : IYmlKeys {
override val keys = listOf(
"maxTestShards", "shardTime", "repeatTests", "smartFlankGcsPath", "disableSharding", "test-targets-always-run", "files-to-download"
"max-test-shards", "shard-time", "repeat-tests", "smart-flank-gcs-path", "disable-sharding",
"test-targets-always-run", "files-to-download"
)
}

init {
if (maxTestShards <= 0 && maxTestShards != -1) fatalError("maxTestShards must be >= 1 or -1")
if (shardTime <= 0 && shardTime != -1) fatalError("shardTime must be >= 1 or -1")
if (repeatTests < 1) fatalError("repeatTests must be >= 1")
if (maxTestShards <= 0 && maxTestShards != -1) fatalError("max-test-shards must be >= 1 or -1")
if (shardTime <= 0 && shardTime != -1) fatalError("shard-time must be >= 1 or -1")
if (repeatTests < 1) fatalError("repeat-tests must be >= 1")

if (smartFlankGcsPath.isNotEmpty()) {
if (!smartFlankGcsPath.startsWith(GCS_PREFIX)) {
fatalError("smartFlankGcsPath must start with gs://")
fatalError("smart-flank-gcs-path must start with gs://")
}
if (smartFlankGcsPath.count { it == '/' } <= 2 || !smartFlankGcsPath.endsWith(".xml")) {
fatalError("smartFlankGcsPath must be in the format gs://bucket/foo.xml")
fatalError("smart-flank-gcs-path must be in the format gs://bucket/foo.xml")
}
}
}
Expand Down
24 changes: 22 additions & 2 deletions test_runner/src/main/kotlin/ftl/args/yml/YamlDeprecated.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,28 @@ object YamlDeprecated {
private val transforms = listOf(
// flank: testShards -> flank: maxTestShards
ModifiedKey(
Key(YamlDeprecated.Parent.flank, "testShards"),
Key(YamlDeprecated.Parent.flank, "maxTestShards"),
Key(Parent.flank, "testShards"),
Key(Parent.flank, "max-test-shards"),
Level.Warning
),
ModifiedKey(
Key(Parent.flank, "shardTime"),
Key(Parent.flank, "shard-time"),
Level.Warning
),
ModifiedKey(
Key(Parent.flank, "repeatTests"),
Key(Parent.flank, "repeat-tests"),
Level.Warning
),
ModifiedKey(
Key(Parent.flank, "smartFlankGcsPath"),
Key(Parent.flank, "smart-flank-gcs-path"),
Level.Warning
),
ModifiedKey(
Key(Parent.flank, "disableSharding"),
Key(Parent.flank, "disable-sharding"),
Level.Warning
)
)
Expand Down
30 changes: 15 additions & 15 deletions test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@ class AndroidArgsTest {
flaky-test-attempts: 3
flank:
maxTestShards: 7
shardTime: 60
repeatTests: 8
max-test-shards: 7
shard-time: 60
repeat-tests: 8
files-to-download:
- /sdcard/screenshots
- /sdcard/screenshots2
test-targets-always-run:
- class example.Test#grantPermission
- class example.Test#grantPermission2
disableSharding: true
disable-sharding: true
"""

@Rule
Expand Down Expand Up @@ -215,17 +215,17 @@ AndroidArgs
flaky-test-attempts: 3
flank:
maxTestShards: 7
shardTime: 60
repeatTests: 8
smartFlankGcsPath:${' '}
max-test-shards: 7
shard-time: 60
repeat-tests: 8
smart-flank-gcs-path:${' '}
files-to-download:
- /sdcard/screenshots
- /sdcard/screenshots2
test-targets-always-run:
- class example.Test#grantPermission
- class example.Test#grantPermission2
disableSharding: true
disable-sharding: true
""".trimIndent()
)
}
Expand Down Expand Up @@ -278,7 +278,7 @@ AndroidArgs
test: $testErrorApk
flank:
maxTestShards: -1
max-test-shards: -1
"""
)

Expand Down Expand Up @@ -312,7 +312,7 @@ AndroidArgs
app: $invalidApk
test: $invalidApk
flank:
disableSharding: true
disable-sharding: true
"""
AndroidArgs.load(yaml).testShardChunks
}
Expand Down Expand Up @@ -693,7 +693,7 @@ AndroidArgs
test: $testApk
flank:
maxTestShards: 2
max-test-shards: 2
"""
assertThat(AndroidArgs.load(yaml).maxTestShards).isEqualTo(2)
assertThat(AndroidArgs.load(yaml, cli).maxTestShards).isEqualTo(3)
Expand All @@ -710,7 +710,7 @@ AndroidArgs
test: $testApk
flank:
shardTime: 2
shard-time: 2
"""
assertThat(AndroidArgs.load(yaml).shardTime).isEqualTo(2)
assertThat(AndroidArgs.load(yaml, cli).shardTime).isEqualTo(3)
Expand All @@ -727,7 +727,7 @@ AndroidArgs
test: $testApk
flank:
disableSharding: false
disable-sharding: false
"""
assertThat(AndroidArgs.load(yaml).disableSharding).isEqualTo(false)
assertThat(AndroidArgs.load(yaml, cli).disableSharding).isEqualTo(true)
Expand All @@ -744,7 +744,7 @@ AndroidArgs
test: $testApk
flank:
repeatTests: 2
repeat-tests: 2
"""
assertThat(AndroidArgs.load(yaml).repeatTests).isEqualTo(2)
assertThat(AndroidArgs.load(yaml, cli).repeatTests).isEqualTo(3)
Expand Down
6 changes: 3 additions & 3 deletions test_runner/src/test/kotlin/ftl/args/FlankYmlTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ class FlankYmlTest {

@Test
fun testInvalidTestShards() {
exceptionRule.expectMessage("maxTestShards must be >= 1 or -1")
exceptionRule.expectMessage("max-test-shards must be >= 1 or -1")
FlankYml(FlankYmlParams(maxTestShards = -2))
}

@Test
fun testInvalidShardTime() {
exceptionRule.expectMessage("shardTime must be >= 1 or -1")
exceptionRule.expectMessage("shard-time must be >= 1 or -1")
FlankYml(FlankYmlParams(shardTime = -2))
}

@Test
fun testInvalidrepeatTests() {
exceptionRule.expectMessage("repeatTests must be >= 1")
exceptionRule.expectMessage("repeat-tests must be >= 1")
FlankYml(FlankYmlParams(repeatTests = 0))
}
}
Loading

0 comments on commit 516b5c4

Please sign in to comment.