Add Polaris Apprunner Gradle/Maven plugins#18
Conversation
ae71aa5 to
6e7cdc1
Compare
There was a problem hiding this comment.
Could we share ASF stuff across all sub-modules?
flyrain
left a comment
There was a problem hiding this comment.
Thanks @snazy for the PR. This seems a huge one. I'd suggest a dev mailing discussion first. This plugin seems to be used for integration tests. Other than adding a whole plugin in to Polaris repo, is there any alternative? For example, is there any plugin can be imported directly instead of having all source code within the project.
| } | ||
| ``` | ||
|
|
||
| ### Groovy DSL |
There was a problem hiding this comment.
Do we need groovy as Polaris is using Kotlin with Gradle?
There was a problem hiding this comment.
We don't need Groovy as, indeed, Polaris is using Kotlin. However, I believe this project is a runner to facilitate Polaris users' life. Users can run the integration tests of their Enterprise projects in isolation without having to manually deploy a Polaris server themselves. And we cannot make any assumption as to whether they are using Groovy or Kotlin in their Gradle build.
| } | ||
| ``` | ||
|
|
||
| ## Maven |
There was a problem hiding this comment.
Do we need maven doc as Polaris doesn't use maven?
There was a problem hiding this comment.
Same comment as my previous answer: we don't need Maven as, indeed, Polaris is using Gradle.
However, I believe this project is a runner to facilitate Polaris users' life. Users can run the integration tests of their Enterprise projects in isolation without having to manually deploy a Polaris server themselves. Maven is the other mainstream Java build system. So it only makes sense that the Apprunner comes with instructions and code to support Maven too.
pingtimeout
left a comment
There was a problem hiding this comment.
No explicit approval yet as there are some questions I think would be worth answering. But generally speaking, the code looks good.
|
|
||
| ## FAQ | ||
|
|
||
| ### Does it have to be a Polaris Quarkus server? |
There was a problem hiding this comment.
Q: This FAQ entry makes me think that, eventually, the code from this module could be extracted and donated to Quarkus. Then this module would just become a specialization of a "Quarkus Gradle Runner for IT" project. Is this correct?
There was a problem hiding this comment.
I would probably leave this question/answer out unless we want to support this code for other projects.
| } | ||
| ``` | ||
|
|
||
| ### Groovy DSL |
There was a problem hiding this comment.
We don't need Groovy as, indeed, Polaris is using Kotlin. However, I believe this project is a runner to facilitate Polaris users' life. Users can run the integration tests of their Enterprise projects in isolation without having to manually deploy a Polaris server themselves. And we cannot make any assumption as to whether they are using Groovy or Kotlin in their Gradle build.
| } | ||
| ``` | ||
|
|
||
| ## Maven |
There was a problem hiding this comment.
Same comment as my previous answer: we don't need Maven as, indeed, Polaris is using Gradle.
However, I believe this project is a runner to facilitate Polaris users' life. Users can run the integration tests of their Enterprise projects in isolation without having to manually deploy a Polaris server themselves. Maven is the other mainstream Java build system. So it only makes sense that the Apprunner comes with instructions and code to support Maven too.
|
|
||
| var any = false; | ||
| while (input.ready()) { | ||
| var c = input.read(); |
There was a problem hiding this comment.
Reading form an input stream byte by byte could result in a lot of syscalls. It seems to me that using a BufferedInputStream would be a lot better. Am I missing something ? Or, is it acceptable because we only use the InputBuffer for a small amount of data?
There was a problem hiding this comment.
It's only there to capture the startup phase output from Quarkus via its stdout.
| * out as fast as possible. If there's no data available, the loop will "yield" via a | ||
| * Thread.sleep(1L), which is good enough. | ||
| * | ||
| * Note: we cannot do blocking-I/O here, because we have to read from both stdout+stderr. |
There was a problem hiding this comment.
Is this still true? Given that ProcessBuilder::redirectErrorStream was called, both stdout and stderr are merged into a single stream. So it seems to me that we could do blocking I/O.
There was a problem hiding this comment.
Nope. It would block forever when the process doesn't yield any output.
There was a problem hiding this comment.
Ah ok so then it is the comment that is misleading
| public void accept(String line) { | ||
| if (!listenUrl.isDone()) { | ||
| synchronized (capturedLog) { | ||
| capturedLog.add(line); |
There was a problem hiding this comment.
Is it possible that capturing all Quarkus output and keeping it in the heap could become a problem if, say, Polaris was started with TRACE logging? It seems to me that capturing all logs was mostly used for debugging purposes?
There was a problem hiding this comment.
It's not a problem in practice. But you want to see all output in case the startup fails. So yes, it's for debugging when things don't work right w/ "your" server.
| */ | ||
| class TestSimulatingTestUsingThePlugin { | ||
| @Test | ||
| void pingNessie() throws Exception { |
There was a problem hiding this comment.
| void pingNessie() throws Exception { | |
| void pingPolaris() throws Exception { |
There was a problem hiding this comment.
Well, it's Nessie in this test.
|
|
||
| var client = NessieClientBuilder.createClientBuilderFromSystemSettings().withUri(uri).build(NessieApiV2.class); | ||
| // Just some simple REST request to verify that Polaris is started - no fancy interactions w/ Nessie | ||
| var config = client.getConfig(); |
There was a problem hiding this comment.
There are references to Nessie that can most likely be simply renamed (e.g. pingNessie()) and others that I am less sure about (Nessie client usage). Is using the Nessie Client intended? There are mentions of Nessie's REST API in code that targets the embedded Polaris server, and that is confusing. What is the rationale for using the Nessie Client here?
There was a problem hiding this comment.
At the time of pushing this, there was no Polaris binary.
There was a problem hiding this comment.
However, it should eventually test both Polaris and Nessie. The principle (code wise) however is the same.
| String uri = String.format("http://127.0.0.1:%s/api/v1", port); | ||
|
|
||
| NessieApiV1 client = HttpClientBuilder.builder().withUri(uri).build(NessieApiV1.class); | ||
| // Just some simple REST request to verify that Nessie is started - no fancy interactions w/ Nessie |
There was a problem hiding this comment.
More mentions of Nessie here
|
Heads up: this is the successor of apache/polaris#785 - it's been open for quite a while. |
|
|
||
| ### Using the plugin in projects in the polaris-tools repository | ||
|
|
||
| 1. include the apprunner build in your project by adding the following snippet at the beginning of your |
There was a problem hiding this comment.
| 1. include the apprunner build in your project by adding the following snippet at the beginning of your | |
| 1. Include the apprunner build in your project by adding the following snippet at the beginning of your |
|
|
||
| `build.gradle.kts` | ||
|
|
||
| 1. add the plugin |
There was a problem hiding this comment.
| 1. add the plugin | |
| 1. Add the plugin |
|
This PR has been open for quite a while. |
|
We still have a "requested change" ... @flyrain: Does this concern still exist in the latest state of this PR? |
|
Ping: @flyrain: Does this concern still exist in the latest state of this PR? If no objections, I'm going to merge tomorrow. |
Oh, seems you're okay with merging |
Gradle and Maven plugins to run a Polaris process and "properly" terminate it for integration testing.
More information in the
README.mdin theapprunner/directory.