From 422e04e98f6a713792e5a852080264998f2e5894 Mon Sep 17 00:00:00 2001 From: Severin Gehwolf Date: Fri, 12 Jul 2019 19:37:25 +0200 Subject: [PATCH 1/3] 8227642: [TESTBUG] Make docker tests podman compatible Reviewed-by: mseledtsov, iignatyev --- test/jtreg-ext/requires/VMProps.java | 2 +- test/lib/jdk/test/lib/Platform.java | 6 ++++++ .../lib/containers/cgroup/MetricsTester.java | 10 +++++++--- .../lib/containers/docker/DockerTestUtils.java | 17 ++++++----------- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index 2483d0f29ea..a37b0f56660 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -455,7 +455,7 @@ public class VMProps implements Callable> { } private boolean checkDockerSupport() throws IOException, InterruptedException { - ProcessBuilder pb = new ProcessBuilder("docker", "ps"); + ProcessBuilder pb = new ProcessBuilder(Platform.DOCKER_COMMAND, "ps"); Process p = pb.start(); p.waitFor(10, TimeUnit.SECONDS); diff --git a/test/lib/jdk/test/lib/Platform.java b/test/lib/jdk/test/lib/Platform.java index 7be0ec171c6..46db877d737 100644 --- a/test/lib/jdk/test/lib/Platform.java +++ b/test/lib/jdk/test/lib/Platform.java @@ -33,6 +33,12 @@ import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; public class Platform { + // Use this property to specify docker location on your system. + // E.g.: "/usr/local/bin/docker". We define this constant here so + // that it can be used in VMProps as well which checks docker support + // via this command + public static final String DOCKER_COMMAND = + System.getProperty("jdk.test.docker.command", "docker"); public static final String vmName = privilegedGetProperty("java.vm.name"); public static final String vmInfo = privilegedGetProperty("java.vm.info"); private static final String osVersion = privilegedGetProperty("os.version"); diff --git a/test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java b/test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java index 13f4693f8e5..115dcf9f1cf 100644 --- a/test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java +++ b/test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java @@ -550,16 +550,20 @@ public class MetricsTester { long newUsage = metrics.getCpuUsage(); long[] newPerCpu = metrics.getPerCpuUsage(); - if (newSysVal <= startSysVal) { + // system/user CPU usage counters may be slowly increasing. + // allow for equal values for a pass + if (newSysVal < startSysVal) { fail(SubSystem.CPU, "getCpuSystemUsage", newSysVal, startSysVal); } - if (newUserVal <= startUserVal) { + // system/user CPU usage counters may be slowly increasing. + // allow for equal values for a pass + if (newUserVal < startUserVal) { fail(SubSystem.CPU, "getCpuUserUsage", newUserVal, startUserVal); } if (newUsage <= startUsage) { - fail(SubSystem.CPU, "getCpuUserUsage", newUsage, startUsage); + fail(SubSystem.CPU, "getCpuUsage", newUsage, startUsage); } boolean success = false; diff --git a/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java b/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java index 1044e57fc4f..132cea129bb 100644 --- a/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java +++ b/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java @@ -37,6 +37,7 @@ import java.util.Arrays; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import jdk.test.lib.Platform; import jdk.test.lib.Utils; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; @@ -54,11 +55,6 @@ public class DockerTestUtils { // diagnostic information. private static final int MAX_LINES_TO_COPY_FOR_CHILD_STDOUT = 100; - // Use this property to specify docker location on your system. - // E.g.: "/usr/local/bin/docker". - private static final String DOCKER_COMMAND = - System.getProperty("jdk.test.docker.command", "docker"); - // Set this property to true to retain image after test. By default // images are removed after test execution completes. // Retaining the image can be useful for diagnostics and image inspection. @@ -116,7 +112,7 @@ public class DockerTestUtils { */ private static boolean isDockerEngineAvailableCheck() throws Exception { try { - execute(DOCKER_COMMAND, "ps") + execute(Platform.DOCKER_COMMAND, "ps") .shouldHaveExitValue(0) .shouldContain("CONTAINER") .shouldContain("IMAGE"); @@ -179,9 +175,8 @@ public class DockerTestUtils { DockerfileConfig.getBaseImageVersion()); try { // Build the docker - execute(DOCKER_COMMAND, "build", "--no-cache", "--tag", imageName, buildDir.toString()) - .shouldHaveExitValue(0) - .shouldContain("Successfully built"); + execute(Platform.DOCKER_COMMAND, "build", "--no-cache", "--tag", imageName, buildDir.toString()) + .shouldHaveExitValue(0); } catch (Exception e) { // If docker image building fails there is a good chance it happens due to environment and/or // configuration other than product failure. Throw jtreg skipped exception in such case @@ -202,7 +197,7 @@ public class DockerTestUtils { public static List buildJavaCommand(DockerRunOptions opts) throws Exception { List cmd = new ArrayList<>(); - cmd.add(DOCKER_COMMAND); + cmd.add(Platform.DOCKER_COMMAND); cmd.add("run"); if (opts.tty) cmd.add("--tty=true"); @@ -244,7 +239,7 @@ public class DockerTestUtils { * @throws Exception */ public static void removeDockerImage(String imageNameAndTag) throws Exception { - execute(DOCKER_COMMAND, "rmi", "--force", imageNameAndTag); + execute(Platform.DOCKER_COMMAND, "rmi", "--force", imageNameAndTag); } From 843ee2be16f020b9f29e2b96a4bf8f39e75b9e76 Mon Sep 17 00:00:00 2001 From: Severin Gehwolf Date: Mon, 22 Jul 2019 10:48:14 +0200 Subject: [PATCH 2/3] 8228434: jdk/net/Sockets/Test.java fails after JDK-8227642 Move container constant to separate test lib class Reviewed-by: alanb --- test/hotspot/jtreg/TEST.ROOT | 4 ++- test/jdk/TEST.ROOT | 4 ++- test/jtreg-ext/requires/VMProps.java | 3 +- test/lib/jdk/test/lib/Container.java | 32 +++++++++++++++++++ test/lib/jdk/test/lib/Platform.java | 6 ---- .../containers/docker/DockerTestUtils.java | 10 +++--- 6 files changed, 45 insertions(+), 14 deletions(-) create mode 100644 test/lib/jdk/test/lib/Container.java diff --git a/test/hotspot/jtreg/TEST.ROOT b/test/hotspot/jtreg/TEST.ROOT index 406709d1d47..bd51c2a45e1 100644 --- a/test/hotspot/jtreg/TEST.ROOT +++ b/test/hotspot/jtreg/TEST.ROOT @@ -35,7 +35,9 @@ groups=TEST.groups TEST.quick-groups # to determine additional characteristics of the system for use with the @requires tag. # Note: compiled bootlibs code will be located in the folder 'bootClasses' requires.extraPropDefns = ../../jtreg-ext/requires/VMProps.java -requires.extraPropDefns.bootlibs = ../../lib/sun ../../lib/jdk/test/lib/Platform.java +requires.extraPropDefns.bootlibs = ../../lib/sun \ + ../../lib/jdk/test/lib/Platform.java \ + ../../lib/jdk/test/lib/Container.java requires.extraPropDefns.vmOpts = -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:bootClasses requires.properties= \ sun.arch.data.model \ diff --git a/test/jdk/TEST.ROOT b/test/jdk/TEST.ROOT index bbaae892450..3f504bfce04 100644 --- a/test/jdk/TEST.ROOT +++ b/test/jdk/TEST.ROOT @@ -37,7 +37,9 @@ groups=TEST.groups # to determine additional characteristics of the system for use with the @requires tag. # Note: compiled bootlibs code will be located in the folder 'bootClasses' requires.extraPropDefns = ../jtreg-ext/requires/VMProps.java -requires.extraPropDefns.bootlibs = ../lib/sun ../lib/jdk/test/lib/Platform.java +requires.extraPropDefns.bootlibs = ../lib/sun \ + ../lib/jdk/test/lib/Platform.java \ + ../lib/jdk/test/lib/Container.java requires.extraPropDefns.vmOpts = -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:bootClasses requires.properties= \ sun.arch.data.model \ diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index a37b0f56660..1db892eb43f 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -46,6 +46,7 @@ import sun.hotspot.cpuinfo.CPUInfo; import sun.hotspot.gc.GC; import sun.hotspot.WhiteBox; import jdk.test.lib.Platform; +import jdk.test.lib.Container; /** * The Class to be invoked by jtreg prior Test Suite execution to @@ -455,7 +456,7 @@ public class VMProps implements Callable> { } private boolean checkDockerSupport() throws IOException, InterruptedException { - ProcessBuilder pb = new ProcessBuilder(Platform.DOCKER_COMMAND, "ps"); + ProcessBuilder pb = new ProcessBuilder(Container.ENGINE_COMMAND, "ps"); Process p = pb.start(); p.waitFor(10, TimeUnit.SECONDS); diff --git a/test/lib/jdk/test/lib/Container.java b/test/lib/jdk/test/lib/Container.java new file mode 100644 index 00000000000..e0ca4851e14 --- /dev/null +++ b/test/lib/jdk/test/lib/Container.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2019, Red Hat Inc. + * 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. + */ +package jdk.test.lib; + +public class Container { + // Use this property to specify docker location on your system. + // E.g.: "/usr/local/bin/docker". We define this constant here so + // that it can be used in VMProps as well which checks docker support + // via this command + public static final String ENGINE_COMMAND = + System.getProperty("jdk.test.container.command", "docker"); +} diff --git a/test/lib/jdk/test/lib/Platform.java b/test/lib/jdk/test/lib/Platform.java index 46db877d737..7be0ec171c6 100644 --- a/test/lib/jdk/test/lib/Platform.java +++ b/test/lib/jdk/test/lib/Platform.java @@ -33,12 +33,6 @@ import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; public class Platform { - // Use this property to specify docker location on your system. - // E.g.: "/usr/local/bin/docker". We define this constant here so - // that it can be used in VMProps as well which checks docker support - // via this command - public static final String DOCKER_COMMAND = - System.getProperty("jdk.test.docker.command", "docker"); public static final String vmName = privilegedGetProperty("java.vm.name"); public static final String vmInfo = privilegedGetProperty("java.vm.info"); private static final String osVersion = privilegedGetProperty("os.version"); diff --git a/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java b/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java index 132cea129bb..9ff511110c2 100644 --- a/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java +++ b/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java @@ -37,7 +37,7 @@ import java.util.Arrays; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import jdk.test.lib.Platform; +import jdk.test.lib.Container; import jdk.test.lib.Utils; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; @@ -112,7 +112,7 @@ public class DockerTestUtils { */ private static boolean isDockerEngineAvailableCheck() throws Exception { try { - execute(Platform.DOCKER_COMMAND, "ps") + execute(Container.ENGINE_COMMAND, "ps") .shouldHaveExitValue(0) .shouldContain("CONTAINER") .shouldContain("IMAGE"); @@ -175,7 +175,7 @@ public class DockerTestUtils { DockerfileConfig.getBaseImageVersion()); try { // Build the docker - execute(Platform.DOCKER_COMMAND, "build", "--no-cache", "--tag", imageName, buildDir.toString()) + execute(Container.ENGINE_COMMAND, "build", "--no-cache", "--tag", imageName, buildDir.toString()) .shouldHaveExitValue(0); } catch (Exception e) { // If docker image building fails there is a good chance it happens due to environment and/or @@ -197,7 +197,7 @@ public class DockerTestUtils { public static List buildJavaCommand(DockerRunOptions opts) throws Exception { List cmd = new ArrayList<>(); - cmd.add(Platform.DOCKER_COMMAND); + cmd.add(Container.ENGINE_COMMAND); cmd.add("run"); if (opts.tty) cmd.add("--tty=true"); @@ -239,7 +239,7 @@ public class DockerTestUtils { * @throws Exception */ public static void removeDockerImage(String imageNameAndTag) throws Exception { - execute(Platform.DOCKER_COMMAND, "rmi", "--force", imageNameAndTag); + execute(Container.ENGINE_COMMAND, "rmi", "--force", imageNameAndTag); } From c98e06ff52d57da565864a299d4ee060071638a7 Mon Sep 17 00:00:00 2001 From: Patrick Concannon Date: Wed, 7 Aug 2019 08:42:14 -0700 Subject: [PATCH 3/3] 8228971: Locale API doc has redundant hyphens for some parameters Reviewed-by: lancea --- src/java.base/share/classes/java/util/Locale.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/java.base/share/classes/java/util/Locale.java b/src/java.base/share/classes/java/util/Locale.java index 7777aed2cdd..55493428025 100644 --- a/src/java.base/share/classes/java/util/Locale.java +++ b/src/java.base/share/classes/java/util/Locale.java @@ -929,7 +929,7 @@ public final class Locale implements Cloneable, Serializable { * if no locale is explicitly specified. It can be changed using the * setDefault(Locale.Category, Locale) method. * - * @param category - the specified category to get the default locale + * @param category the specified category to get the default locale * @throws NullPointerException if category is null * @return the default locale for the specified Category for this instance * of the Java Virtual Machine @@ -1075,8 +1075,8 @@ public final class Locale implements Cloneable, Serializable { * prepared to reinitialize locale-sensitive code running within the * same Java Virtual Machine. * - * @param category - the specified category to set the default locale - * @param newLocale - the new default locale + * @param category the specified category to set the default locale + * @param newLocale the new default locale * @throws SecurityException if a security manager exists and its * checkPermission method doesn't allow the operation. * @throws NullPointerException if category and/or newLocale is null