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

Add option to prevent uploading results for Smart Flank #537

Merged
merged 6 commits into from
Apr 5, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ flank:
## Google cloud storage path to store the JUnit XML results from the last run.
# smart-flank-gcs-path: gs://tmp_flank/flank/test_app_ios.xml

## Whether the JUnit XML results should be uploaded for Smart Flank.
## This can be disabled to prevent new results from overriding previous results.
## Default: true
# smart-flank-upload-enabled: true

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

Expand Down Expand Up @@ -274,6 +279,11 @@ flank:
## Google cloud storage path to store the JUnit XML results from the last run.
# smart-flank-gcs-path: gs://tmp_flank/flank/test_app_android.xml

## Whether the JUnit XML results should be uploaded for Smart Flank.
## This can be disabled to prevent new results from overriding previous results.
## Default: true
# smart-flank-upload-enabled: true

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

Expand Down
1 change: 0 additions & 1 deletion docs/smart_flank.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,3 @@ Example:

* Keep a user configurable rolling number of aggregated xmls (1.xml, 2.xml, 3.xml) and shard based on the average time. Average time is expected to be more reliable than always using the last time in isolation.
* Identify a way of translating app binary to a default xml name (bundle id/package name) so that smart flank works out of the box for users. Talk with Firebase on how to do this locally and/or expose an API.
* Provide an option to disable uploading so that local runs don't update time information for CI/pull request runs.
2 changes: 1 addition & 1 deletion release_notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## next (unreleased)

