Skip to content

Commit 10d5182

Browse files
Update to use dash naming on flank yml params (#519)
* Update to use dash naming on flank yml params FlankYmlParams maxTestShards -> max-test-shards shardTime -> shard-time repeatTests -> repeat-tests smartFlankGcsPath -> smart-flank-gcs-path disableSharding -> disable-sharding * Migrate project from gcloud to Flank
1 parent 569e1dd commit 10d5182

23 files changed

Lines changed: 224 additions & 139 deletions

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ gcloud:
7171
## Invoke a test asynchronously without waiting for test results.
7272
# async: false
7373

74-
## The billing enabled Google Cloud Platform project name to use
75-
# project: delta-essence-114723
76-
7774
## The history name for your test results (an arbitrary string label; default: the application's label from the APK manifest).
7875
## All tests which use the same history name will have their results grouped together in the Firebase console in a time-ordered test history list.
7976
# results-history-name: android-history
@@ -117,25 +114,25 @@ gcloud:
117114
flank:
118115
# -- FlankYml --
119116

120-
## test shards - the maxmimum amount of groups to split the test suite into
117+
## test shards - the amount of groups to split the test suite into
121118
## set to -1 to use one shard per test. default: 1
122-
# maxTestShards: 1
119+
# max-test-shards: 1
123120

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

130127
## repeat tests - the amount of times to run the tests.
131128
## 1 runs the tests once. 10 runs all the tests 10x
132-
# repeatTests: 1
129+
# repeat-tests: 1
133130

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

137134
## Disables sharding. Useful for parameterized tests.
138-
# disableSharding: false
135+
# disable-sharding: false
139136

140137
## always run - these tests are inserted at the beginning of every shard
141138
## useful if you need to grant permissions or login before other tests run
@@ -151,6 +148,9 @@ flank:
151148
## test targets - a list of tests to run. omit to run all tests.
152149
# test-targets:
153150
# - className/testName
151+
152+
## The billing enabled Google Cloud Platform project name to use
153+
# project: delta-essence-114723
154154
```
155155

156156
### Android example
@@ -186,9 +186,6 @@ gcloud:
186186
## Invoke a test asynchronously without waiting for test results.
187187
# async: false
188188

189-
## The billing enabled Google Cloud Platform project name to use
190-
# project: delta-essence-114723
191-
192189
## The history name for your test results (an arbitrary string label; default: the application's label from the APK manifest).
193190
## All tests which use the same history name will have their results grouped together in the Firebase console in a time-ordered test history list.
194191
# results-history-name: android-history
@@ -259,23 +256,23 @@ flank:
259256

260257
## test shards - the amount of groups to split the test suite into
261258
## set to -1 to use one shard per test. default: 1
262-
# maxTestShards: 1
259+
# max-test-shards: 1
263260

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

270267
## repeat tests - the amount of times to run the tests.
271268
## 1 runs the tests once. 10 runs all the tests 10x
272-
# repeatTests: 1
269+
# repeat-tests: 1
273270

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

277274
## Disables sharding. Useful for parameterized tests.
278-
# disableSharding: false
275+
# disable-sharding: false
279276

280277
## always run - these tests are inserted at the beginning of every shard
281278
## useful if you need to grant permissions or login before other tests run
@@ -285,6 +282,9 @@ flank:
285282
## regex is matched against bucket paths, for example: 2019-01-09_00:13:06.106000_YCKl/shard_0/NexusLowRes-28-en-portrait/bugreport.txt
286283
# files-to-download:
287284
# - .*\.mp4$
285+
286+
## The billing enabled Google Cloud Platform project name to use
287+
# project: delta-essence-114723
288288
```
289289

290290
### Android code coverage

release_notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- [#507](https://github.com/TestArmada/flank/pull/507) Improve error message when credentials fail to load, folder doesn't exist, and on bucket creation failure. Properly pass through user credential when checking the storage bucket. ([bootstraponline](https://github.com/bootstraponline))
55
- [#514](https://github.com/TestArmada/flank/pull/514) Rename `testShards` to `maxTestShards` ([miguelslemos](https://github.com/miguelslemos))
66
- [#518](https://github.com/TestArmada/flank/pull/518) Add deprecation warnings when old key names are used. `flank android doctor --fix` will auto fix the YAML file. ([bootstraponline](https://github.com/bootstraponline))
7+
- [#519](https://github.com/TestArmada/flank/pull/519) Rename `maxTestShards` to `max-test-shards`, `shardTime` to `shard-time`, `repeatTests` to `repeat-tests`, `smartFlankGcsPath` to `smart-flank-gcs-path`, `disableSharding` to `disable-sharding`. Moved `project` from `gcloud` to `flank` ([bootstraponline](https://github.com/bootstraponline))
78

89
## v4.4.0
910

test_runner/flank.ios.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ gcloud:
2222
## Invoke a test asynchronously without waiting for test results.
2323
# async: false
2424

25-
## The billing enabled Google Cloud Platform project name to use
26-
# project: delta-essence-114723
27-
2825
## The history name for your test results (an arbitrary string label; default: the application's label from the APK manifest).
2926
## All tests which use the same history name will have their results grouped together in the Firebase console in a time-ordered test history list.
3027
# results-history-name: android-history
@@ -70,23 +67,23 @@ flank:
7067

7168
## test shards - the amount of groups to split the test suite into
7269
## set to -1 to use one shard per test. default: 1
73-
# maxTestShards: 1
70+
# max-test-shards: 1
7471

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

8178
## repeat tests - the amount of times to run the tests.
8279
## 1 runs the tests once. 10 runs all the tests 10x
83-
# repeatTests: 1
80+
# repeat-tests: 1
8481

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

8885
## Disables sharding. Useful for parameterized tests.
89-
# disableSharding: false
86+
# disable-sharding: false
9087

9188
## always run - these tests are inserted at the beginning of every shard
9289
## useful if you need to grant permissions or login before other tests run
@@ -102,3 +99,6 @@ flank:
10299
## test targets - a list of tests to run. omit to run all tests.
103100
# test-targets:
104101
# - className/testName
102+
103+
## The billing enabled Google Cloud Platform project name to use
104+
# project: delta-essence-114723

test_runner/flank.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ gcloud:
2222
## Invoke a test asynchronously without waiting for test results.
2323
# async: false
2424

25-
## The billing enabled Google Cloud Platform project name to use
26-
# project: delta-essence-114723
27-
2825
## The history name for your test results (an arbitrary string label; default: the application's label from the APK manifest).
2926
## All tests which use the same history name will have their results grouped together in the Firebase console in a time-ordered test history list.
3027
# results-history-name: android-history
@@ -95,23 +92,23 @@ flank:
9592

9693
## test shards - the amount of groups to split the test suite into
9794
## set to -1 to use one shard per test. default: 1
98-
# maxTestShards: 1
95+
# max-test-shards: 1
9996

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

106103
## repeat tests - the amount of times to run the tests.
107104
## 1 runs the tests once. 10 runs all the tests 10x
108-
# repeatTests: 1
105+
# repeat-tests: 1
109106

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

113110
## Disables sharding. Useful for parameterized tests.
114-
# disableSharding: false
111+
# disable-sharding: false
115112

116113
## always run - these tests are inserted at the beginning of every shard
117114
## useful if you need to grant permissions or login before other tests run
@@ -121,3 +118,6 @@ flank:
121118
## regex is matched against bucket paths, for example: 2019-01-09_00:13:06.106000_YCKl/shard_0/NexusLowRes-28-en-portrait/bugreport.txt
122119
# files-to-download:
123120
# - .*\.mp4$
121+
122+
## The billing enabled Google Cloud Platform project name to use
123+
# project: delta-essence-114723

test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class AndroidArgs(
4747
override val recordVideo = cli?.recordVideo ?: cli?.noRecordVideo?.not() ?: gcloud.recordVideo
4848
override val testTimeout = cli?.timeout ?: gcloud.timeout
4949
override val async = cli?.async ?: gcloud.async
50-
override val project = cli?.project ?: gcloud.project
5150
override val resultsHistoryName = cli?.resultsHistoryName ?: gcloud.resultsHistoryName
5251
override val flakyTestAttempts = cli?.flakyTestAttempts ?: gcloud.flakyTestAttempts
5352

@@ -72,6 +71,7 @@ class AndroidArgs(
7271
override val testTargetsAlwaysRun = cli?.testTargetsAlwaysRun ?: flank.testTargetsAlwaysRun
7372
override val filesToDownload = cli?.filesToDownload ?: flank.filesToDownload
7473
override val disableSharding = cli?.disableSharding ?: flank.disableSharding
74+
override val project = cli?.project ?: flank.project
7575

7676
// computed properties not specified in yaml
7777
override val testShardChunks: List<List<String>> by lazy {
@@ -145,7 +145,6 @@ AndroidArgs
145145
record-video: $recordVideo
146146
timeout: $testTimeout
147147
async: $async
148-
project: $project
149148
results-history-name: $resultsHistoryName
150149
# Android gcloud
151150
app: $appApk
@@ -164,15 +163,16 @@ ${devicesToString(devices)}
164163
flaky-test-attempts: $flakyTestAttempts
165164
166165
flank:
167-
maxTestShards: $maxTestShards
168-
shardTime: $shardTime
169-
repeatTests: $repeatTests
170-
smartFlankGcsPath: $smartFlankGcsPath
166+
max-test-shards: $maxTestShards
167+
shard-time: $shardTime
168+
repeat-tests: $repeatTests
169+
smart-flank-gcs-path: $smartFlankGcsPath
171170
files-to-download:
172171
${listToString(filesToDownload)}
173172
test-targets-always-run:
174173
${listToString(testTargetsAlwaysRun)}
175-
disableSharding: $disableSharding
174+
disable-sharding: $disableSharding
175+
project: $project
176176
""".trimIndent()
177177
}
178178

test_runner/src/main/kotlin/ftl/args/ArgsHelper.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import ftl.config.FtlConstants
1616
import ftl.config.FtlConstants.GCS_PREFIX
1717
import ftl.config.FtlConstants.JSON_FACTORY
1818
import ftl.config.FtlConstants.defaultCredentialPath
19+
import ftl.config.FtlConstants.useMock
1920
import ftl.gc.GcStorage
21+
import ftl.gc.GcToolResults
2022
import ftl.reports.xml.model.JUnitTestResult
2123
import ftl.shard.Shard
2224
import ftl.shard.StringShards
@@ -105,9 +107,9 @@ object ArgsHelper {
105107
}
106108

107109
fun createGcsBucket(projectId: String, bucket: String): String {
108-
// com.google.cloud.storage.contrib.nio.testing.FakeStorageRpc doesn't support list
109-
// when testing, use a hard coded results bucket instead.
110-
if (FtlConstants.useMock) return bucket
110+
if (bucket.isEmpty()) return GcToolResults.getDefaultBucket(projectId) ?: throw RuntimeException("Failed to make bucket for $projectId")
111+
if (useMock) return bucket
112+
111113
// test lab supports using a special free storage bucket
112114
// because we don't have access to the root account, it won't show up in the storage list.
113115
if (bucket.startsWith("test-lab-")) return bucket

test_runner/src/main/kotlin/ftl/args/IosArgs.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class IosArgs(
3838
override val recordVideo = cli?.recordVideo ?: cli?.noRecordVideo?.not() ?: gcloud.recordVideo
3939
override val testTimeout = cli?.timeout ?: gcloud.timeout
4040
override val async = cli?.async ?: gcloud.async
41-
override val project = cli?.project ?: gcloud.project
4241
override val resultsHistoryName = cli?.resultsHistoryName ?: gcloud.resultsHistoryName
4342
override val flakyTestAttempts = cli?.flakyTestAttempts ?: gcloud.flakyTestAttempts
4443

@@ -56,6 +55,7 @@ class IosArgs(
5655
override val testTargetsAlwaysRun = cli?.testTargetsAlwaysRun ?: flank.testTargetsAlwaysRun
5756
override val filesToDownload = cli?.filesToDownload ?: flank.filesToDownload
5857
override val disableSharding = cli?.disableSharding ?: flank.disableSharding
58+
override val project = cli?.project ?: flank.project
5959

6060
private val iosFlank = iosFlankYml.flank
6161
val testTargets = cli?.testTargets ?: iosFlank.testTargets
@@ -109,7 +109,6 @@ IosArgs
109109
record-video: $recordVideo
110110
timeout: $testTimeout
111111
async: $async
112-
project: $project
113112
results-history-name: $resultsHistoryName
114113
# iOS gcloud
115114
test: $xctestrunZip
@@ -120,18 +119,19 @@ ${devicesToString(devices)}
120119
flaky-test-attempts: $flakyTestAttempts
121120
122121
flank:
123-
maxTestShards: $maxTestShards
124-
shardTime: $shardTime
125-
repeatTests: $repeatTests
126-
smartFlankGcsPath: $smartFlankGcsPath
122+
max-test-shards: $maxTestShards
123+
shard-time: $shardTime
124+
repeat-tests: $repeatTests
125+
smart-flank-gcs-path: $smartFlankGcsPath
127126
test-targets-always-run:
128127
${listToString(testTargetsAlwaysRun)}
129128
files-to-download:
130129
${listToString(filesToDownload)}
131130
# iOS flank
132131
test-targets:
133132
${listToString(testTargets)}
134-
disableSharding: $disableSharding
133+
disable-sharding: $disableSharding
134+
project: $project
135135
""".trimIndent()
136136
}
137137

test_runner/src/main/kotlin/ftl/args/yml/FlankYml.kt

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,62 @@ package ftl.args.yml
22

33
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
44
import com.fasterxml.jackson.annotation.JsonProperty
5+
import ftl.args.ArgsHelper
6+
import ftl.config.FtlConstants
57
import ftl.config.FtlConstants.GCS_PREFIX
8+
import ftl.util.Utils
69
import ftl.util.Utils.fatalError
710

811
/** Flank specific parameters for both iOS and Android */
912
@JsonIgnoreProperties(ignoreUnknown = true)
1013
class FlankYmlParams(
14+
@field:JsonProperty("max-test-shards")
1115
val maxTestShards: Int = 1,
16+
17+
@field:JsonProperty("shard-time")
1218
val shardTime: Int = -1,
19+
20+
@field:JsonProperty("repeat-tests")
1321
val repeatTests: Int = 1,
22+
23+
@field:JsonProperty("smart-flank-gcs-path")
1424
val smartFlankGcsPath: String = "",
25+
26+
@field:JsonProperty("disable-sharding")
1527
val disableSharding: Boolean = false,
1628

1729
@field:JsonProperty("test-targets-always-run")
1830
val testTargetsAlwaysRun: List<String> = emptyList(),
1931

2032
@field:JsonProperty("files-to-download")
21-
val filesToDownload: List<String> = emptyList()
33+
val filesToDownload: List<String> = emptyList(),
34+
35+
val project: String = ArgsHelper.getDefaultProjectId() ?: ""
2236
) {
2337
companion object : IYmlKeys {
2438
override val keys = listOf(
25-
"maxTestShards", "shardTime", "repeatTests", "smartFlankGcsPath", "disableSharding", "test-targets-always-run", "files-to-download"
39+
"max-test-shards", "shard-time", "repeat-tests", "smart-flank-gcs-path", "disable-sharding",
40+
"test-targets-always-run", "files-to-download", "project"
2641
)
2742
}
2843

2944
init {
30-
if (maxTestShards <= 0 && maxTestShards != -1) fatalError("maxTestShards must be >= 1 or -1")
31-
if (shardTime <= 0 && shardTime != -1) fatalError("shardTime must be >= 1 or -1")
32-
if (repeatTests < 1) fatalError("repeatTests must be >= 1")
45+
Utils.assertNotEmpty(
46+
project, "The project is not set. Define GOOGLE_CLOUD_PROJECT, set project in flank.yml\n" +
47+
"or save service account credential to ${FtlConstants.defaultCredentialPath}\n" +
48+
" See https://github.com/GoogleCloudPlatform/google-cloud-java#specifying-a-project-id"
49+
)
50+
51+
if (maxTestShards <= 0 && maxTestShards != -1) fatalError("max-test-shards must be >= 1 or -1")
52+
if (shardTime <= 0 && shardTime != -1) fatalError("shard-time must be >= 1 or -1")
53+
if (repeatTests < 1) fatalError("repeat-tests must be >= 1")
3354

3455
if (smartFlankGcsPath.isNotEmpty()) {
3556
if (!smartFlankGcsPath.startsWith(GCS_PREFIX)) {
36-
fatalError("smartFlankGcsPath must start with gs://")
57+
fatalError("smart-flank-gcs-path must start with gs://")
3758
}
3859
if (smartFlankGcsPath.count { it == '/' } <= 2 || !smartFlankGcsPath.endsWith(".xml")) {
39-
fatalError("smartFlankGcsPath must be in the format gs://bucket/foo.xml")
60+
fatalError("smart-flank-gcs-path must be in the format gs://bucket/foo.xml")
4061
}
4162
}
4263
}

0 commit comments

Comments
 (0)