Skip to content
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

Update to use dash naming on flank yml params #519

Merged
merged 2 commits into from
Mar 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ gcloud:
## Invoke a test asynchronously without waiting for test results.
# async: false

## The billing enabled Google Cloud Platform project name to use
# project: delta-essence-114723

## The history name for your test results (an arbitrary string label; default: the application's label from the APK manifest).
## 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.
# results-history-name: android-history
Expand Down Expand Up @@ -117,25 +114,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 All @@ -151,6 +148,9 @@ flank:
## test targets - a list of tests to run. omit to run all tests.
# test-targets:
# - className/testName

## The billing enabled Google Cloud Platform project name to use
# project: delta-essence-114723
```

### Android example
Expand Down Expand Up @@ -186,9 +186,6 @@ gcloud:
## Invoke a test asynchronously without waiting for test results.
# async: false

## The billing enabled Google Cloud Platform project name to use
# project: delta-essence-114723

## The history name for your test results (an arbitrary string label; default: the application's label from the APK manifest).
## 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.
# results-history-name: android-history
Expand Down Expand Up @@ -259,23 +256,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 All @@ -285,6 +282,9 @@ flank:
## regex is matched against bucket paths, for example: 2019-01-09_00:13:06.106000_YCKl/shard_0/NexusLowRes-28-en-portrait/bugreport.txt
# files-to-download:
# - .*\.mp4$

## The billing enabled Google Cloud Platform project name to use
# project: delta-essence-114723
```

