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

[EagerAppCDS] Enhancement for support apps with fixed jmxremote port #614

Merged
merged 1 commit into from
Jan 4, 2024
Merged
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
63 changes: 63 additions & 0 deletions jdk/test/com/alibaba/quickstart/TestDumpWithFixedJMXPort.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* @test
* @modules java.base/sun.security.action
* @summary Test dumping using jcmd
* @library /lib
* @build TestDump
* @requires os.arch=="amd64" | os.arch=="aarch64"
* @run driver ClassFileInstaller -jar test-notifyDumpByJcmd.jar TestDump TestDump$Policy TestDump$ClassLoadingPolicy TestDump$WatcherThread
* @run main/othervm/timeout=600 TestDumpWithFixedJMXPort
*/

import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
import sun.security.action.GetPropertyAction;

import java.io.File;
import java.security.AccessController;

public class TestDumpWithFixedJMXPort {

private static final String TESTJAR = "./test-notifyDumpByJcmd.jar";
private static final String TESTCLASS = "TestDump";

public static void main(String[] args) throws Exception {
String dir = AccessController.doPrivileged(new GetPropertyAction("test.classes"));
destroyCache(dir);
TestDumpWithFixedJMXPort.verifyPathSetting(dir);
new File(dir).delete();
}

static void verifyPathSetting(String parentDir) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Xquickstart:path=" + parentDir + "/fixedJMXPortcache",
"-Xquickstart:verbose",
// In sleeping condition there is no classloading happens,
// we will consider it as the start-up finish
"-DcheckIntervalMS=" + TestDump.SLEEP_MILLIS,
"-DtestJcmd=true",
"-Dcom.sun.management.jmxremote.authenticate=false",
"-Dcom.sun.management.jmxremote.ssl=false",
"-Dcom.sun.management.jmxremote.port=8780",
"-Dcom.sun.management.jmxremote.rmi.port=8780",
"-cp",
TESTJAR,
TESTCLASS);
pb.redirectErrorStream(true);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
System.out.println("[Child Output] " + output.getOutput());
output.shouldContain(TestDump.ANCHOR);
output.shouldHaveExitValue(0);
}

static void destroyCache(String parentDir) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Xquickstart:destroy",
"-Xquickstart:path=" + parentDir + "/fixedJMXPortcache",
"-Xquickstart:verbose", "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("destroy the cache folder");
output.shouldHaveExitValue(0);
}

}
Loading