changeset 10780:9d42d5dfa0cf

Merge
author andrew
date Fri, 28 Aug 2020 07:32:38 +0100
parents 6898cbe6d575 (current diff) 9ceaa376784a (diff)
children 633a3d28d2fe
files
diffstat 7 files changed, 107 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/THIRD_PARTY_README	Wed Aug 26 03:59:50 2020 +0100
+++ b/THIRD_PARTY_README	Fri Aug 28 07:32:38 2020 +0100
@@ -2240,7 +2240,7 @@
 
 -------------------------------------------------------------------------------
 
-%% This notice is provided with respect to PC/SC Lite v1.8.24,
+%% This notice is provided with respect to PC/SC Lite v1.8.26,
 which may be included with JRE 8, JDK 8, and OpenJDK 8 on Linux and Solaris.
 
 --- begin of LICENSE ---
--- a/src/share/vm/runtime/globals.hpp	Wed Aug 26 03:59:50 2020 +0100
+++ b/src/share/vm/runtime/globals.hpp	Fri Aug 28 07:32:38 2020 +0100
@@ -1339,7 +1339,7 @@
   develop(bool, TraceClassInitialization, false,                            \
           "Trace class initialization")                                     \
                                                                             \
-  develop(bool, TraceExceptions, false,                                     \
+  product(bool, TraceExceptions, false,                                     \
           "Trace exceptions")                                               \
                                                                             \
   develop(bool, TraceICs, false,                                            \
--- a/test/runtime/CommandLine/TraceExceptionsTest.java	Wed Aug 26 03:59:50 2020 +0100
+++ b/test/runtime/CommandLine/TraceExceptionsTest.java	Fri Aug 28 07:32:38 2020 +0100
@@ -33,11 +33,6 @@
 public class TraceExceptionsTest {
     public static void main(String[] args) throws Exception {
 
-        if (!Platform.isDebugBuild()) {
-          System.out.println("Skip the test on product builds since XX:+TraceExceptions is not available on product builds");
-          return;
-        }
-
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
             "-XX:+TraceExceptions", "NoClassFound");
         OutputAnalyzer output = new OutputAnalyzer(pb.start());
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/runtime/containers/docker/CheckOperatingSystemMXBean.java	Fri Aug 28 07:32:38 2020 +0100
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import com.sun.management.OperatingSystemMXBean;
+import java.lang.management.ManagementFactory;
+
+public class CheckOperatingSystemMXBean {
+
+    public static void main(String[] args) {
+        System.out.println("Checking OperatingSystemMXBean");
+
+        OperatingSystemMXBean osBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
+        System.out.println(String.format("Runtime.availableProcessors: %d", Runtime.getRuntime().availableProcessors()));
+        System.out.println(String.format("OperatingSystemMXBean.getAvailableProcessors: %d", osBean.getAvailableProcessors()));
+        System.out.println(String.format("OperatingSystemMXBean.getTotalPhysicalMemorySize: %d", osBean.getTotalPhysicalMemorySize()));
+        System.out.println(String.format("OperatingSystemMXBean.getFreePhysicalMemorySize: %d", osBean.getFreePhysicalMemorySize()));
+        System.out.println(String.format("OperatingSystemMXBean.getTotalSwapSpaceSize: %d", osBean.getTotalSwapSpaceSize()));
+        System.out.println(String.format("OperatingSystemMXBean.getFreeSwapSpaceSize: %d", osBean.getFreeSwapSpaceSize()));
+        System.out.println(String.format("OperatingSystemMXBean.getSystemCpuLoad: %f", osBean.getSystemCpuLoad()));
+    }
+
+}
--- a/test/runtime/containers/docker/Dockerfile-BasicTest	Wed Aug 26 03:59:50 2020 +0100
+++ b/test/runtime/containers/docker/Dockerfile-BasicTest	Fri Aug 28 07:32:38 2020 +0100
@@ -1,4 +1,4 @@
-FROM oraclelinux:7.2
+FROM oraclelinux:7.6
 MAINTAINER mikhailo.seledtsov@oracle.com
 
 COPY /jdk /jdk
--- a/test/runtime/containers/docker/TestCPUAwareness.java	Wed Aug 26 03:59:50 2020 +0100
+++ b/test/runtime/containers/docker/TestCPUAwareness.java	Fri Aug 28 07:32:38 2020 +0100
@@ -25,7 +25,9 @@
 /*
  * @test
  * @summary Test JVM's CPU resource awareness when running inside docker container
- * @library /testlibrary
+ * @library /testlibrary /testlibrary/whitebox
+ * @build sun.hotspot.WhiteBox PrintContainerInfo CheckOperatingSystemMXBean
+ * @run driver ClassFileInstaller -jar whitebox.jar sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run driver TestCPUAwareness
  */
 
@@ -72,6 +74,14 @@
             testCpuQuotaAndPeriod(150*1000, 100*1000);
             testCpuQuotaAndPeriod(400*1000, 100*1000);
 
+            testOperatingSystemMXBeanAwareness("0.5", "1");
+            testOperatingSystemMXBeanAwareness("1.0", "1");
+            if (availableCPUs > 2) {
+                testOperatingSystemMXBeanAwareness("1.2", "2");
+                testOperatingSystemMXBeanAwareness("1.8", "2");
+                testOperatingSystemMXBeanAwareness("2.0", "2");
+            }
+
         } finally {
             DockerTestUtils.removeDockerImage(imageName);
         }
@@ -202,4 +212,21 @@
             .shouldMatch("CPU Shares is.*" + shares)
             .shouldMatch("active_processor_count.*" + expectedAPC);
     }
+
+    private static void testOperatingSystemMXBeanAwareness(String cpuAllocation, String expectedCpus) throws Exception {
+        Common.logNewTestCase("Check OperatingSystemMXBean");
+
+        DockerRunOptions opts = Common.newOpts(imageName, "CheckOperatingSystemMXBean")
+            .addDockerOpts(
+                "--cpus", cpuAllocation
+            );
+
+        DockerTestUtils.dockerRunJava(opts)
+            .shouldHaveExitValue(0)
+            .shouldContain("Checking OperatingSystemMXBean")
+            .shouldContain("Runtime.availableProcessors: " + expectedCpus)
+            .shouldContain("OperatingSystemMXBean.getAvailableProcessors: " + expectedCpus)
+            .shouldMatch("OperatingSystemMXBean\\.getSystemCpuLoad: [0-9]+\\.[0-9]+")
+            ;
+    }
 }
