Mercurial > hg > icedtea8-forest > jdk
changeset 14909:e587e2d238a0
8227642: [TESTBUG] Make docker tests podman compatible
Reviewed-by: mseledtsov, iignatyev, phh
author | sgehwolf |
---|---|
date | Fri, 12 Jul 2019 19:37:25 +0200 |
parents | 17c2b3fda521 |
children | ac977b45cfa9 |
files | test/lib/jdk/test/lib/Platform.java test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java |
diffstat | 3 files changed, 19 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/test/lib/jdk/test/lib/Platform.java Fri Sep 25 17:16:38 2020 +0000 +++ b/test/lib/jdk/test/lib/Platform.java Fri Jul 12 19:37:25 2019 +0200 @@ -33,6 +33,12 @@ import java.util.stream.Collectors; 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 = System.getProperty("java.vm.name"); public static final String vmInfo = System.getProperty("java.vm.info"); private static final String osVersion = System.getProperty("os.version");
--- a/test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java Fri Sep 25 17:16:38 2020 +0000 +++ b/test/lib/jdk/test/lib/containers/cgroup/MetricsTester.java Fri Jul 12 19:37:25 2019 +0200 @@ -534,16 +534,20 @@ 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;
--- a/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java Fri Sep 25 17:16:38 2020 +0000 +++ b/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java Fri Jul 12 19:37:25 2019 +0200 @@ -36,6 +36,7 @@ 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; @@ -46,11 +47,6 @@ private static boolean isDockerEngineAvailable = false; private static boolean wasDockerEngineChecked = false; - // 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. @@ -110,7 +106,7 @@ */ private static boolean isDockerEngineAvailableCheck() throws Exception { try { - execute(DOCKER_COMMAND, "ps") + execute(Platform.DOCKER_COMMAND, "ps") .shouldHaveExitValue(0) .shouldContain("CONTAINER") .shouldContain("IMAGE"); @@ -173,9 +169,8 @@ DockerfileConfig.getBaseImageVersion()); // 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); } @@ -190,7 +185,7 @@ public static OutputAnalyzer dockerRunJava(DockerRunOptions opts) throws Exception { ArrayList<String> cmd = new ArrayList<>(); - cmd.add(DOCKER_COMMAND); + cmd.add(Platform.DOCKER_COMMAND); cmd.add("run"); if (opts.tty) cmd.add("--tty=true"); @@ -220,7 +215,7 @@ * @throws Exception */ public static void removeDockerImage(String imageNameAndTag) throws Exception { - execute(DOCKER_COMMAND, "rmi", "--force", imageNameAndTag); + execute(Platform.DOCKER_COMMAND, "rmi", "--force", imageNameAndTag); }