Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8287398: Allow concurrent execution of hotspot docker tests #8914

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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