< prev index next >

test/lib/jdk/test/lib/containers/cgroup/MetricsTesterCgroupV1.java

Print this page
@  rev 57735 : Review feedback 2
|
o  rev 57734 : Review feedback
|
o  rev 57733 : 8231111: Cgroups v2: Rework Metrics in java.base so as to recognize unified hierarchy
|  Reviewed-by: bobv, mchung
~
o  rev 56862 : 8231111: Cgroups v2: Rework Metrics in java.base so as to recognize unified hierarchy
|  Reviewed-by: bobv
~

*** 37,47 **** import java.util.stream.Collectors; import java.util.stream.LongStream; import java.util.stream.Stream; import jdk.internal.platform.Metrics; ! import jdk.internal.platform.MetricsCgroupV1; public class MetricsTesterCgroupV1 implements CgroupMetricsTester { private static long unlimited_minimum = 0x7FFFFFFFFF000000L; long startSysVal; --- 37,47 ---- import java.util.stream.Collectors; import java.util.stream.LongStream; import java.util.stream.Stream; import jdk.internal.platform.Metrics; ! import jdk.internal.platform.CgroupV1Metrics; public class MetricsTesterCgroupV1 implements CgroupMetricsTester { private static long unlimited_minimum = 0x7FFFFFFFFF000000L; long startSysVal;
*** 202,212 **** private static void warn(Controller system, String metric, long oldVal, long testVal) { CgroupMetricsTester.warn(system.value, metric, oldVal, testVal); } public void testMemorySubsystem() { ! MetricsCgroupV1 metrics = (MetricsCgroupV1)Metrics.systemMetrics(); // User Memory long oldVal = metrics.getMemoryFailCount(); long newVal = getLongValueFromFile(Controller.MEMORY, "memory.failcnt"); if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) { --- 202,212 ---- private static void warn(Controller system, String metric, long oldVal, long testVal) { CgroupMetricsTester.warn(system.value, metric, oldVal, testVal); } public void testMemorySubsystem() { ! CgroupV1Metrics metrics = (CgroupV1Metrics)Metrics.systemMetrics(); // User Memory long oldVal = metrics.getMemoryFailCount(); long newVal = getLongValueFromFile(Controller.MEMORY, "memory.failcnt"); if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) {
*** 326,336 **** + oomKillEnabled + "], got [" + newOomKillEnabled + "]"); } } public void testCpuAccounting() { ! MetricsCgroupV1 metrics = (MetricsCgroupV1)Metrics.systemMetrics(); long oldVal = metrics.getCpuUsage(); long newVal = getLongValueFromFile(Controller.CPUACCT, "cpuacct.usage"); if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) { warn(Controller.CPUACCT, "cpuacct.usage", oldVal, newVal); --- 326,336 ---- + oomKillEnabled + "], got [" + newOomKillEnabled + "]"); } } public void testCpuAccounting() { ! CgroupV1Metrics metrics = (CgroupV1Metrics)Metrics.systemMetrics(); long oldVal = metrics.getCpuUsage(); long newVal = getLongValueFromFile(Controller.CPUACCT, "cpuacct.usage"); if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) { warn(Controller.CPUACCT, "cpuacct.usage", oldVal, newVal);
*** 365,375 **** warn(Controller.CPUACCT, "cpuacct.usage - system", oldVal, newVal); } } public void testCpuSchedulingMetrics() { ! MetricsCgroupV1 metrics = (MetricsCgroupV1)Metrics.systemMetrics(); long oldVal = metrics.getCpuPeriod(); long newVal = getLongValueFromFile(Controller.CPUACCT, "cpu.cfs_period_us"); if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) { fail(Controller.CPUACCT, "cpu.cfs_period_us", oldVal, newVal); } --- 365,375 ---- warn(Controller.CPUACCT, "cpuacct.usage - system", oldVal, newVal); } } public void testCpuSchedulingMetrics() { ! CgroupV1Metrics metrics = (CgroupV1Metrics)Metrics.systemMetrics(); long oldVal = metrics.getCpuPeriod(); long newVal = getLongValueFromFile(Controller.CPUACCT, "cpu.cfs_period_us"); if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) { fail(Controller.CPUACCT, "cpu.cfs_period_us", oldVal, newVal); }
*** 405,415 **** fail(Controller.CPUACCT, "cpu.stat - throttled_time", oldVal, newVal); } } public void testCpuSets() { ! MetricsCgroupV1 metrics = (MetricsCgroupV1)Metrics.systemMetrics(); Integer[] oldVal = Arrays.stream(metrics.getCpuSetCpus()).boxed().toArray(Integer[]::new); Arrays.sort(oldVal); String cpusstr = getFileContents(Controller.CPUSET, "cpuset.cpus"); // Parse range string in the format 1,2-6,7 --- 405,415 ---- fail(Controller.CPUACCT, "cpu.stat - throttled_time", oldVal, newVal); } } public void testCpuSets() { ! CgroupV1Metrics metrics = (CgroupV1Metrics)Metrics.systemMetrics(); Integer[] oldVal = Arrays.stream(metrics.getCpuSetCpus()).boxed().toArray(Integer[]::new); Arrays.sort(oldVal); String cpusstr = getFileContents(Controller.CPUSET, "cpuset.cpus"); // Parse range string in the format 1,2-6,7
*** 473,483 **** fail(Controller.CPUSET, "cpuset.memory_pressure_enabled", oldV, newV); } } private void testBlkIO() { ! MetricsCgroupV1 metrics = (MetricsCgroupV1)Metrics.systemMetrics(); long oldVal = metrics.getBlkIOServiceCount(); long newVal = getLongValueFromFile(Controller.BLKIO, "blkio.throttle.io_service_bytes", "Total"); if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) { fail(Controller.BLKIO, "blkio.throttle.io_service_bytes - Total", --- 473,483 ---- fail(Controller.CPUSET, "cpuset.memory_pressure_enabled", oldV, newV); } } private void testBlkIO() { ! CgroupV1Metrics metrics = (CgroupV1Metrics)Metrics.systemMetrics(); long oldVal = metrics.getBlkIOServiceCount(); long newVal = getLongValueFromFile(Controller.BLKIO, "blkio.throttle.io_service_bytes", "Total"); if (!CgroupMetricsTester.compareWithErrorMargin(oldVal, newVal)) { fail(Controller.BLKIO, "blkio.throttle.io_service_bytes - Total",
*** 490,500 **** fail(Controller.BLKIO, "blkio.throttle.io_serviced - Total", oldVal, newVal); } } public void testCpuConsumption() throws IOException, InterruptedException { ! MetricsCgroupV1 metrics = (MetricsCgroupV1)Metrics.systemMetrics(); // make system call long newSysVal = metrics.getCpuSystemUsage(); long newUserVal = metrics.getCpuUserUsage(); long newUsage = metrics.getCpuUsage(); long[] newPerCpu = metrics.getPerCpuUsage(); --- 490,500 ---- fail(Controller.BLKIO, "blkio.throttle.io_serviced - Total", oldVal, newVal); } } public void testCpuConsumption() throws IOException, InterruptedException { ! CgroupV1Metrics metrics = (CgroupV1Metrics)Metrics.systemMetrics(); // make system call long newSysVal = metrics.getCpuSystemUsage(); long newUserVal = metrics.getCpuUserUsage(); long newUsage = metrics.getCpuUsage(); long[] newPerCpu = metrics.getPerCpuUsage();
*** 529,539 **** if(!success) fail(Controller.CPU, "getPerCpuUsage", Arrays.toString(newPerCpu), Arrays.toString(startPerCpu)); } public void testMemoryUsage() throws Exception { ! MetricsCgroupV1 metrics = (MetricsCgroupV1)Metrics.systemMetrics(); long memoryMaxUsage = metrics.getMemoryMaxUsage(); long memoryUsage = metrics.getMemoryUsage(); long newMemoryMaxUsage = 0, newMemoryUsage = 0; // allocate memory in a loop and check more than once for new values --- 529,539 ---- if(!success) fail(Controller.CPU, "getPerCpuUsage", Arrays.toString(newPerCpu), Arrays.toString(startPerCpu)); } public void testMemoryUsage() throws Exception { ! CgroupV1Metrics metrics = (CgroupV1Metrics)Metrics.systemMetrics(); long memoryMaxUsage = metrics.getMemoryMaxUsage(); long memoryUsage = metrics.getMemoryUsage(); long newMemoryMaxUsage = 0, newMemoryUsage = 0; // allocate memory in a loop and check more than once for new values
< prev index next >