< prev index next >

test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java

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

@@ -35,10 +35,12 @@
 import java.nio.file.attribute.BasicFileAttributes;
 import java.util.Arrays;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
+import jdk.test.lib.Platform;
 import jdk.test.lib.Utils;
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.process.ProcessTools;
 import jtreg.SkippedException;
 

@@ -52,15 +54,10 @@
     // Having too many lines in the main test output will result
     // in JT harness trimming the output, and can lead to loss of useful
     // 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.
     // E.g.: start image interactively: docker run -it <IMAGE_NAME>.
     public static final boolean RETAIN_IMAGE_AFTER_TEST =

@@ -114,11 +111,11 @@
      * @return true if docker engine is available and usable
      * @throws Exception
      */
     private static boolean isDockerEngineAvailableCheck() throws Exception {
         try {
-            execute(DOCKER_COMMAND, "ps")
+            execute(Platform.DOCKER_COMMAND, "ps")
                 .shouldHaveExitValue(0)
                 .shouldContain("CONTAINER")
                 .shouldContain("IMAGE");
         } catch (Exception e) {
             return false;

@@ -177,13 +174,12 @@
         generateDockerFile(buildDir.resolve("Dockerfile"),
                            DockerfileConfig.getBaseImageName(),
                            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
             // instead of failing the test.
             throw new SkippedException("Building docker image failed. Details: \n" + e.getMessage());

@@ -200,11 +196,11 @@
      * @throws Exception
      */
     public static List<String> buildJavaCommand(DockerRunOptions opts) throws Exception {
         List<String> cmd = new ArrayList<>();
 
-        cmd.add(DOCKER_COMMAND);
+        cmd.add(Platform.DOCKER_COMMAND);
         cmd.add("run");
         if (opts.tty)
             cmd.add("--tty=true");
         if (opts.removeContainerAfterUse)
             cmd.add("--rm");

@@ -242,11 +238,11 @@
      *
      * @param DockerRunOptions optins for running docker
      * @throws Exception
      */
     public static void removeDockerImage(String imageNameAndTag) throws Exception {
-            execute(DOCKER_COMMAND, "rmi", "--force", imageNameAndTag);
+            execute(Platform.DOCKER_COMMAND, "rmi", "--force", imageNameAndTag);
     }
 
 
 
     /**
< prev index next >