8354407: Test com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java still fails on Windows#24961
8354407: Test com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java still fails on Windows#24961kevinjwalls wants to merge 2 commits intoopenjdk:masterfrom
Conversation
…oad.java still fails on Windows
|
👋 Welcome back kevinw! A progress list of the required criteria for merging this PR into |
|
@kevinjwalls 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: 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 27 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
|
@kevinjwalls The following labels will be automatically applied to this pull request:
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. |
Webrevs
|
| ex = null; | ||
| good++; |
There was a problem hiding this comment.
The ex = null is a little misleading because actually it's irrelevant. An error on the next iteration will set it again, but it will be ignored because good != 0.
There was a problem hiding this comment.
Yes, as long as there is a good value captured, Windows should pass.
We could get into how many good values we should see, I might suggest 6 out of 10? But that seems like a guessing game.
The breakage in this feature before meant it could never return a good value, that's what we need to guard against.
There was a problem hiding this comment.
I would simplify to
for (int i = 0; i < TEST_COUNT; i++) {
double load = mbean.getProcessCpuLoad();
if (load == -1.0 && Platform.isWindows()) {
// Some Windows 2019 systems can return -1 for the first few reads.
// Remember a -1 in case it never gets better.
// Some Windows systems can return -1 occasionally, at any time.
// Will fail if we never see good values.
} else if (load < 0.0 || load > 1.0) {
throw new RuntimeException("getProcessCpuLoad() returns " + load
+ " which is not in the [0.0,1.0] interval");
} else {
// we got at least one load from 0.0 to 1.0, that's good to pass on Wiindows
good++;
}
try {
Thread.sleep(200);
}
}
if (good == 0 && Platform.isWindows()) {
// Never get any good results on Windows 2019
throw throw new RuntimeException("getProcessCpuLoad() returns always -1.0 on Windows in 10 attempts. ");
}
}
does it makes a sense?
There was a problem hiding this comment.
Thanks Leonid, yes we could do it like that. There have to be a load of ways we could arrange this. Yes, it could be a little simpler that what we have now, although it's not that complicated now...
There was a problem hiding this comment.
I do like having the Exception created at the point where we recognise there's a problem. While the message could hard-code in the -1 in the Windows case, it must be also good to use the same expression to build the message, right next to each other.
I also like keeping the existing Exception wording, there isn't a real need to change it.
It's still a tiny little test routine and on future failure on Windows, it should be clear that we didn't receive any good values.
On balance would you be OK if we leave as it stands?
There was a problem hiding this comment.
sure, let left it as it is.
Let return to this once 2019 is going to be EOL and remove all this stuff:
Looks good for me.
There was a problem hiding this comment.
Thanks Leonid!
Eventually there were a few failures on other Windows versions, so I removed the specific mention of Windows 2019, although it was most common.
| } | ||
|
|
||
| if (ex != null) { | ||
| if (good == 0 && ex != null) { |
There was a problem hiding this comment.
The check for ex != null is not necessary. It should always be set if good == 0
There was a problem hiding this comment.
Right, it does not really need to set ex = null as as soon as there is something in "good", we pass. But leaving the Exception hanging around seems wrong.
If good is zero then yes checking for ex is redundant. I left the check mostly to avoid any future change breaking it, but maybe it's best to expose that and make sure we fail if good is zero.
|
Thanks for the reviews! |
|
/integrate |
|
Going to push as commit 09cae5f.
Your commit was automatically rebased without conflicts. |
|
@kevinjwalls Pushed as commit 09cae5f. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This is hard to reproduce, and at first I'd only seen -1 returned on the first calls to mbean.getProcessCpuLoad().
But eventually I observed a -1 at any time, including in middle of the iterations, or on the last iteration which makes the current test fail.
Should fail on Windows only if we only ever see -1 returned from getProcessCpuLoad().
Remove the "exclusiveAccess.dirs=." (JDK-8353231 adding "exclusiveAccess.dirs=." did not fix this.)
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24961/head:pull/24961$ git checkout pull/24961Update a local copy of the PR:
$ git checkout pull/24961$ git pull https://git.openjdk.org/jdk.git pull/24961/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 24961View PR using the GUI difftool:
$ git pr show -t 24961Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24961.diff
Using Webrev
Link to Webrev Comment