< prev index next >

test/hotspot/jtreg/runtime/containers/docker/TestCPUAwareness.java

Print this page
rev 53488 : 8217597: [TESTBUG] old version docker does not support --cpus
Summary: "--cpus" is available in Docker 1.13 and higher, and is the equivalent of setting both --cpu-period and --cpu-quota.


 112                 testAPCCombo(testCpuSet, 200*1000, 100*1000, 1023,   true, 2);
 113                 testAPCCombo(testCpuSet, 200*1000, 100*1000, 1023,   false,  1);
 114             }
 115         }
 116     }
 117 
 118 
 119     private static void testActiveProcessorCount(int valueToSet, int expectedValue) throws Exception {
 120         Common.logNewTestCase("Test ActiveProcessorCount: valueToSet = " + valueToSet);
 121 
 122         DockerRunOptions opts = Common.newOpts(imageName)
 123             .addJavaOpts("-XX:ActiveProcessorCount=" + valueToSet, "-Xlog:os=trace");
 124         Common.run(opts)
 125             .shouldMatch("active processor count set by user.*" + expectedValue);
 126     }
 127 
 128 
 129     private static void testCpus(int valueToSet, int expectedTraceValue) throws Exception {
 130         Common.logNewTestCase("test cpus: " + valueToSet);
 131         DockerRunOptions opts = Common.newOpts(imageName)
 132             .addDockerOpts("--cpus", "" + valueToSet);

 133         Common.run(opts)
 134             .shouldMatch("active_processor_count.*" + expectedTraceValue);
 135     }
 136 
 137 
 138     // Expected active processor count can not exceed available CPU count
 139     private static int adjustExpectedAPCForAvailableCPUs(int expectedAPC) {
 140         if (expectedAPC > availableCPUs) {
 141             expectedAPC = availableCPUs;
 142             System.out.println("Adjusted expectedAPC = " + expectedAPC);
 143         }
 144         return expectedAPC;
 145     }
 146 
 147 
 148     private static void testCpuQuotaAndPeriod(int quota, int period)
 149         throws Exception {
 150         Common.logNewTestCase("test cpu quota and period: ");
 151         System.out.println("quota = " + quota);
 152         System.out.println("period = " + period);




 112                 testAPCCombo(testCpuSet, 200*1000, 100*1000, 1023,   true, 2);
 113                 testAPCCombo(testCpuSet, 200*1000, 100*1000, 1023,   false,  1);
 114             }
 115         }
 116     }
 117 
 118 
 119     private static void testActiveProcessorCount(int valueToSet, int expectedValue) throws Exception {
 120         Common.logNewTestCase("Test ActiveProcessorCount: valueToSet = " + valueToSet);
 121 
 122         DockerRunOptions opts = Common.newOpts(imageName)
 123             .addJavaOpts("-XX:ActiveProcessorCount=" + valueToSet, "-Xlog:os=trace");
 124         Common.run(opts)
 125             .shouldMatch("active processor count set by user.*" + expectedValue);
 126     }
 127 
 128 
 129     private static void testCpus(int valueToSet, int expectedTraceValue) throws Exception {
 130         Common.logNewTestCase("test cpus: " + valueToSet);
 131         DockerRunOptions opts = Common.newOpts(imageName)
 132             .addDockerOpts("--cpu-period=" + 10000)
 133             .addDockerOpts("--cpu-quota=" + valueToSet * 10000);
 134         Common.run(opts)
 135             .shouldMatch("active_processor_count.*" + expectedTraceValue);
 136     }
 137 
 138 
 139     // Expected active processor count can not exceed available CPU count
 140     private static int adjustExpectedAPCForAvailableCPUs(int expectedAPC) {
 141         if (expectedAPC > availableCPUs) {
 142             expectedAPC = availableCPUs;
 143             System.out.println("Adjusted expectedAPC = " + expectedAPC);
 144         }
 145         return expectedAPC;
 146     }
 147 
 148 
 149     private static void testCpuQuotaAndPeriod(int quota, int period)
 150         throws Exception {
 151         Common.logNewTestCase("test cpu quota and period: ");
 152         System.out.println("quota = " + quota);
 153         System.out.println("period = " + period);


< prev index next >