-
- [#537](https://github.com/TestArmada/flank/pull/537) Add `smart-flank-upload-enabled` yml option to prevent new results from overriding previous results. ([elihart](https://github.com/elihart))

## v5.0.1

Expand Down
5 changes: 5 additions & 0 deletions test_runner/flank.ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ flank:
## Google cloud storage path to store the JUnit XML results from the last run.
# smart-flank-gcs-path: gs://tmp_flank/flank/test_app_ios.xml

## Whether the JUnit XML results should be uploaded for Smart Flank.
## This can be disabled to prevent new results from overriding previous results.
## Default: true
# smart-flank-upload-enabled: true

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

Expand Down
5 changes: 5 additions & 0 deletions test_runner/flank.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ flank:
## Google cloud storage path to store the JUnit XML results from the last run.
# smart-flank-gcs-path: gs://tmp_flank/flank/test_app_android.xml

## Whether the JUnit XML results should be uploaded for Smart Flank.
## This can be disabled to prevent new results from overriding previous results.
## Default: true
# smart-flank-upload-enabled: true

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for consistency with disable-sharding, I'd like the flag renamed to:

smart-flank-disable-upload

then in the code we can check args.smartFlankDisableUpload instead of !args.smartFlankUploadEnabled.

The description can be written like this:

Disables smart flank JUnit XML uploading. Useful for preventing timing data from being updated.

I'm happy to make both changes if you'd like.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure thing, I'll do it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thanks. After that I'll merge the PR.

Expand Down
2 changes: 2 additions & 0 deletions test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class AndroidArgs(
override val shardTime = cli?.shardTime ?: flank.shardTime
override val repeatTests = cli?.repeatTests ?: flank.repeatTests
override val smartFlankGcsPath = flank.smartFlankGcsPath
override val smartFlankUploadEnabled = cli?.smartFlankUploadEnabled ?: flank.smartFlankUploadEnabled
override val testTargetsAlwaysRun = cli?.testTargetsAlwaysRun ?: flank.testTargetsAlwaysRun
override val filesToDownload = cli?.filesToDownload ?: flank.filesToDownload
override val disableSharding = cli?.disableSharding ?: flank.disableSharding
Expand Down Expand Up @@ -169,6 +170,7 @@ ${devicesToString(devices)}
shard-time: $shardTime
repeat-tests: $repeatTests
smart-flank-gcs-path: $smartFlankGcsPath
smart-flank-upload-enabled: $smartFlankUploadEnabled
files-to-download:
${listToString(filesToDownload)}
test-targets-always-run:
Expand Down
1 change: 1 addition & 0 deletions test_runner/src/main/kotlin/ftl/args/IArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface IArgs {
val shardTime: Int
val repeatTests: Int
val smartFlankGcsPath: String
val smartFlankUploadEnabled: Boolean
val testTargetsAlwaysRun: List<String>
val filesToDownload: List<String>
val disableSharding: Boolean
Expand Down
2 changes: 2 additions & 0 deletions test_runner/src/main/kotlin/ftl/args/IosArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class IosArgs(
override val shardTime = cli?.shardTime ?: flank.shardTime
override val repeatTests = cli?.repeatTests ?: flank.repeatTests
override val smartFlankGcsPath = flank.smartFlankGcsPath
override val smartFlankUploadEnabled = cli?.smartFlankUploadEnabled ?: flank.smartFlankUploadEnabled
override val testTargetsAlwaysRun = cli?.testTargetsAlwaysRun ?: flank.testTargetsAlwaysRun
override val filesToDownload = cli?.filesToDownload ?: flank.filesToDownload
override val disableSharding = cli?.disableSharding ?: flank.disableSharding
Expand Down Expand Up @@ -124,6 +125,7 @@ ${devicesToString(devices)}
shard-time: $shardTime
repeat-tests: $repeatTests
smart-flank-gcs-path: $smartFlankGcsPath
smart-flank-upload-enabled: $smartFlankUploadEnabled
test-targets-always-run:
${listToString(testTargetsAlwaysRun)}
files-to-download:
Expand Down
7 changes: 5 additions & 2 deletions test_runner/src/main/kotlin/ftl/args/yml/FlankYml.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class FlankYmlParams(
@field:JsonProperty("smart-flank-gcs-path")
val smartFlankGcsPath: String = "",

@field:JsonProperty("smart-flank-upload-enabled")
val smartFlankUploadEnabled: Boolean = true,

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

Expand All @@ -39,8 +42,8 @@ class FlankYmlParams(
) {
companion object : IYmlKeys {
override val keys = listOf(
"max-test-shards", "shard-time", "repeat-tests", "smart-flank-gcs-path", "disable-sharding",
"test-targets-always-run", "files-to-download", "project", "local-result-dir"
"max-test-shards", "shard-time", "repeat-tests", "smart-flank-gcs-path", "smart-flank-upload-enabled",
"disable-sharding", "test-targets-always-run", "files-to-download", "project", "local-result-dir"
)

const val defaultLocalResultDir = "results"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,10 @@ class AndroidRunCommand : Runnable {
description = ["Saves test result to this local folder. Deleted before each run."]
)
var localResultDir: String? = null

@Option(
names = ["--smart-flank-upload-enabled"],
description = ["Whether the JUnit XML results should be uploaded to the Smart Flank cloud storage."]
)
var smartFlankUploadEnabled: Boolean? = null
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,10 @@ class IosRunCommand : Runnable {
description = ["Saves test result to this local folder. Deleted before each run."]
)
var localResultsDir: String? = null

@Option(
names = ["--smart-flank-upload-enabled"],
description = ["Whether the JUnit XML results should be uploaded to the Smart Flank cloud storage."]
)
var smartFlankUploadEnabled: Boolean? = null
}
2 changes: 1 addition & 1 deletion test_runner/src/main/kotlin/ftl/gc/GcStorage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ object GcStorage {
)

fun uploadJunitXml(testResult: JUnitTestResult, args: IArgs) {
if (args.smartFlankGcsPath.isEmpty()) return
if (args.smartFlankGcsPath.isEmpty() || !args.smartFlankUploadEnabled) return

// bucket/path/to/object
val rawPath = args.smartFlankGcsPath.drop(GCS_PREFIX.length)
Expand Down
19 changes: 19 additions & 0 deletions test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ AndroidArgs
shard-time: 60
repeat-tests: 8
smart-flank-gcs-path:${' '}
smart-flank-upload-enabled: true
files-to-download:
- /sdcard/screenshots
- /sdcard/screenshots2
Expand Down Expand Up @@ -813,4 +814,22 @@ AndroidArgs
val androidArgs = AndroidArgs.load(yaml, cli)
assertThat(androidArgs.localResultDir).isEqualTo("b")
}

@Test
fun `cli smart-flank-upload-enabled`() {
val cli = AndroidRunCommand()
CommandLine(cli).parse("--smart-flank-upload-enabled=false")

val yaml = """
gcloud:
app: $appApk
test: $testApk
flank:
smart-flank-upload-enabled: true
"""
assertThat(AndroidArgs.load(yaml).smartFlankUploadEnabled).isEqualTo(true)

val androidArgs = AndroidArgs.load(yaml, cli)
assertThat(androidArgs.smartFlankUploadEnabled).isEqualTo(false)
}
}
17 changes: 17 additions & 0 deletions test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ IosArgs
shard-time: 60
repeat-tests: 8
smart-flank-gcs-path:${' '}
smart-flank-upload-enabled: true
test-targets-always-run:
- a/testGrantPermissions
- a/testGrantPermissions2
Expand Down Expand Up @@ -634,6 +635,22 @@ IosArgs
assertThat(androidArgs.localResultDir).isEqualTo("a")
}

@Test
fun `cli smart-flank-upload-enabled`() {
val cli = IosRunCommand()
CommandLine(cli).parse("--smart-flank-upload-enabled=false")

val yaml = """
gcloud:
test: $testPath
xctestrun-file: $testPath
"""
assertThat(IosArgs.load(yaml).smartFlankUploadEnabled).isEqualTo(true)

val androidArgs = IosArgs.load(yaml, cli)
assertThat(androidArgs.smartFlankUploadEnabled).isEqualTo(false)
}

private fun getValidTestsSample() = listOf(
"ClassOneTest/testOne",
"ClassOneTest/testTwo",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class AndroidRunCommandTest {
assertThat(cmd.flakyTestAttempts).isNull()
assertThat(cmd.disableSharding).isNull()
assertThat(cmd.localResultDir).isNull()
assertThat(cmd.smartFlankUploadEnabled).isNull()
}

@Test
Expand Down Expand Up @@ -320,4 +321,12 @@ class AndroidRunCommandTest {

assertThat(cmd.localResultDir).isEqualTo("a")
}

@Test
fun `smartFlankUploadEnabled parse`() {
val cmd = AndroidRunCommand()
CommandLine(cmd).parse("--smart-flank-upload-enabled=false")

assertThat(cmd.smartFlankUploadEnabled).isEqualTo(false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class IosRunCommandTest {
assertThat(cmd.resultsDir).isNull()
assertThat(cmd.flakyTestAttempts).isNull()
assertThat(cmd.localResultsDir).isNull()
assertThat(cmd.smartFlankUploadEnabled).isNull()
}

@Test
Expand Down Expand Up @@ -255,4 +256,12 @@ class IosRunCommandTest {

assertThat(cmd.localResultsDir).isEqualTo("a")
}

@Test
fun `smart-flank-upload-enabled parse`() {
val cmd = IosRunCommand()
CommandLine(cmd).parse("--smart-flank-upload-enabled=false")

assertThat(cmd.smartFlankUploadEnabled).isEqualTo(false)
}
}