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: Dump shards and upload on every run #1171

Merged
merged 9 commits into from
Oct 1, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ftl.args.validate
import ftl.cli.firebase.test.CommonRunCommand
import ftl.config.FtlConstants
import ftl.config.emptyAndroidConfig
import ftl.gc.GcStorage
import ftl.mock.MockServer
import ftl.run.ANDROID_SHARD_FILE
import ftl.run.dumpShards
Expand Down Expand Up @@ -47,7 +48,10 @@ class AndroidRunCommand : CommonRunCommand(), Runnable {
val config = AndroidArgs.load(Paths.get(configPath), cli = this).validate()
runBlocking {
if (dumpShards) dumpShards(args = config, obfuscatedOutput = obfuscate)
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's keep the same convention as below

else newTestRun(config)
else {
config.dumpShardsWithGcloudUpload(obfuscate)
newTestRun(config)
adamfilipow92 marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

Expand All @@ -57,3 +61,8 @@ class AndroidRunCommand : CommonRunCommand(), Runnable {
)
var dumpShards: Boolean = false
}

private suspend fun AndroidArgs.dumpShardsWithGcloudUpload(obfuscatedOutput: Boolean) {
dumpShards(args = this, obfuscatedOutput = obfuscatedOutput)
if (disableResultsUpload.not()) GcStorage.upload(ANDROID_SHARD_FILE, resultsBucket, resultsDir)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ftl.args.validate
import ftl.cli.firebase.test.CommonRunCommand
import ftl.config.FtlConstants
import ftl.config.emptyIosConfig
import ftl.gc.GcStorage
import ftl.mock.MockServer
import ftl.run.IOS_SHARD_FILE
import ftl.run.dumpShards
Expand Down Expand Up @@ -49,6 +50,7 @@ class IosRunCommand : CommonRunCommand(), Runnable {
if (dumpShards) {
dumpShards(args = config, obfuscatedOutput = obfuscate)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as previous

} else runBlocking {
config.dumpShardsWithGcloudUpload(obfuscate)
newTestRun(config)
}
}
Expand All @@ -59,3 +61,8 @@ class IosRunCommand : CommonRunCommand(), Runnable {
)
var dumpShards: Boolean = false
}

private fun IosArgs.dumpShardsWithGcloudUpload(obfuscatedOutput: Boolean) {
dumpShards(args = this, obfuscatedOutput = obfuscatedOutput)
if (disableResultsUpload.not()) GcStorage.upload(IOS_SHARD_FILE, resultsBucket, resultsDir)
}
1 change: 0 additions & 1 deletion test_runner/src/main/kotlin/ftl/run/NewTestRun.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ suspend fun newTestRun(args: IArgs) = withTimeoutOrNull(args.parsedTimeout) {

println()
matrixMap.printMatricesWebLinks(args.project)

matrixMap.validate(args.ignoreFailedTests)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package ftl.cli.firebase.test.android

import com.google.common.truth.Truth.assertThat
import ftl.args.AndroidArgs
import ftl.args.yml.AppTestPair
import ftl.config.Device
import ftl.config.FtlConstants
import ftl.gc.GcStorage
import ftl.run.ANDROID_SHARD_FILE
import ftl.run.dumpShards
import ftl.run.exception.FlankConfigurationError
import ftl.test.util.FlankTestRunner
import io.mockk.coVerify
import io.mockk.mockkObject
import io.mockk.mockkStatic
import io.mockk.verify
import org.junit.Assert.assertEquals
import org.junit.Rule
import org.junit.Test
Expand Down Expand Up @@ -523,4 +531,26 @@ class AndroidRunCommandTest {
)
cmd.run()
}

@Test
fun `should dump shards on android test run`() {
mockkStatic("ftl.run.DumpShardsKt")
val runCmd = AndroidRunCommand()
runCmd.configPath = "./src/test/kotlin/ftl/fixtures/simple-android-flank.yml"
runCmd.run()
coVerify { dumpShards(any<AndroidArgs>(), any(), any()) }
}

@Test
fun `should dump shards on android test run and not upload when disable-upload-results set`() {
mockkStatic("ftl.run.DumpShardsKt")
mockkObject(GcStorage) {
val runCmd = AndroidRunCommand()
runCmd.configPath = "./src/test/kotlin/ftl/fixtures/simple-android-flank.yml"
CommandLine(runCmd).parseArgs("--disable-results-upload")
runCmd.run()
coVerify { dumpShards(any<AndroidArgs>(), any(), any()) }
verify(inverse = true) { GcStorage.upload(ANDROID_SHARD_FILE, any(), any()) }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package ftl.cli.firebase.test.ios

import com.google.common.truth.Truth.assertThat
import ftl.args.IosArgs
import ftl.config.Device
import ftl.config.FtlConstants
import ftl.config.FtlConstants.isWindows
import ftl.gc.GcStorage
import ftl.run.IOS_SHARD_FILE
import ftl.run.dumpShards
import ftl.test.util.FlankTestRunner
import io.mockk.mockkObject
import io.mockk.mockkStatic
import io.mockk.verify
import org.junit.Assume.assumeFalse
import org.junit.Rule
import org.junit.Test
Expand Down Expand Up @@ -337,4 +344,26 @@ class IosRunCommandTest {

assertThat(cmd.config.common.flank.useAverageTestTimeForNewTests).isTrue()
}

@Test
fun `should dump shards on ios test run`() {
mockkStatic("ftl.run.DumpShardsKt")
val runCmd = IosRunCommand()
runCmd.configPath = "./src/test/kotlin/ftl/fixtures/simple-ios-flank.yml"
runCmd.run()
verify { dumpShards(any<IosArgs>(), any(), any()) }
}

@Test
fun `should dump shards on ios test run and not upload when disable-upload-results set`() {
mockkStatic("ftl.run.DumpShardsKt")
mockkObject(GcStorage) {
val runCmd = IosRunCommand()
runCmd.configPath = "./src/test/kotlin/ftl/fixtures/simple-ios-flank.yml"
CommandLine(runCmd).parseArgs("--disable-results-upload")
runCmd.run()
verify { dumpShards(any<IosArgs>(), any(), any()) }
verify(inverse = true) { GcStorage.upload(IOS_SHARD_FILE, any(), any()) }
}
}
}
2 changes: 1 addition & 1 deletion test_runner/src/test/kotlin/ftl/json/MatrixMapTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MatrixMapTest {
}

@Test
fun `invalid matrix should contains specyfic error message`() {
fun `invalid matrix should contain a specific error message`() {
val testMatrix = testMatrix()
testMatrix.testMatrixId = "123"
testMatrix.state = MatrixState.INVALID
Expand Down