equal
deleted
inserted
replaced
35 import java.nio.file.attribute.BasicFileAttributes; |
35 import java.nio.file.attribute.BasicFileAttributes; |
36 import java.util.Arrays; |
36 import java.util.Arrays; |
37 import java.util.ArrayList; |
37 import java.util.ArrayList; |
38 import java.util.Collections; |
38 import java.util.Collections; |
39 import java.util.List; |
39 import java.util.List; |
40 import jdk.test.lib.Platform; |
40 import jdk.test.lib.Container; |
41 import jdk.test.lib.Utils; |
41 import jdk.test.lib.Utils; |
42 import jdk.test.lib.process.OutputAnalyzer; |
42 import jdk.test.lib.process.OutputAnalyzer; |
43 import jdk.test.lib.process.ProcessTools; |
43 import jdk.test.lib.process.ProcessTools; |
44 import jtreg.SkippedException; |
44 import jtreg.SkippedException; |
45 |
45 |
110 * @return true if docker engine is available and usable |
110 * @return true if docker engine is available and usable |
111 * @throws Exception |
111 * @throws Exception |
112 */ |
112 */ |
113 private static boolean isDockerEngineAvailableCheck() throws Exception { |
113 private static boolean isDockerEngineAvailableCheck() throws Exception { |
114 try { |
114 try { |
115 execute(Platform.DOCKER_COMMAND, "ps") |
115 execute(Container.ENGINE_COMMAND, "ps") |
116 .shouldHaveExitValue(0) |
116 .shouldHaveExitValue(0) |
117 .shouldContain("CONTAINER") |
117 .shouldContain("CONTAINER") |
118 .shouldContain("IMAGE"); |
118 .shouldContain("IMAGE"); |
119 } catch (Exception e) { |
119 } catch (Exception e) { |
120 return false; |
120 return false; |
173 generateDockerFile(buildDir.resolve("Dockerfile"), |
173 generateDockerFile(buildDir.resolve("Dockerfile"), |
174 DockerfileConfig.getBaseImageName(), |
174 DockerfileConfig.getBaseImageName(), |
175 DockerfileConfig.getBaseImageVersion()); |
175 DockerfileConfig.getBaseImageVersion()); |
176 try { |
176 try { |
177 // Build the docker |
177 // Build the docker |
178 execute(Platform.DOCKER_COMMAND, "build", "--no-cache", "--tag", imageName, buildDir.toString()) |
178 execute(Container.ENGINE_COMMAND, "build", "--no-cache", "--tag", imageName, buildDir.toString()) |
179 .shouldHaveExitValue(0); |
179 .shouldHaveExitValue(0); |
180 } catch (Exception e) { |
180 } catch (Exception e) { |
181 // If docker image building fails there is a good chance it happens due to environment and/or |
181 // If docker image building fails there is a good chance it happens due to environment and/or |
182 // configuration other than product failure. Throw jtreg skipped exception in such case |
182 // configuration other than product failure. Throw jtreg skipped exception in such case |
183 // instead of failing the test. |
183 // instead of failing the test. |
195 * @throws Exception |
195 * @throws Exception |
196 */ |
196 */ |
197 public static List<String> buildJavaCommand(DockerRunOptions opts) throws Exception { |
197 public static List<String> buildJavaCommand(DockerRunOptions opts) throws Exception { |
198 List<String> cmd = new ArrayList<>(); |
198 List<String> cmd = new ArrayList<>(); |
199 |
199 |
200 cmd.add(Platform.DOCKER_COMMAND); |
200 cmd.add(Container.ENGINE_COMMAND); |
201 cmd.add("run"); |
201 cmd.add("run"); |
202 if (opts.tty) |
202 if (opts.tty) |
203 cmd.add("--tty=true"); |
203 cmd.add("--tty=true"); |
204 if (opts.removeContainerAfterUse) |
204 if (opts.removeContainerAfterUse) |
205 cmd.add("--rm"); |
205 cmd.add("--rm"); |
237 * |
237 * |
238 * @param DockerRunOptions optins for running docker |
238 * @param DockerRunOptions optins for running docker |
239 * @throws Exception |
239 * @throws Exception |
240 */ |
240 */ |
241 public static void removeDockerImage(String imageNameAndTag) throws Exception { |
241 public static void removeDockerImage(String imageNameAndTag) throws Exception { |
242 execute(Platform.DOCKER_COMMAND, "rmi", "--force", imageNameAndTag); |
242 execute(Container.ENGINE_COMMAND, "rmi", "--force", imageNameAndTag); |
243 } |
243 } |
244 |
244 |
245 |
245 |
246 |
246 |
247 /** |
247 /** |