RFR: 8288885: Introduce a jwebserver launcher utility in test library for jtreg tests

Jaikiran Pai jpai at openjdk.org
Wed Jun 22 07:37:41 UTC 2022


On Wed, 22 Jun 2022 06:09:39 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

> Can I please get a review for this change which adds a utility to the JDK test library to help launch the JWebServer? As noted in the JBS issue, this utility does the necessary work to make sure when the `launch()` method returns, the jwebserver is ready to receive requests. This helps remove a lot of boilerplate code from individual tests.
> 
> As part of this commit, the existing `MaxRequestTimeTest` has been migrated to use this new utility. This existing test continues to pass with this change.
> 
> tier1, tier2 and tier3 testing passed without any related issues.

Hello Alan,

> If a test needs an "in-process" HTTP server then it is easy to use the com.sun.net.httpserver API directly or use ToolProvider to find jwebserver. So I think the use-case you are looking at is JDK tests that want a HTTP server in a separate process, is that right?

The usage of this new utility will be for those tests that test the `jwebserver` tool itself. In other words, tests that would want to run the `jwebserver` command from within the  test and then run some tests against that launched process. So you are right, this utility is for launching a separate process.
On a related note, jwebserver doesn't implement the `ToolProvider` SPI, so (for in-process usages), it cannot be found using the `ToolProvider`. My understanding, based on some previous discussions I found around this, is that it was intentional not to implement the `ToolProvider` interface for `jwebserver`.



> It's important that such tests need to be able to clean up. If I read the proposal correctly then they must call Process:destroy, is that right?

That is correct. The test which uses this utility to launch the server will be returned by a `record` which will provide the test with the access to the launched `Process`. The test is then responsible for managing that Process including destroying it. The `MaxRequestTimeTest` which uses this new utility, in this PR, has the code which does this destruction. 

Additionally, the utility itself takes the responsibility of destroying the `Process`, if the `launch()` itself failed. The `launch()` is considered as failed if after the Process has been started, the utility cannot find the server's host/port from the Process's output. In cases like that, this utility will destroy the `Process` and then throw an `IOException` from `launch()`

-------------

PR: https://git.openjdk.org/jdk/pull/9232


More information about the net-dev mailing list