Skip to content

Commit

Permalink
Update directories to download
Browse files Browse the repository at this point in the history
  • Loading branch information
bootstraponline committed Jan 8, 2019
1 parent 28364ed commit 3465ff4
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 14 deletions.
3 changes: 3 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 repeatTests = cli?.repeatTests ?: flank.repeatTests
override val smartFlankGcsPath = flank.smartFlankGcsPath
override val testTargetsAlwaysRun = cli?.testTargetsAlwaysRun ?: flank.testTargetsAlwaysRun
val directoriesToDownload = cli?.directoriesToDownload ?: flank.directoriesToDownload

private val iosFlank = iosFlankYml.flank
val testTargets = cli?.testTargets ?: iosFlank.testTargets
Expand Down Expand Up @@ -123,6 +124,8 @@ ${devicesToString(devices)}
smartFlankGcsPath: $smartFlankGcsPath
test-targets-always-run:
${listToString(testTargetsAlwaysRun)}
directories-to-download:
${listToString(directoriesToDownload)}
# iOS flank
test-targets:
${listToString(testTargets)}
Expand Down
1 change: 1 addition & 0 deletions test_runner/src/main/kotlin/ftl/args/yml/FlankYml.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class FlankYmlParams(

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

@field:JsonProperty("directories-to-download")
val directoriesToDownload: List<String> = emptyList()
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,6 @@ class AndroidRunCommand : Runnable {
)
var directoriesToPull: List<String>? = null

@Option(
names = ["--directories-to-download"],
split = ",",
description = ["A list of paths that will be downloaded from the resulting bucket " +
"to the designated local results folder after the test is complete. These must be absolute paths " +
"(for example, --directories-to-download /images/tempDir1,/data/local/tmp/tempDir2). " +
"Path names are restricted to the characters a-zA-Z0-9_-./+."]
)
var directoriesToDownload: List<String>? = null

@Option(
names = ["--device"],
split = ",",
Expand Down Expand Up @@ -245,6 +235,16 @@ class AndroidRunCommand : Runnable {
)
var testTargetsAlwaysRun: List<String>? = null

@Option(
names = ["--directories-to-download"],
split = ",",
description = ["A list of paths that will be downloaded from the resulting bucket " +
"to the local results folder after the test is complete. These must be absolute paths " +
"(for example, --directories-to-download /images/tempDir1,/data/local/tmp/tempDir2). " +
"Path names are restricted to the characters a-zA-Z0-9_-./+."]
)
var directoriesToDownload: List<String>? = null

@Option(
names = ["--results-dir"],
description = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ class IosRunCommand : Runnable {
)
var testTargets: List<String>? = null

@Option(
names = ["--directories-to-download"],
split = ",",
description = ["A list of paths that will be downloaded from the resulting bucket " +
"to the local results folder after the test is complete. These must be absolute paths " +
"(for example, --directories-to-download /images/tempDir1,/data/local/tmp/tempDir2). " +
"Path names are restricted to the characters a-zA-Z0-9_-./+."]
)
var directoriesToDownload: List<String>? = null

@Option(
names = ["--test"],
description = ["The path to the test package (a zip file containing the iOS app " +
Expand Down
21 changes: 21 additions & 0 deletions test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class IosArgsTest {
flank:
testShards: 7
repeatTests: 8
directories-to-download:
- /sdcard/screenshots
test-targets-always-run:
- a/testGrantPermissions
- a/testGrantPermissions2
Expand Down Expand Up @@ -159,6 +161,8 @@ IosArgs
test-targets-always-run:
- a/testGrantPermissions
- a/testGrantPermissions2
directories-to-download:
- /sdcard/screenshots
# iOS flank
test-targets:
- b/testBasicSelection
Expand Down Expand Up @@ -194,6 +198,7 @@ IosArgs
assert(testShards, 1)
assert(repeatTests, 1)
assert(testTargetsAlwaysRun, emptyList<String>())
assert(directoriesToDownload, emptyList<String>())

// IosFlankYml
assert(testTargets, empty)
Expand Down Expand Up @@ -507,4 +512,20 @@ IosArgs
assertThat(IosArgs.load(yaml).resultsDir).isEqualTo("a")
assertThat(IosArgs.load(yaml, cli).resultsDir).isEqualTo("b")
}

@Test
fun cli_directoriesToDownload() {
val cli = IosRunCommand()
CommandLine(cli).parse("--directories-to-download=a,b,c")

val yaml = """
gcloud:
test: $testPath
xctestrun-file: $testPath
"""
assertThat(IosArgs.load(yaml).directoriesToDownload).isEmpty()

val androidArgs = IosArgs.load(yaml, cli)
assertThat(androidArgs.directoriesToDownload).isEqualTo(listOf("a", "b"))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class AndroidRunCommandTest {
assertThat(cmd.testShards).isNull()
assertThat(cmd.repeatTests).isNull()
assertThat(cmd.testTargetsAlwaysRun).isNull()
assertThat(cmd.directoriesToDownload).isNull()
assertThat(cmd.resultsDir).isNull()
}

Expand Down Expand Up @@ -273,4 +274,12 @@ class AndroidRunCommandTest {

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

@Test
fun directoriesToDownload_parse() {
val cmd = AndroidRunCommand()
CommandLine(cmd).parse("--directories-to-download=a,b")

assertThat(cmd.directoriesToDownload).isEqualTo(arrayListOf("a", "b"))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class IosRunCommandTest {
assertThat(cmd.repeatTests).isNull()
assertThat(cmd.testTargetsAlwaysRun).isNull()
assertThat(cmd.testTargets).isNull()
assertThat(cmd.directoriesToDownload).isNull()
assertThat(cmd.test).isNull()
assertThat(cmd.xctestrunFile).isNull()
assertThat(cmd.xcodeVersion).isNull()
Expand Down Expand Up @@ -207,4 +208,12 @@ class IosRunCommandTest {

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

@Test
fun directoriesToDownload_parse() {
val cmd = IosRunCommand()
CommandLine(cmd).parse("--directories-to-download=a,b")

assertThat(cmd.directoriesToDownload).isEqualTo(arrayListOf("a", "b"))
}
}
4 changes: 4 additions & 0 deletions test_runner/src/test/kotlin/ftl/test/util/FlankTestRunner.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package ftl.test.util

import com.google.auth.oauth2.ComputeEngineCredentials
import ftl.config.FtlConstants
import ftl.gc.GcStorage
import ftl.util.Bash
import org.junit.runners.BlockJUnit4ClassRunner
import java.net.BindException
import java.util.logging.Level
import java.util.logging.Logger

class FlankTestRunner(klass: Class<*>) : BlockJUnit4ClassRunner(klass) {

Expand Down
10 changes: 10 additions & 0 deletions test_runner/src/test/kotlin/ftl/test/util/LocalGcs.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package ftl.test.util

import com.google.auth.oauth2.ComputeEngineCredentials
import com.google.cloud.storage.BlobInfo
import ftl.gc.GcStorage
import org.junit.Assert
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.util.logging.Level
import java.util.logging.Logger

object LocalGcs {

Expand All @@ -28,6 +31,13 @@ object LocalGcs {
)
}

private fun silenceComputeEngine() {
// Set log level then access the storage var to lazy load it.
// Silence info log about "Failed to detect whether we are running on Google Compute Engine."
Logger.getLogger(ComputeEngineCredentials::class.java.name).level = Level.OFF
GcStorage.storage
}

fun uploadFiles() {
val appApk = "../test_app/apks/app-debug.apk"
val testApk = "../test_app/apks/app-debug-androidTest.apk"
Expand Down
7 changes: 3 additions & 4 deletions test_runner/src/test/kotlin/ftl/util/ArtifactRegexTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,28 @@ class ArtifactRegexTest {
@Test
fun regexExists() {
assertThat(ArtifactRegex.testResultRgx).isNotNull()
assertThat(ArtifactRegex.screenshotRgx).isNotNull()
}

@Test
fun `artifactsToDownload should return just testResult and screenshot regex if no directoriesToDownload`() {
assertRegexEquals(ArtifactRegex.artifactsToDownload(matrix, emptyList()),
listOf(ArtifactRegex.testResultRgx, ArtifactRegex.screenshotRgx))
listOf(ArtifactRegex.testResultRgx))
}

@Test
fun `artifactsToDownload should return testResult, screenshot regex and directoriesToDownload regex if one`() {
`when`(matrix.gcsPathWithoutRootBucket).thenReturn(MATRIX_GCS_PATH_WITHOUT_ROOT_BUCKET)

assertRegexEquals(ArtifactRegex.artifactsToDownload(matrix, listOf(TO_DOWNLOAD_1)),
listOf(ArtifactRegex.testResultRgx, ArtifactRegex.screenshotRgx, TO_DOWNLOAD_REGEX_1))
listOf(ArtifactRegex.testResultRgx, TO_DOWNLOAD_REGEX_1))
}

@Test
fun `artifactsToDownload should return testResult, screenshot regex and directoriesToDownload regex if multiple`() {
`when`(matrix.gcsPathWithoutRootBucket).thenReturn(MATRIX_GCS_PATH_WITHOUT_ROOT_BUCKET)

assertRegexEquals(ArtifactRegex.artifactsToDownload(matrix, listOf(TO_DOWNLOAD_1, TO_DOWNLOAD_2)),
listOf(ArtifactRegex.testResultRgx, ArtifactRegex.screenshotRgx, TO_DOWNLOAD_REGEX_1, TO_DOWNLOAD_REGEX_2))
listOf(ArtifactRegex.testResultRgx, TO_DOWNLOAD_REGEX_1, TO_DOWNLOAD_REGEX_2))
}

private fun assertRegexEquals(expected: List<Regex>, actual: List<Regex>) {
Expand Down

0 comments on commit 3465ff4

Please sign in to comment.