--- old/test/lib/jdk/test/lib/containers/cgroup/MetricsTesterCgroupV2.java 2020-02-11 18:28:06.307506846 +0100 +++ new/test/lib/jdk/test/lib/containers/cgroup/MetricsTesterCgroupV2.java 2020-02-11 18:28:06.156506346 +0100 @@ -34,13 +34,12 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; +import jdk.internal.platform.CgroupSubsystem; import jdk.internal.platform.Metrics; -import jdk.test.lib.Asserts; public class MetricsTesterCgroupV2 implements CgroupMetricsTester { private static final long UNLIMITED = -1; - private static final long NOT_SUPPORTED = -2; private static final UnifiedController UNIFIED = new UnifiedController(); private static final String MAX = "max"; private static final int PER_CPU_SHARES = 1024; @@ -153,21 +152,6 @@ CgroupMetricsTester.warn(UnifiedController.NAME, metric, oldVal, newVal); } - private void verifyNotSupported(long metricVal) { - Asserts.assertEquals(metricVal, NOT_SUPPORTED, "Expected metric to be not supported!"); - } - - private void verifyNotSupported(double metricVal) { - if (!CgroupMetricsTester.compareWithErrorMargin(NOT_SUPPORTED, metricVal)) { - throw new RuntimeException("Metric not supported, got: " + metricVal + - " expected: " + NOT_SUPPORTED); - } - } - - private void verifyPerCpuNotSupported(long[] perCpuUsage) { - Asserts.assertNull(perCpuUsage, "perCpuUsage expected to be not supported"); - } - private long getCpuShares(String file) { long rawVal = getLongValueFromFile(file); if (rawVal == 0 || rawVal == 100) { @@ -243,18 +227,6 @@ if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) { fail("memory.current", oldVal, newVal); } - verifyNotSupported(metrics.getMemoryMaxUsage()); - - // Kernel memory - verifyNotSupported(metrics.getKernelMemoryFailCount()); - verifyNotSupported(metrics.getKernelMemoryLimit()); - verifyNotSupported(metrics.getKernelMemoryMaxUsage()); - verifyNotSupported(metrics.getKernelMemoryUsage()); - - //TCP Memory - verifyNotSupported(metrics.getTcpMemoryFailCount()); - verifyNotSupported(metrics.getTcpMemoryLimit()); - verifyNotSupported(metrics.getTcpMemoryMaxUsage()); oldVal = metrics.getTcpMemoryUsage(); newVal = getLongValueEntryFromFile("memory.stat", "sock"); @@ -262,10 +234,6 @@ fail("memory.stat[sock]", oldVal, newVal); } - // Memory and Swap - verifyNotSupported(metrics.getMemoryAndSwapFailCount()); - verifyNotSupported(metrics.getMemoryAndSwapMaxUsage()); - oldVal = metrics.getMemoryAndSwapLimit(); newVal = getLongLimitValueFromFile("memory.swap.max"); if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) { @@ -284,7 +252,6 @@ fail("memory.high", oldVal, newVal); } - Asserts.assertNull(metrics.isMemoryOOMKillEnabled(), "Not supported"); } @Override @@ -297,8 +264,6 @@ warn("cpu.stat[usage_usec]", oldVal, newVal); } - verifyPerCpuNotSupported(metrics.getPerCpuUsage()); - oldVal = metrics.getCpuUserUsage(); newVal = TimeUnit.MICROSECONDS.toNanos(getLongValueEntryFromFile("cpu.stat", "user_usec")); if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) { @@ -400,9 +365,6 @@ fail("cpuset.mems.effective", Arrays.toString(oldVal), Arrays.toString(newVal)); } - - verifyNotSupported(metrics.getCpuSetMemoryPressure()); - Asserts.assertNull(metrics.isCpuSetMemoryPressureEnabled(), "Should be not supported"); } private int[] mapNullToEmpty(int[] cpus) { @@ -422,8 +384,6 @@ long newUserVal = metrics.getCpuUserUsage(); long newUsage = metrics.getCpuUsage(); - verifyPerCpuNotSupported(metrics.getPerCpuUsage()); - // system/user CPU usage counters may be slowly increasing. // allow for equal values for a pass if (newSysVal < startSysVal) { @@ -444,9 +404,8 @@ @Override public void testMemoryUsage() { Metrics metrics = Metrics.systemMetrics(); - long memoryMaxUsage = metrics.getMemoryMaxUsage(); long memoryUsage = metrics.getMemoryUsage(); - long newMemoryMaxUsage = 0, newMemoryUsage = 0; + long newMemoryUsage = 0; // allocate memory in a loop and check more than once for new values // otherwise we might occasionally see the effect of decreasing new memory @@ -459,12 +418,6 @@ break; } } - newMemoryMaxUsage = metrics.getMemoryMaxUsage(); - - if (newMemoryMaxUsage < memoryMaxUsage) { - fail("getMemoryMaxUsage", memoryMaxUsage, - newMemoryMaxUsage); - } if (newMemoryUsage < memoryUsage) { fail("getMemoryUsage", memoryUsage, newMemoryUsage); @@ -511,7 +464,7 @@ return accumulator; }).collect(Collectors.summingLong(e -> e)); } catch (IOException e) { - return Metrics.LONG_RETVAL_NOT_SUPPORTED; + return CgroupSubsystem.LONG_RETVAL_UNLIMITED; } } }