Skip to content

Commit

Permalink
Merge branch 'master' into #1178-rewrite_scripts_to_kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
piotradamczyk5 authored Nov 2, 2020
2 parents 2680656 + 33a01d4 commit 60e5f4a
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 14 deletions.
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
3 changes: 2 additions & 1 deletion test_runner/src/main/kotlin/ftl/args/ValidateAndroidArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ private fun AndroidArgs.assertLabelContent() {
else -> obbFiles.forEach { ArgsHelper.assertFileExists(it, " (obb file)") }
}

if (scenarioNumbers.isNotEmpty() && (type == null || type != Type.GAMELOOP))
if (scenarioNumbers.isNotEmpty() && (type != Type.GAMELOOP))
throw FlankConfigurationError("Scenario numbers defined but Type is not Game-loop.")
scenarioNumbers.forEach { it.toIntOrNull() ?: throw FlankConfigurationError("Invalid scenario number provided - $it") }
if (scenarioNumbers.size > 1024) throw FlankConfigurationError("There cannot be more than 1024 Scenario numbers")
}

private const val MAX_OBB_FILES = 2
Expand Down
8 changes: 8 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,14 @@ fun IosArgs.validate() = apply {
checkResultsDirUnique()
assertAdditionalIpas()
validType()
assertGameloop()
}

fun IosArgs.assertGameloop() {
if (scenarioNumbers.isNotEmpty() && (type != Type.GAMELOOP))
throw FlankConfigurationError("Scenario numbers defined but Type is not Game-loop.")
scenarioNumbers.forEach { it.toIntOrNull() ?: throw FlankConfigurationError("Invalid scenario number provided - $it") }
if (scenarioNumbers.size > 1024) throw FlankConfigurationError("There cannot be more than 1024 Scenario numbers")
}

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

0 comments on commit 60e5f4a

Please sign in to comment.