diff --git a/release_notes.md b/release_notes.md index adf0a99cd9..0fc4f6cc99 100644 --- a/release_notes.md +++ b/release_notes.md @@ -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)) - - - diff --git a/test_runner/docs/ascii/flank.jar_-firebase-test.adoc b/test_runner/docs/ascii/flank.jar_-firebase-test.adoc index 55fcc7796f..eaf60d706e 100644 --- a/test_runner/docs/ascii/flank.jar_-firebase-test.adoc +++ b/test_runner/docs/ascii/flank.jar_-firebase-test.adoc @@ -35,6 +35,9 @@ flank.jar *network-profiles*:: +*provided-software*:: + + // end::picocli-generated-man-section-commands[] -// end::picocli-generated-full-manpage[] \ No newline at end of file +// end::picocli-generated-full-manpage[] diff --git a/test_runner/docs/ascii/flank.jar_.adoc b/test_runner/docs/ascii/flank.jar_.adoc index af35376f6a..7dee54e5af 100644 --- a/test_runner/docs/ascii/flank.jar_.adoc +++ b/test_runner/docs/ascii/flank.jar_.adoc @@ -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[] \ No newline at end of file +// end::picocli-generated-full-manpage[] diff --git a/test_runner/src/main/kotlin/ftl/Main.kt b/test_runner/src/main/kotlin/ftl/Main.kt index 1e2b7528a8..f207172219 100644 --- a/test_runner/src/main/kotlin/ftl/Main.kt +++ b/test_runner/src/main/kotlin/ftl/Main.kt @@ -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 @@ -21,7 +22,8 @@ import picocli.CommandLine AndroidCommand::class, RefreshCommand::class, CancelCommand::class, - AuthCommand::class + AuthCommand::class, + ProvidedSoftwareCommand::class ] ) class Main : Runnable { diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/TestCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/TestCommand.kt index f05d7ad011..b73fcc35eb 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/TestCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/TestCommand.kt @@ -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 @@ -12,7 +13,8 @@ import picocli.CommandLine.Command subcommands = [ AndroidCommand::class, IosCommand::class, - NetworkProfilesCommand::class + NetworkProfilesCommand::class, + ProvidedSoftwareCommand::class ], usageHelpAutoWidth = true ) diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ProvidedSoftwareCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ProvidedSoftwareCommand.kt new file mode 100644 index 0000000000..864eeb0f3f --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ProvidedSoftwareCommand.kt @@ -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) + } +} diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidTestEnvironmentCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidTestEnvironmentCommand.kt index bb72c77a4c..77f074d755 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidTestEnvironmentCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/android/AndroidTestEnvironmentCommand.kt @@ -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 @@ -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"]) diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosTestEnvironmentCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosTestEnvironmentCommand.kt index 1c68c4099e..64a4a50141 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosTestEnvironmentCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/IosTestEnvironmentCommand.kt @@ -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 @@ -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"]) diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/providedsoftware/ProvidedSoftwareListCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/providedsoftware/ProvidedSoftwareListCommand.kt new file mode 100644 index 0000000000..d81bc9c9ff --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/providedsoftware/ProvidedSoftwareListCommand.kt @@ -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()) + } +} diff --git a/test_runner/src/main/kotlin/ftl/environment/ListProvidedSoftware.kt b/test_runner/src/main/kotlin/ftl/environment/ListProvidedSoftware.kt new file mode 100644 index 0000000000..d9b4b275b3 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/environment/ListProvidedSoftware.kt @@ -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" diff --git a/test_runner/src/main/kotlin/ftl/environment/ProvidedSoftwareCatalog.kt b/test_runner/src/main/kotlin/ftl/environment/ProvidedSoftwareCatalog.kt new file mode 100644 index 0000000000..f05f4092af --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/environment/ProvidedSoftwareCatalog.kt @@ -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 diff --git a/test_runner/src/main/kotlin/ftl/mock/MockServer.kt b/test_runner/src/main/kotlin/ftl/mock/MockServer.kt index 50b006fcc0..b476ccdf8f 100644 --- a/test_runner/src/main/kotlin/ftl/mock/MockServer.kt +++ b/test_runner/src/main/kotlin/ftl/mock/MockServer.kt @@ -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 @@ -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}") diff --git a/test_runner/src/test/kotlin/ftl/environment/ListProvidedSoftwareTest.kt b/test_runner/src/test/kotlin/ftl/environment/ListProvidedSoftwareTest.kt new file mode 100644 index 0000000000..50b2ae35f8 --- /dev/null +++ b/test_runner/src/test/kotlin/ftl/environment/ListProvidedSoftwareTest.kt @@ -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) + } +}