This is test unstable when monitoring CodeHeap pools as they can change outside
the test's control.
Attempting more heuristics to sense these unrelated changes just means we skip
more pools.
The test design, making a Java allocation to affect a memory pool, shows it was
intended for Java heap pools, so the test should focus on them. If we make a
larger allocation during the test we actually can observe a change in size in
the old gen pools it monitors (new gen pools are not expected to have
thresholds, so they are skipped).
There exist specific tests in test/hotspot/jtreg/compiler/codecache/jmx which
are intended for non-heap pools, so we should skip them intentionally here in
isUsageThresholdExceeded.
Other edits in the test to fix that the peak usage reported by the test was
simply usage, not peak. Fetch the usage and peak usage as near together as
possible in the test. At line 110 in the test, remove an attempt to skip pools
we can't monitor (which was working, but does not cover all cases).
Example test log, showing allocation that hits the old gen and triggers the
threshold set by the test:
----------System.out:(15/796)----------
...
5 pool G1 Old Gen of type: Heap memory
used value is 1024000 max is 1038090240 isExceeded = false
peak used value is 1024000
threshold set to 1024001
threshold count 0
reset peak usage. peak usage = 1024000 isExceeded = false
Allocated heap. isExceeded = true
used value is 106930176 max is 1038090240 isExceeded = true
peak used value is 106930176 peak max is 1038090240
threshold count 1
-------------
Commit messages:
- 8290909: MemoryPoolMBean/isUsageThresholdExceeded tests failed with
"isUsageThresholdExceeded() returned false, and is still false, while threshold
= MMMMMMM and used peak = NNNNNNN"
Changes: https://git.openjdk.org/jdk/pull/9842/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=9842&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8290909
Stats: 19 lines in 1 file changed: 5 ins; 7 del; 7 mod
Patch: https://git.openjdk.org/jdk/pull/9842.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/9842/head:pull/9842
PR: https://git.openjdk.org/jdk/pull/9842