Skip to content

Add Polaris Apprunner Gradle/Maven plugins #18

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

snazy
Copy link
Member

@snazy snazy commented Apr 24, 2025

Gradle and Maven plugins to run a Polaris process and "properly" terminate it for integration testing.

More information in the README.md in the apprunner/ directory.

Copy link

Choose a reason for hiding this comment

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

Could we share ASF stuff across all sub-modules?

Copy link

@flyrain flyrain left a comment

Choose a reason for hiding this comment

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

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
Copy link

Choose a reason for hiding this comment

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

Do we need groovy as Polaris is using Kotlin with Gradle?

Copy link
Contributor

Choose a reason for hiding this comment

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

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
Copy link

Choose a reason for hiding this comment

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

Do we need maven doc as Polaris doesn't use maven?

Copy link
Contributor

Choose a reason for hiding this comment

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

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.

@snazy snazy requested a review from HonahX as a code owner May 6, 2025 12:23
Copy link
Contributor

@pingtimeout pingtimeout left a comment

Choose a reason for hiding this comment

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

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?
Copy link
Contributor

Choose a reason for hiding this comment

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

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?

}
```

### Groovy DSL
Copy link
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Contributor

Choose a reason for hiding this comment

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

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();
Copy link
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Member Author

@snazy snazy May 12, 2025

Choose a reason for hiding this comment

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

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope. It would block forever when the process doesn't yield any output.

public void accept(String line) {
if (!listenUrl.isDone()) {
synchronized (capturedLog) {
capturedLog.add(line);
Copy link
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

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 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
void pingNessie() throws Exception {
void pingPolaris() throws Exception {

Copy link
Member Author

Choose a reason for hiding this comment

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

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();
Copy link
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

At the time of pushing this, there was no Polaris binary.

Copy link
Member Author

Choose a reason for hiding this comment

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

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
Copy link
Contributor

Choose a reason for hiding this comment

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

More mentions of Nessie here

Co-authored-by: Pierre Laporte <[email protected]>
@snazy
Copy link
Member Author

snazy commented May 12, 2025

Heads up: this is the successor of apache/polaris#785 - it's been open for quite a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants