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

feat: ios scenario numbers #1287

Merged
merged 5 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
14 changes: 14 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ gcloud:
# - gs://bucket/additional.ipa
# - path/to/local/ipa/file.ipa

## A list of game-loop scenario numbers which will be run as part of the test (default: all scenarios).
## A maximum of 1024 scenarios may be specified in one test matrix, but the maximum number may also be limited by the overall test --timeout setting.
# scenario-numbers:
# - 1
# - 2
# - 3

## The type of iOS test to run. TYPE must be one of: xctest, game-loop. Default: xctest
# type: xctest

Expand Down Expand Up @@ -361,6 +368,13 @@ gcloud:
# - local/file/path/test1.obb
# - local/file/path/test2.obb

## A list of game-loop scenario numbers which will be run as part of the test (default: all scenarios).
## A maximum of 1024 scenarios may be specified in one test matrix, but the maximum number may also be limited by the overall test --timeout setting.
# scenario-numbers:
# - 1
# - 2
# - 3

## A list of OBB required filenames. OBB file name must conform to the format as specified by Android e.g.
## [main|patch].0300110.com.example.android.obb which will be installed into <shared-storage>/Android/obb/<package-name>/ on the device.
# obb-names:
Expand Down
7 changes: 7 additions & 0 deletions test_runner/flank.ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ gcloud:
# - gs://bucket/additional.ipa
# - path/to/local/ipa/file.ipa

## A list of game-loop scenario numbers which will be run as part of the test (default: all scenarios).
## A maximum of 1024 scenarios may be specified in one test matrix, but the maximum number may also be limited by the overall test --timeout setting.
# scenario-numbers:
# - 1
# - 2
# - 3

## The type of iOS test to run. TYPE must be one of: xctest, game-loop. Default: xctest
# type: xctest