### Android code coverage
Expand Down
1 change: 1 addition & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- [#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))
- [#514](https://github.com/TestArmada/flank/pull/514) Rename `testShards` to `maxTestShards` ([miguelslemos](https://github.com/miguelslemos))
- [#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))
- [#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))

## v4.4.0

Expand Down
18 changes: 9 additions & 9 deletions test_runner/flank.ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ gcloud:
## Invoke a test asynchronously without waiting for test results.
# async: false

## The billing enabled Google Cloud Platform project name to use
# project: delta-essence-114723

## The history name for your test results (an arbitrary string label; default: the application's label from the APK manifest).
## 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.
# results-history-name: android-history
Expand Down Expand Up @@ -70,23 +67,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 All @@ -102,3 +99,6 @@ flank:
## test targets - a list of tests to run. omit to run all tests.
# test-targets:
# - className/testName

## The billing enabled Google Cloud Platform project name to use
# project: delta-essence-114723
18 changes: 9 additions & 9 deletions test_runner/flank.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ gcloud:
## Invoke a test asynchronously without waiting for test results.
# async: false

## The billing enabled Google Cloud Platform project name to use
# project: delta-essence-114723

## The history name for your test results (an arbitrary string label; default: the application's label from the APK manifest).
## 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.
# results-history-name: android-history
Expand Down Expand Up @@ -95,23 +92,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 All @@ -121,3 +118,6 @@ flank:
## regex is matched against bucket paths, for example: 2019-01-09_00:13:06.106000_YCKl/shard_0/NexusLowRes-28-en-portrait/bugreport.txt
# files-to-download:
# - .*\.mp4$

## The billing enabled Google Cloud Platform project name to use
# project: delta-essence-114723
14 changes: 7 additions & 7 deletions test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class AndroidArgs(
override val recordVideo = cli?.recordVideo ?: cli?.noRecordVideo?.not() ?: gcloud.recordVideo
override val testTimeout = cli?.timeout ?: gcloud.timeout
override val async = cli?.async ?: gcloud.async
override val project = cli?.project ?: gcloud.project
override val resultsHistoryName = cli?.resultsHistoryName ?: gcloud.resultsHistoryName
override val flakyTestAttempts = cli?.flakyTestAttempts ?: gcloud.flakyTestAttempts

Expand All @@ -72,6 +71,7 @@ class AndroidArgs(
override val testTargetsAlwaysRun = cli?.testTargetsAlwaysRun ?: flank.testTargetsAlwaysRun
override val filesToDownload = cli?.filesToDownload ?: flank.filesToDownload
override val disableSharding = cli?.disableSharding ?: flank.disableSharding
override val project = cli?.project ?: flank.project

// computed properties not specified in yaml
override val testShardChunks: List<List<String>> by lazy {
Expand Down Expand Up @@ -145,7 +145,6 @@ AndroidArgs
record-video: $recordVideo
timeout: $testTimeout
async: $async
project: $project
results-history-name: $resultsHistoryName
# Android gcloud
app: $appApk
Expand All @@ -164,15 +163,16 @@ ${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
project: $project
""".trimIndent()
}

Expand Down
8 changes: 5 additions & 3 deletions test_runner/src/main/kotlin/ftl/args/ArgsHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import ftl.config.FtlConstants
import ftl.config.FtlConstants.GCS_PREFIX
import ftl.config.FtlConstants.JSON_FACTORY
import ftl.config.FtlConstants.defaultCredentialPath
import ftl.config.FtlConstants.useMock
import ftl.gc.GcStorage
import ftl.gc.GcToolResults
import ftl.reports.xml.model.JUnitTestResult
import ftl.shard.Shard
import ftl.shard.StringShards
Expand Down Expand Up @@ -105,9 +107,9 @@ object ArgsHelper {
}

fun createGcsBucket(projectId: String, bucket: String): String {
// com.google.cloud.storage.contrib.nio.testing.FakeStorageRpc doesn't support list
// when testing, use a hard coded results bucket instead.
if (FtlConstants.useMock) return bucket
if (bucket.isEmpty()) return GcToolResults.getDefaultBucket(projectId) ?: throw RuntimeException("Failed to make bucket for $projectId")
if (useMock) return bucket

// test lab supports using a special free storage bucket
// because we don't have access to the root account, it won't show up in the storage list.
if (bucket.startsWith("test-lab-")) return bucket
Expand Down
14 changes: 7 additions & 7 deletions test_runner/src/main/kotlin/ftl/args/IosArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class IosArgs(
override val recordVideo = cli?.recordVideo ?: cli?.noRecordVideo?.not() ?: gcloud.recordVideo
override val testTimeout = cli?.timeout ?: gcloud.timeout
override val async = cli?.async ?: gcloud.async
override val project = cli?.project ?: gcloud.project
override val resultsHistoryName = cli?.resultsHistoryName ?: gcloud.resultsHistoryName
override val flakyTestAttempts = cli?.flakyTestAttempts ?: gcloud.flakyTestAttempts

Expand All @@ -56,6 +55,7 @@ class IosArgs(
override val testTargetsAlwaysRun = cli?.testTargetsAlwaysRun ?: flank.testTargetsAlwaysRun
override val filesToDownload = cli?.filesToDownload ?: flank.filesToDownload
override val disableSharding = cli?.disableSharding ?: flank.disableSharding
override val project = cli?.project ?: flank.project

private val iosFlank = iosFlankYml.flank
val testTargets = cli?.testTargets ?: iosFlank.testTargets
Expand Down Expand Up @@ -109,7 +109,6 @@ IosArgs
record-video: $recordVideo
timeout: $testTimeout
async: $async
project: $project
results-history-name: $resultsHistoryName
# iOS gcloud
test: $xctestrunZip
Expand All @@ -120,18 +119,19 @@ ${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
project: $project
""".trimIndent()
}

Expand Down
35 changes: 28 additions & 7 deletions test_runner/src/main/kotlin/ftl/args/yml/FlankYml.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,62 @@ package ftl.args.yml

import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonProperty
import ftl.args.ArgsHelper
import ftl.config.FtlConstants
import ftl.config.FtlConstants.GCS_PREFIX
import ftl.util.Utils
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")
val testTargetsAlwaysRun: List<String> = emptyList(),

@field:JsonProperty("files-to-download")
val filesToDownload: List<String> = emptyList()
val filesToDownload: List<String> = emptyList(),

val project: String = ArgsHelper.getDefaultProjectId() ?: ""
) {
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", "project"
)
}

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")
Utils.assertNotEmpty(
project, "The project is not set. Define GOOGLE_CLOUD_PROJECT, set project in flank.yml\n" +
"or save service account credential to ${FtlConstants.defaultCredentialPath}\n" +
" See https://github.com/GoogleCloudPlatform/google-cloud-java#specifying-a-project-id"
)

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
Loading