Skip to content
Browse files
8287398: Allow concurrent execution of hotspot docker tests
Reviewed-by: shade, mseledtsov, sgehwolf
  • Loading branch information
iklam committed Jun 1, 2022
1 parent 8071b23 commit 67ecd30327086c5d7628c4156f8d9dcccb0f4d09
Showing 2 changed files with 34 additions and 33 deletions.

This file was deleted.

@@ -34,36 +34,61 @@
import jdk.test.lib.Utils;
import jdk.test.lib.process.OutputAnalyzer;

import static jdk.test.lib.Asserts.assertNotNull;

public class Common {
public static final String imageNameAndTag = "jdk-internal:test";
// Create a unique name for docker image.
public static String imageName() {
// jtreg guarantees that is unique among all concurrently executing
// tests. For example, if you have two test roots:
// $ find test -type f
// test/foo/TEST.ROOT
// test/foo/my/
// test/bar/TEST.ROOT
// test/bar/my/
// $ jtreg -concur:2 test/foo test/bar
// jtreg will first run all the tests under test/foo. When they are all finished, then
// jtreg will run all the tests under test/bar. So you will never have two concurrent
// test cases whose is "my/"
String testname = System.getProperty("");
assertNotNull(testname, "must be set by jtreg");
testname = testname.replace(".java", "");
testname = testname.replace('/', '-');
testname = testname.replace('\\', '-');

// Example: "jdk-internal:test-containers-docker-TestMemoryAwareness"
return "jdk-internal:test-" + testname;

public static String imageName(String suffix) {
return imageNameAndTag + "-" + suffix;
// Example: "jdk-internal:test-containers-docker-TestMemoryAwareness-memory"
return imageName() + '-' + suffix;

public static void prepareWhiteBox() throws Exception {
Files.copy(Paths.get(new File("whitebox.jar").getAbsolutePath()),
Paths.get(Utils.TEST_CLASSES, "whitebox.jar"), StandardCopyOption.REPLACE_EXISTING);

// create simple commonly used options
public static DockerRunOptions newOpts(String imageNameAndTag) {
return new DockerRunOptions(imageNameAndTag, "/jdk/bin/java", "-version")
public static DockerRunOptions newOpts(String imageName) {
return new DockerRunOptions(imageName, "/jdk/bin/java", "-version")

public static DockerRunOptions newOptsShowSettings(String imageNameAndTag) {
return new DockerRunOptions(imageNameAndTag, "/jdk/bin/java", "-version", "-XshowSettings:system");
public static DockerRunOptions newOptsShowSettings(String imageName) {
return new DockerRunOptions(imageName, "/jdk/bin/java", "-version", "-XshowSettings:system");

// create commonly used options with class to be launched inside container
public static DockerRunOptions newOpts(String imageNameAndTag, String testClass) {
public static DockerRunOptions newOpts(String imageName, String testClass) {
DockerRunOptions opts =
new DockerRunOptions(imageNameAndTag, "/jdk/bin/java", testClass);
new DockerRunOptions(imageName, "/jdk/bin/java", testClass);
opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/");
opts.addJavaOpts("-Xlog:os+container=trace", "-cp", "/test-classes/");
return opts;

1 comment on commit 67ecd30

Copy link

@openjdk-notifier openjdk-notifier bot commented on 67ecd30 Jun 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.