RFR: 8313770: jdk/internal/platform/docker/TestSystemMetrics.java fails on Ubuntu
Casper Norrbin
cnorrbin at openjdk.org
Wed Oct 22 08:58:15 UTC 2025
Hi everyone,
The test `TestSystemMetrics.java` sometimes fails on cgroupv2 when comparing read/write I/O metrics (`rios`/`wios`) because the expected value doesn't match the one read from the `io.stat` file. The current approach in this test is somewhat flawed, it reads from the same `io.stat` file cgroup file twice, once directly and once through `jdk.internal.platform.Metrics`, and assumes the values should be identical. In practice, this assumption does not hold. Unrelated I/O running in the same cgroup may increment the counter between reads, leading to discrepancies.
The current comparisons have a 25% margin from the original value to account for incidental noise, but this doesn't work well on the I/O operation counters, which can have very small values (sometimes as low as 0), which makes the percentage-based margin useless. As a result, this test is at risk of failing whenever activity happens between the 2 file readings.
For greater reliability, I suggest we should instead check that the value is increasing rather than expecting equality. This is already done for other metrics, such as CPU and memory usage, and more accurately reflects the expected behaviour of the counters. Switching to this check removes the reliance on error margins and results in a more stable and meaningful test.
Testing:
- Repeated runs of `TestSystemMetrics.java` without any observed failures.
- Oracle tiers 1-5
-------------
Commit messages:
- changed io.stat to use <
Changes: https://git.openjdk.org/jdk/pull/27934/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=27934&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8313770
Stats: 3 lines in 1 file changed: 1 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/27934.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/27934/head:pull/27934
PR: https://git.openjdk.org/jdk/pull/27934
More information about the hotspot-runtime-dev
mailing list