Expand Down
1 change: 0 additions & 1 deletion test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ data class AndroidArgs(
val environmentVariables: Map<String, String>, // should not be printed, becuase could contains sensitive informations
val directoriesToPull: List<String>,
val grantPermissions: String?,
val scenarioNumbers: List<String>,
val scenarioLabels: List<String>,
val obbFiles: List<String>,
val obbNames: List<String>,
Expand Down
1 change: 1 addition & 0 deletions test_runner/src/main/kotlin/ftl/args/CommonArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ data class CommonArgs(
override val networkProfile: String?,
override val otherFiles: Map<String, String>,
override val type: Type?,
override val scenarioNumbers: List<String>,

// flank
override val project: String,
Expand Down
1 change: 0 additions & 1 deletion test_runner/src/main/kotlin/ftl/args/CreateAndroidArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,5 @@ fun createAndroidArgs(
obfuscateDumpShards = obfuscate,
obbFiles = gcloud.obbfiles!!,
obbNames = gcloud.obbnames!!,
scenarioNumbers = gcloud.scenarioNumbers!!,
grantPermissions = gcloud.grantPermissions
)
1 change: 1 addition & 0 deletions test_runner/src/main/kotlin/ftl/args/CreateCommonArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ fun CommonConfig.createCommonArgs(
networkProfile = gcloud.networkProfile,
clientDetails = gcloud.clientDetails,
otherFiles = gcloud.otherFiles!!.mapValues { (_, path) -> path.normalizeFilePath() },
scenarioNumbers = gcloud.scenarioNumbers!!,
type = gcloud.type?.toType(),

// flank
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 @@ -24,6 +24,7 @@ interface IArgs {
val resultsHistoryName: String?
val flakyTestAttempts: Int
val otherFiles: Map<String, String>
val scenarioNumbers: List<String>
val type: Type? get() = null

// FlankYml
Expand Down
1 change: 1 addition & 0 deletions test_runner/src/main/kotlin/ftl/args/IosArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ IosArgs
num-flaky-test-attempts: $flakyTestAttempts
other-files: ${ArgsToString.mapToString(otherFiles)}
additional-ipas: ${ArgsToString.listToString(additionalIpas)}
scenario-numbers: ${ArgsToString.listToString(scenarioNumbers)}
type: ${type?.ymlName}

flank:
Expand Down
7 changes: 7 additions & 0 deletions test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ fun IosArgs.validate() = apply {
checkResultsDirUnique()
assertAdditionalIpas()
validType()
assertGameloop()
}

fun IosArgs.assertGameloop() {
Sloox marked this conversation as resolved.
Show resolved Hide resolved
if (scenarioNumbers.isNotEmpty() && (type == null || type != Type.GAMELOOP))
Sloox marked this conversation as resolved.
Show resolved Hide resolved
throw FlankConfigurationError("Scenario numbers defined but Type is not Game-loop.")
scenarioNumbers.forEach { it.toIntOrNull() ?: throw FlankConfigurationError("Invalid scenario number provided - $it") }
}

fun IosArgs.validateRefresh() = apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,6 @@ data class AndroidGcloudConfig @JsonIgnore constructor(
@set:JsonProperty("directories-to-pull")
var directoriesToPull: List<String>? by data

@set:CommandLine.Option(
names = ["--scenario-numbers"],
split = ",",
description = ["A list of game-loop scenario numbers which will be run as part of the test (default: all scenarios). " +
"A maximum of 1024 scenarios may be specified in one test matrix, " +
"but the maximum number may also be limited by the overall test --timeout setting."]
)
@set:JsonProperty("scenario-numbers")
var scenarioNumbers: List<String>? by data

@set:CommandLine.Option(
names = ["--scenario-labels"],
split = ",",
Expand Down Expand Up @@ -250,7 +240,6 @@ data class AndroidGcloudConfig @JsonIgnore constructor(
environmentVariables = emptyMap()
grantPermissions = FlankDefaults.GRANT_PERMISSIONS_ALL
directoriesToPull = emptyList()
scenarioNumbers = emptyList()
scenarioLabels = emptyList()
obbfiles = emptyList()
obbnames = emptyList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ data class CommonGcloudConfig @JsonIgnore constructor(
@set:JsonProperty("other-files")
var otherFiles: Map<String, String>? by data

@set:CommandLine.Option(
names = ["--scenario-numbers"],
split = ",",
description = ["A list of game-loop scenario numbers which will be run as part of the test (default: all scenarios). " +
"A maximum of 1024 scenarios may be specified in one test matrix, " +
"but the maximum number may also be limited by the overall test --timeout setting."]
)
@set:JsonProperty("scenario-numbers")
var scenarioNumbers: List<String>? by data

@set:CommandLine.Option(
names = ["--type"],
description = ["The type of test to run. TYPE must be one of: instrumentation, robo, xctest, game-loop."]
Expand Down Expand Up @@ -162,6 +172,7 @@ data class CommonGcloudConfig @JsonIgnore constructor(
devices = listOf(defaultDevice(android))
otherFiles = emptyMap()
type = null
scenarioNumbers = emptyList()
}
}
}
Expand Down
58 changes: 58 additions & 0 deletions test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ IosArgs
additional-ipas:
- $testIpa1
- $testIpa2
scenario-numbers:
type: xctest

flank:
Expand Down Expand Up @@ -301,6 +302,7 @@ IosArgs
num-flaky-test-attempts: 0
other-files:
additional-ipas:
scenario-numbers:
type: xctest

flank:
Expand Down Expand Up @@ -1127,6 +1129,62 @@ IosArgs
assertFalse(systemOutRule.log.contains("WARNING: Google cloud storage result directory should be unique, otherwise results from multiple test matrices will be overwritten or intermingled"))
}
}

@Test
fun `should not throw exception if game-loop is provided and nothing else`() {
val yaml = """
gcloud:
test: $testPath
xctestrun-file: $testPath
results-dir: test
type: game-loop
""".trimIndent()
IosArgs.load(yaml).validate()
}

@Test(expected = FlankConfigurationError::class)
fun `should throw exception if game-loop is not provided and scenario numbers are`() {
val yaml = """
gcloud:
test: $testPath
xctestrun-file: $testPath
results-dir: test
scenario-numbers:
- 1
- 2
""".trimIndent()
IosArgs.load(yaml).validate()
}

@Test
fun `should not throw exception if game-loop is provided and scenario numbers are`() {
val yaml = """
gcloud:
test: $testPath
xctestrun-file: $testPath
results-dir: test
type: game-loop
scenario-numbers:
- 1
- 2
""".trimIndent()
IosArgs.load(yaml).validate()
}

@Test(expected = FlankConfigurationError::class)
fun `should throw exception if invalid scenario numbers are provided`() {
val yaml = """
gcloud:
test: $testPath
xctestrun-file: $testPath
results-dir: test
type: game-loop
scenario-numbers:
- error1
- error2
""".trimIndent()
IosArgs.load(yaml).validate()
}
}

private fun IosArgs.Companion.load(yamlData: String, cli: IosRunCommand? = null): IosArgs =
Expand Down