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

Save local connector address in Attach API code #2951

Merged
merged 1 commit into from
Sep 25, 2018

Conversation

mikezhang1234567890
Copy link
Contributor

@mikezhang1234567890 mikezhang1234567890 commented Sep 19, 2018

From #2742, VirtualMachine.getAgentProperties() doesn't get the local connector address if it isn't saved to our systems properties. Thus, we check VMSupport class for the local connector address and save it in system properties if it is not there already.

Fixes #2742

Signed-off-by: Mike Zhang mike.h.zhang@ibm.com

}
if (Objects.isNull(addr)) {
/* startLocalAgent() should have set the property. */
return Response.EXCEPTION_AGENT_INITIALIZATION_EXCEPTION + "loadAgentLibrary: " + LOCAL_CONNECTOR_ADDRESS + " not defined"; //$NON-NLS-1$ //$NON-NLS-2$
Copy link
Member

Choose a reason for hiding this comment

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

Needs a space after EXCEPTION_AGENT_INITIALIZATION_EXCEPTION

Copy link
Contributor

Choose a reason for hiding this comment

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

This code is the same as that in startLocalAgent(), correct? If so, please factor it out into a separate static method. While you are doing that, please add logging to record the agent address and any errors.

@mikezhang1234567890 mikezhang1234567890 force-pushed the attach branch 4 times, most recently from 73756d2 to 8d0dd3f Compare September 20, 2018 21:02
@mikezhang1234567890 mikezhang1234567890 changed the title WIP: Save LOCAL_CONNECTOR_ADDRESS on loadAgent() Save local connector address in Attach API code Sep 24, 2018
try {
saveLocalConnectorAddress();
} catch (IbmAttachOperationFailedException e) {
return Response.EXCEPTION_AGENT_INITIALIZATION_EXCEPTION + "loadAgentLibrary: " + e.getMessage();
Copy link
Member

Choose a reason for hiding this comment

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

Please add a space between EXCEPTION_AGENT_INITIALIZATION_EXCEPTION and "loadAgentLibrary: "

try {
return saveLocalConnectorAddress();
} catch (IbmAttachOperationFailedException e) {
throw new IbmAttachOperationFailedException("startLocalManagementAgent: " + e.getMessage());
Copy link
Member

@pshipton pshipton Sep 24, 2018

Choose a reason for hiding this comment

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

This should set the original exception as the cause of the IbmAttachOperationFailedException. Although see the next comment, I think saveLocalConnectorAddress() could just return null.

IPC.logMessage(LOCAL_CONNECTOR_ADDRESS + " not set"); //$NON-NLS-1$
throw new IbmAttachOperationFailedException("startLocalManagementAgent: " + LOCAL_CONNECTOR_ADDRESS + " not defined"); //$NON-NLS-1$ //$NON-NLS-2$
throw new IbmAttachOperationFailedException(LOCAL_CONNECTOR_ADDRESS + " not defined"); //$NON-NLS-1$
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to throw an exception? Seems it could just return null.

@mikezhang1234567890 mikezhang1234567890 force-pushed the attach branch 2 times, most recently from e97b67a to ceb58cb Compare September 24, 2018 22:47
@pshipton
Copy link
Member

jenkins test all zlinux jdk8

@pshipton
Copy link
Member

pshipton commented Sep 25, 2018

At least one failure in extended testing

TestAttachAPI_SE80_0

===============================================
Running test TestAttachAPI_SE80_0 ...
===============================================
TestAttachAPI_SE80_0 Start Time: Mon Sep 24 20:45:01 2018 Epoch Time (ms): 1537836301340
test with NoOptions
[IncludeExcludeTestAnnotationTransformer] [INFO] exclude file is /home/jenkins/jenkins-agent/workspace/PullRequest-Extended-JDK8-linux_390-64_cmprssptrs-OpenJ9/openj9/test/TestConfig/../../jvmtest/TestConfig/resources/excludes/latest_exclude_8.txt
...
... TestNG 6.14.2 by Cédric Beust (cedric@beust.com)
...

[AttachApiTest] [ERROR] com.sun.tools.attach.AgentInitializationException: ATTACH_ERR AgentInitializationException loadAgentLibrary: com.sun.management.jmxremote.localConnectorAddress not defined
	at com.ibm.tools.attach.attacher.OpenJ9VirtualMachine.parseResponse(OpenJ9VirtualMachine.java:321)
	at com.ibm.tools.attach.attacher.OpenJ9VirtualMachine.loadAgentLibrary(OpenJ9VirtualMachine.java:244)
	at com.sun.tools.attach.VirtualMachine.loadAgentLibrary(VirtualMachine.java:378)
	at org.openj9.test.attachAPI.TestAttachAPI.test_agntld01(TestAttachAPI.java:132)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
	at org.testng.internal.Invoker.invokeMethod(Invoker.java:580)
	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:716)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:988)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
	at org.testng.TestRunner.privateRun(TestRunner.java:648)
	at org.testng.TestRunner.run(TestRunner.java:505)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
	at org.testng.SuiteRunner.run(SuiteRunner.java:364)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
	at org.testng.TestNG.runSuites(TestNG.java:1049)
	at org.testng.TestNG.run(TestNG.java:1017)
	at org.testng.TestNG.privateMain(TestNG.java:1354)
	at org.testng.TestNG.main(TestNG.java:1323)

[AttachApiTest] [ERROR] AgentInitializationException ignored

... passing tests ...

20:46:02 FAILED: test_agntld01
20:46:02 java.lang.AssertionError: com.sun.tools.attach.AgentInitializationException: ATTACH_ERR AgentInitializationException loadAgentLibrary: com.sun.management.jmxremote.localConnectorAddress not defined
20:46:02 	at org.testng.Assert.fail(Assert.java:96)
20:46:02 	at org.openj9.test.attachAPI.AttachApiTest.logExceptionInfoAndFail(AttachApiTest.java:46)
20:46:02 	at org.openj9.test.attachAPI.TestAttachAPI.test_agntld01(TestAttachAPI.java:135)
20:46:02 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
20:46:02 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
20:46:02 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
20:46:02 	at java.lang.reflect.Method.invoke(Method.java:498)
20:46:02 	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
20:46:02 	at org.testng.internal.Invoker.invokeMethod(Invoker.java:580)
20:46:02 	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:716)
20:46:02 	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:988)
20:46:02 	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
20:46:02 	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
20:46:02 	at org.testng.TestRunner.privateRun(TestRunner.java:648)
20:46:02 	at org.testng.TestRunner.run(TestRunner.java:505)
20:46:02 	at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
20:46:02 	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
20:46:02 	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
20:46:02 	at org.testng.SuiteRunner.run(SuiteRunner.java:364)
20:46:02 	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
20:46:02 	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
20:46:02 	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
20:46:02 	at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
20:46:02 	at org.testng.TestNG.runSuites(TestNG.java:1049)
20:46:02 	at org.testng.TestNG.run(TestNG.java:1017)
20:46:02 	at org.testng.TestNG.privateMain(TestNG.java:1354)
20:46:02 	at org.testng.TestNG.main(TestNG.java:1323)

VirtualMachine.getAgentProperties() doesn't get the local connector
address if it isn't saved to our systems properties. Thus, we check
VMSupport class for the local connector address and save it in system
properties if it is not there already.

Signed-off-by: Mike Zhang <mike.h.zhang@ibm.com>
@mikezhang1234567890
Copy link
Contributor Author

Removed the save local connector code in loadAgentLibrary since we don't always load an agent with the local connector address property. Running getAgentProperties will find the address anyways. This should fix the exception in the extended test.

@pshipton
Copy link
Member

jenkins test extended zlinux jdk8

@pshipton pshipton merged commit cf45f6e into eclipse-openj9:master Sep 25, 2018
@mikezhang1234567890 mikezhang1234567890 deleted the attach branch October 1, 2018 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants