RFR: 8374200: jdk/internal/platform/cgroup/TestCgroupMetrics.java fails with common prefix metrics

David Holmes dholmes at openjdk.org
Tue Dec 23 00:59:03 UTC 2025


On Mon, 22 Dec 2025 15:31:37 GMT, Jie Fu <jiefu at openjdk.org> wrote:

> Hi all,
> 
> `jdk/internal/platform/cgroup/TestCgroupMetrics.java` fails on machines with common prefix metrics.
> 
> For example, the cpu.stat may be
> 
> usage_usec 5111148455
> user_usec 4457755664
> system_usec 653392790
> core_sched.force_idle_usec 0
> nr_periods 0
> nr_throttled 0
> throttled_usec 0
> nr_burst 0
> burst_usec 0
> nr_throttled_bt 0
> throttled_usec_bt 0
> 
> 
> `nr_throttled` and `nr_throttled_bt` are metrics with common prefix.
> In this case, the test fails since it only matches the starting metric string.
> 
> The fix just adds one more filter `.filter(l -> l.split("\\s+")[0].equals(metric))`, which would match the metric exactly.

test/lib/jdk/test/lib/containers/cgroup/MetricsTesterCgroupV2.java line 126:

> 124:             String strVal = Files.lines(filePath)
> 125:                                  .filter(l -> l.startsWith(metric))
> 126:                                  .filter(l -> l.split("\\s+")[0].equals(metric))

I'm not a regex expert but it seems odd to me to perform an inexact match first, then split that line to perform an exact match. Can't you check if it "starts with" the metric as a full word?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28956#discussion_r2641625287


More information about the hotspot-runtime-dev mailing list