--- a/test/runtime/containers/docker/TestMemoryAwareness.java	Wed Aug 26 03:59:50 2020 +0100
+++ b/test/runtime/containers/docker/TestMemoryAwareness.java	Fri Aug 28 07:32:38 2020 +0100
@@ -26,7 +26,7 @@
  * @test
  * @summary Test JVM's memory resource awareness when running inside docker container
  * @library /testlibrary /testlibrary/whitebox
- * @build AttemptOOM sun.hotspot.WhiteBox PrintContainerInfo
+ * @build AttemptOOM sun.hotspot.WhiteBox PrintContainerInfo CheckOperatingSystemMXBean
  * @run driver ClassFileInstaller -jar whitebox.jar sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  * @run driver TestMemoryAwareness
  */
@@ -59,6 +59,18 @@
             // Add extra 10 Mb to allocator limit, to be sure to cause OOM
             testOOM("256m", 256 + 10);
 
+            testOperatingSystemMXBeanAwareness(
+                "100M", Integer.toString(((int) Math.pow(2, 20)) * 100),
+                "150M", Integer.toString(((int) Math.pow(2, 20)) * (150 - 100))
+            );
+            testOperatingSystemMXBeanAwareness(
+                "128M", Integer.toString(((int) Math.pow(2, 20)) * 128),
+                "256M", Integer.toString(((int) Math.pow(2, 20)) * (256 - 128))
+            );
+            testOperatingSystemMXBeanAwareness(
+                "1G", Integer.toString(((int) Math.pow(2, 20)) * 1024),
+                "1500M", Integer.toString(((int) Math.pow(2, 20)) * (1500 - 1024))
+            );
         } finally {
             DockerTestUtils.removeDockerImage(imageName);
         }
@@ -106,4 +118,24 @@
             .shouldContain("java.lang.OutOfMemoryError");
     }
 
+    private static void testOperatingSystemMXBeanAwareness(String memoryAllocation, String expectedMemory,
+            String swapAllocation, String expectedSwap) throws Exception {
+        Common.logNewTestCase("Check OperatingSystemMXBean");
+
+        DockerRunOptions opts = Common.newOpts(imageName, "CheckOperatingSystemMXBean")
+            .addDockerOpts(
+                "--memory", memoryAllocation,
+                "--memory-swap", swapAllocation
+            );
+
+        DockerTestUtils.dockerRunJava(opts)
+            .shouldHaveExitValue(0)
+            .shouldContain("Checking OperatingSystemMXBean")
+            .shouldContain("OperatingSystemMXBean.getTotalPhysicalMemorySize: " + expectedMemory)
+            .shouldMatch("OperatingSystemMXBean\\.getFreePhysicalMemorySize: [1-9][0-9]+")
+            .shouldContain("OperatingSystemMXBean.getTotalSwapSpaceSize: " + expectedSwap)
+            .shouldMatch("OperatingSystemMXBean\\.getFreeSwapSpaceSize: [1-9][0-9]+")
+            ;
+    }
+
 }