Skip to content
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

8321812: Update GC tests to use execute[Limited]TestJava #17067

Closed

Conversation

stefank
Copy link
Member

@stefank stefank commented Dec 11, 2023

A lot of our tests use a multi-step recipe to spawn and wait for a process. Here's an example

    ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
         "-XX:-UseTLAB",
         "-XX:+UnlockDiagnosticVMOptions",
         "-XX:+VerifyDuringStartup",
         "-Xlog:gc+verify=debug",
         "-version");
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    ... do something with output and wait for the process to complete ...

These are the steps involved:

  1. Create a ProcessBuilder
  2. Call ProcessBuilder::start
  3. Create an OutputAnalyzer
  4. Perform an operation that finally waits for the process to, at least partially, complete (OutputAnalyzer::getOutput, OutputAnalyzer::shouldHaveExitValue(), and more).

Almost all our tests could be converted to use a single call to ProcessTools.executeTestJava (or executeLimitedTestJava), which spawns the process, makes sure that it has fully completed, and then returns a filled-in OutputAnalyzer to the caller. The above example would become:

    OutputAnalyzer output = ProcessTools.executeTestJava(
         "-XX:-UseTLAB",
         "-XX:+UnlockDiagnosticVMOptions",
         "-XX:+VerifyDuringStartup",
         "-Xlog:gc+verify=debug",
         "-version");

I propose that we make this change in the GC tests, to make our code simpler and hopefully easier to read.

Note: There's a few changes to the throws statements because some ProcessTools APIs throws IOException while others throw Exception.

Testing: I've done testing on a similar set of changes, but I'm going to run the appropriate, final tests while this is being considered/reviewed.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8321812: Update GC tests to use execute[Limited]TestJava (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17067/head:pull/17067
$ git checkout pull/17067

Update a local copy of the PR:
$ git checkout pull/17067
$ git pull https://git.openjdk.org/jdk.git pull/17067/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 17067

View PR using the GUI difftool:
$ git pr show -t 17067

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17067.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 11, 2023

👋 Welcome back stefank! A progress list of the required criteria for merging this PR into pr/17049 will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 11, 2023
@openjdk
Copy link

openjdk bot commented Dec 11, 2023

@stefank The following labels will be automatically applied to this pull request:

  • hotspot-gc
  • shenandoah

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added hotspot-gc hotspot-gc-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org labels Dec 11, 2023
@mlbridge
Copy link

mlbridge bot commented Dec 11, 2023

Webrevs

@@ -101,7 +102,7 @@ public static void compileClass(String className, Path root, String source) thro
.addToolArg(sourceFile.toAbsolutePath().toString());

ProcessBuilder pb = new ProcessBuilder(jar.getCommand());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
OutputAnalyzer output = ProcessTools.executeProcess(pb);
Copy link
Member

@xmas92 xmas92 Jan 3, 2024

Choose a reason for hiding this comment

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

The pattern

OutputAnalyzer output = ProcessTools.executeProcess(jcmd.getCommand());

is used above, but an explicit ProcessBuilder is used here. Maybe one style should be picked?

test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsFlagsWithUlimit.java does something similar to this as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've changed this to skip using an explicit ProcessBuilder. However, that hit a problem that some ProcessTools.executeProcess overloads are declared to throw Throwable instead of Exception. Instead of fixing that inside this PR, or creating a workaround for this, I created a separate, trivial PR to update those functions. Please see #17240. I've merged the branch for that PR into this PR so that we can test the updated changes.

@openjdk-notifier openjdk-notifier bot changed the base branch from pr/17049 to master January 3, 2024 08:55
@openjdk-notifier
Copy link

The parent pull request that this pull request depends on has now been integrated and the target branch of this pull request has been updated. This means that changes from the dependent pull request can start to show up as belonging to this pull request, which may be confusing for reviewers. To remedy this situation, simply merge the latest changes from the new target branch into this pull request by running commands similar to these in the local repository for your personal fork:

git checkout 8321812_use_executeTestJava_in_gc_tests
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# if there are conflicts, follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk
Copy link

openjdk bot commented Jan 3, 2024

@stefank This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8321812: Update GC tests to use execute[Limited]TestJava

Reviewed-by: tschatzl, aboldtch

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented Jan 3, 2024

⚠️ @stefank This pull request contains merges that bring in commits not present in the target repository. Since this is not a "merge style" pull request, these changes will be squashed when this pull request in integrated. If this is your intention, then please ignore this message. If you want to preserve the commit structure, you must change the title of this pull request to Merge <project>:<branch> where <project> is the name of another project in the OpenJDK organization (for example Merge jdk:master).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 3, 2024
@stefank
Copy link
Member Author

stefank commented Jan 5, 2024

Thanks for the reviews! Tier1-3 testing passes.
/integrate

@openjdk
Copy link

openjdk bot commented Jan 5, 2024

Going to push as commit 1d1cd32.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jan 5, 2024
@openjdk openjdk bot closed this Jan 5, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jan 5, 2024
@openjdk
Copy link

openjdk bot commented Jan 5, 2024

@stefank Pushed as commit 1d1cd32.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-gc hotspot-gc-dev@openjdk.org integrated Pull request has been integrated shenandoah shenandoah-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

3 participants