Skip to content

Commit

Permalink
#885 Print provided software (#904)
Browse files Browse the repository at this point in the history
* #885 Print provided software

* #885 Updated release notes

* Update release_notes.md
  • Loading branch information
piotradamczyk5 authored Jul 21, 2020
1 parent 611e0f0 commit bc0e1cc
Show file tree
Hide file tree
Showing 13 changed files with 122 additions and 4 deletions.
1 change: 1 addition & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [#894](https://github.com/Flank/flank/pull/894) Added option to print Android available versions to test against. ([piotradamczyk5](https://github.com/piotradamczyk5))
- [#897](https://github.com/Flank/flank/pull/897) Added option to print iOS available versions to test against. ([piotradamczyk5](https://github.com/piotradamczyk5))
- [#901](https://github.com/Flank/flank/pull/901) Added option to print Android and iOS available test-environment. ([piotradamczyk5](https://github.com/piotradamczyk5))
- [#904](https://github.com/Flank/flank/pull/904) Added option to print provided software. ([piotradamczyk5](https://github.com/piotradamczyk5))
-
-
-
Expand Down
5 changes: 4 additions & 1 deletion test_runner/docs/ascii/flank.jar_-firebase-test.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ flank.jar
*network-profiles*::


*provided-software*::


// end::picocli-generated-man-section-commands[]

// end::picocli-generated-full-manpage[]
// end::picocli-generated-full-manpage[]
5 changes: 4 additions & 1 deletion test_runner/docs/ascii/flank.jar_.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ flank.jar
*auth*::
Manage oauth2 credentials for Google Cloud

*provided-software*::


// end::picocli-generated-man-section-commands[]

// end::picocli-generated-full-manpage[]
// end::picocli-generated-full-manpage[]
4 changes: 3 additions & 1 deletion test_runner/src/main/kotlin/ftl/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ftl.cli.firebase.CancelCommand
import ftl.cli.firebase.RefreshCommand
import ftl.cli.firebase.test.AndroidCommand
import ftl.cli.firebase.test.IosCommand
import ftl.cli.firebase.test.ProvidedSoftwareCommand
import ftl.log.setDebugLogging
import ftl.util.readRevision
import ftl.util.readVersion
Expand All @@ -21,7 +22,8 @@ import picocli.CommandLine
AndroidCommand::class,
RefreshCommand::class,
CancelCommand::class,
AuthCommand::class
AuthCommand::class,
ProvidedSoftwareCommand::class
]
)
class Main : Runnable {
Expand Down
4 changes: 3 additions & 1 deletion test_runner/src/main/kotlin/ftl/cli/firebase/TestCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ftl.cli.firebase
import ftl.cli.firebase.test.AndroidCommand
import ftl.cli.firebase.test.IosCommand
import ftl.cli.firebase.test.NetworkProfilesCommand
import ftl.cli.firebase.test.ProvidedSoftwareCommand
import picocli.CommandLine
import picocli.CommandLine.Command

Expand All @@ -12,7 +13,8 @@ import picocli.CommandLine.Command
subcommands = [
AndroidCommand::class,
IosCommand::class,
NetworkProfilesCommand::class
NetworkProfilesCommand::class,
ProvidedSoftwareCommand::class
],
usageHelpAutoWidth = true
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ftl.cli.firebase.test

import ftl.cli.firebase.test.providedsoftware.ProvidedSoftwareListCommand
import picocli.CommandLine

@CommandLine.Command(
name = "provided-software",
synopsisHeading = "",
subcommands = [
ProvidedSoftwareListCommand::class
],
usageHelpAutoWidth = true
)
class ProvidedSoftwareCommand : Runnable {
override fun run() {
CommandLine.usage(ProvidedSoftwareCommand(), System.out)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ftl.android.AndroidCatalog.devicesCatalogAsTable
import ftl.android.AndroidCatalog.supportedVersionsAsTable
import ftl.args.AndroidArgs
import ftl.config.FtlConstants
import ftl.environment.providedSoftwareAsTable
import picocli.CommandLine
import java.nio.file.Paths

Expand All @@ -22,6 +23,7 @@ class AndroidTestEnvironmentCommand : Runnable {
override fun run() {
println(devicesCatalogAsTable(AndroidArgs.load(Paths.get(configPath)).project))
println(supportedVersionsAsTable(AndroidArgs.load(Paths.get(configPath)).project))
println(providedSoftwareAsTable())
}

@CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ftl.cli.firebase.test.ios

import ftl.args.IosArgs
import ftl.config.FtlConstants
import ftl.environment.providedSoftwareAsTable
import ftl.ios.IosCatalog.devicesCatalogAsTable
import ftl.ios.IosCatalog.softwareVersionsAsTable
import picocli.CommandLine
Expand All @@ -22,6 +23,7 @@ class IosTestEnvironmentCommand : Runnable {
override fun run() {
println(devicesCatalogAsTable(IosArgs.load(Paths.get(configPath)).project))
println(softwareVersionsAsTable(IosArgs.load(Paths.get(configPath)).project))
println(providedSoftwareAsTable())
}

@CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ftl.cli.firebase.test.providedsoftware

import ftl.environment.providedSoftwareAsTable
import picocli.CommandLine

@CommandLine.Command(
name = "list",
sortOptions = false,
headerHeading = "",
synopsisHeading = "%n",
descriptionHeading = "%n@|bold,underline Description:|@%n%n",
parameterListHeading = "%n@|bold,underline Parameters:|@%n",
optionListHeading = "%n@|bold,underline Options:|@%n",
header = ["The software environment provided by TestExecutionService."],
usageHelpAutoWidth = true
)
class ProvidedSoftwareListCommand : Runnable {
override fun run() {
println(providedSoftwareAsTable())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package ftl.environment

import com.google.api.services.testing.model.ProvidedSoftwareCatalog
import ftl.util.TableColumn
import ftl.util.buildTable

fun ProvidedSoftwareCatalog.asTable() = buildTable(
TableColumn(
ORCHESTRATOR_VERSION,
listOf(orchestratorVersion)
)
)

private const val ORCHESTRATOR_VERSION = "ORCHESTRATOR VERSION"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package ftl.environment

import ftl.gc.GcTesting
import ftl.http.executeWithRetry

fun providedSoftwareAsTable() = getProvidedSoftware().asTable()

private fun getProvidedSoftware() = GcTesting.get.testEnvironmentCatalog()
.get("provided_software")
.executeWithRetry()
.softwareCatalog
9 changes: 9 additions & 0 deletions test_runner/src/main/kotlin/ftl/mock/MockServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.google.api.services.testing.model.AndroidDeviceCatalog
import com.google.api.services.testing.model.Environment
import com.google.api.services.testing.model.GoogleCloudStorage
import com.google.api.services.testing.model.IosDeviceCatalog
import com.google.api.services.testing.model.ProvidedSoftwareCatalog
import com.google.api.services.testing.model.ResultStorage
import com.google.api.services.testing.model.TestEnvironmentCatalog
import com.google.api.services.testing.model.TestExecution
Expand Down Expand Up @@ -122,6 +123,14 @@ object MockServer {
call.respond(catalog)
}

get("/v1/testEnvironmentCatalog/provided_software") {
println("Responding to GET ${call.request.uri}")
val catalog = TestEnvironmentCatalog().apply {
softwareCatalog = ProvidedSoftwareCatalog().apply { orchestratorVersion = "1.0.0" }
}
call.respond(catalog)
}

get("/v1/testEnvironmentCatalog/ios") {
println("Responding to GET ${call.request.uri}")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package ftl.environment

import com.google.common.truth.Truth.assertThat
import ftl.test.util.FlankTestRunner
import io.mockk.unmockkAll
import org.junit.After
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(FlankTestRunner::class)
class ListProvidedSoftwareTest {

@After
fun tearDown() = unmockkAll()

@Test
fun `should print provided software as a table`() {
// given
val expectedOrchestratorVersion = "1.0.0"
val expectedHeader = "ORCHESTRATOR VERSION"

// when
val output = providedSoftwareAsTable()

// then
assertThat(output.lines()[0]).doesNotContain("")
assertThat(output.lines()[1]).contains(expectedHeader)
assertThat(output.lines()[3]).contains(expectedOrchestratorVersion)
}
}

0 comments on commit bc0e1cc

Please sign in to comment.