Skip to content

Commit

Permalink
8287398: Allow concurrent execution of hotspot docker tests
Browse files Browse the repository at this point in the history
Reviewed-by: shade, mseledtsov, sgehwolf
  • Loading branch information
iklam committed Jun 1, 2022
1 parent 8071b23 commit 67ecd30
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 33 deletions.
24 changes: 0 additions & 24 deletions test/hotspot/jtreg/containers/docker/TEST.properties

This file was deleted.

43 changes: 34 additions & 9 deletions test/lib/jdk/test/lib/containers/docker/Common.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 test.name 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/TestCase.java
// test/bar/TEST.ROOT
// test/bar/my/TestCase.java
// $ 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 test.name is "my/TestCase.java"
String testname = System.getProperty("test.name");
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")
.addJavaOpts("-Xlog:os+container=trace");
}

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;
Expand Down

1 comment on commit 67ecd30

@openjdk-notifier
Copy link

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.