< prev index next >

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

Print this page
@  rev 55684 : 8227642: [TESTBUG] Make docker tests podman compatible
|  Reviewed-by: mseledtsov, iignatyev
~


 514         if (!compareWithErrorMargin(oldVal, newVal)) {
 515             fail(SubSystem.BLKIO, "blkio.throttle.io_service_bytes - Total",
 516                     oldVal, newVal);
 517         }
 518 
 519         oldVal = metrics.getBlkIOServiced();
 520         newVal = getLongValueFromFile(SubSystem.BLKIO, "blkio.throttle.io_serviced", "Total");
 521         if (!compareWithErrorMargin(oldVal, newVal)) {
 522             fail(SubSystem.BLKIO, "blkio.throttle.io_serviced - Total", oldVal, newVal);
 523         }
 524     }
 525 
 526     public void testCpuConsumption() throws IOException, InterruptedException {
 527         Metrics metrics = Metrics.systemMetrics();
 528         // make system call
 529         long newSysVal = metrics.getCpuSystemUsage();
 530         long newUserVal = metrics.getCpuUserUsage();
 531         long newUsage = metrics.getCpuUsage();
 532         long[] newPerCpu = metrics.getPerCpuUsage();
 533 
 534         if (newSysVal <= startSysVal) {


 535             fail(SubSystem.CPU, "getCpuSystemUsage", newSysVal, startSysVal);
 536         }
 537 
 538         if (newUserVal <= startUserVal) {


 539             fail(SubSystem.CPU, "getCpuUserUsage", newUserVal, startUserVal);
 540         }
 541 
 542         if (newUsage <= startUsage) {
 543             fail(SubSystem.CPU, "getCpuUserUsage", newUsage, startUsage);
 544         }
 545 
 546         boolean success = false;
 547         for (int i = 0; i < startPerCpu.length; i++) {
 548             if (newPerCpu[i] > startPerCpu[i]) {
 549                 success = true;
 550                 break;
 551             }
 552         }
 553 
 554         if(!success) fail(SubSystem.CPU, "getPerCpuUsage", Arrays.toString(newPerCpu),
 555                 Arrays.toString(startPerCpu));
 556     }
 557 
 558     public void testMemoryUsage() throws Exception {
 559         Metrics metrics = Metrics.systemMetrics();
 560         long memoryMaxUsage = metrics.getMemoryMaxUsage();
 561         long memoryUsage = metrics.getMemoryUsage();
 562 
 563         byte[] bb = new byte[64*1024*1024]; // 64M




 514         if (!compareWithErrorMargin(oldVal, newVal)) {
 515             fail(SubSystem.BLKIO, "blkio.throttle.io_service_bytes - Total",
 516                     oldVal, newVal);
 517         }
 518 
 519         oldVal = metrics.getBlkIOServiced();
 520         newVal = getLongValueFromFile(SubSystem.BLKIO, "blkio.throttle.io_serviced", "Total");
 521         if (!compareWithErrorMargin(oldVal, newVal)) {
 522             fail(SubSystem.BLKIO, "blkio.throttle.io_serviced - Total", oldVal, newVal);
 523         }
 524     }
 525 
 526     public void testCpuConsumption() throws IOException, InterruptedException {
 527         Metrics metrics = Metrics.systemMetrics();
 528         // make system call
 529         long newSysVal = metrics.getCpuSystemUsage();
 530         long newUserVal = metrics.getCpuUserUsage();
 531         long newUsage = metrics.getCpuUsage();
 532         long[] newPerCpu = metrics.getPerCpuUsage();
 533 
 534         // system/user CPU usage counters may be slowly increasing.
 535         // allow for equal values for a pass
 536         if (newSysVal < startSysVal) {
 537             fail(SubSystem.CPU, "getCpuSystemUsage", newSysVal, startSysVal);
 538         }
 539 
 540         // system/user CPU usage counters may be slowly increasing.
 541         // allow for equal values for a pass
 542         if (newUserVal < startUserVal) {
 543             fail(SubSystem.CPU, "getCpuUserUsage", newUserVal, startUserVal);
 544         }
 545 
 546         if (newUsage <= startUsage) {
 547             fail(SubSystem.CPU, "getCpuUsage", newUsage, startUsage);
 548         }
 549 
 550         boolean success = false;
 551         for (int i = 0; i < startPerCpu.length; i++) {
 552             if (newPerCpu[i] > startPerCpu[i]) {
 553                 success = true;
 554                 break;
 555             }
 556         }
 557 
 558         if(!success) fail(SubSystem.CPU, "getPerCpuUsage", Arrays.toString(newPerCpu),
 559                 Arrays.toString(startPerCpu));
 560     }
 561 
 562     public void testMemoryUsage() throws Exception {
 563         Metrics metrics = Metrics.systemMetrics();
 564         long memoryMaxUsage = metrics.getMemoryMaxUsage();
 565         long memoryUsage = metrics.getMemoryUsage();
 566 
 567         byte[] bb = new byte[64*1024*1024]; // 64M


< prev index next >