added test for attaching to running VM and add prometheus JMX agent;

this adds com.sun.jna[.platform] to the runtime
This commit is contained in:
Axel Uhl
2025-02-07 13:42:38 +01:00
parent 38d1e2a399
commit a562e4cd44
3 changed files with 58 additions and 1 deletions
@@ -24,5 +24,7 @@ Require-Bundle: org.mockito.mockito-core;bundle-version="4.8.1",
org.objenesis;bundle-version="2.1.0",
net.bytebuddy.byte-buddy;bundle-version="1.12.18",
net.bytebuddy.byte-buddy-agent;bundle-version="1.12.18",
com.sap.sailing.domain.test
com.sap.sailing.domain.test,
com.sun.jna;bundle-version="5.12.1",
com.sun.jna.platform;bundle-version="5.12.1"
Automatic-Module-Name: com.sap.sailing.datamining.test
@@ -0,0 +1,27 @@
package com.sap.sailing.datamining.test.util;
import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import org.junit.Ignore;
import org.junit.Test;
import net.bytebuddy.agent.VirtualMachine;
/**
* Requires com.sun.jna, com.sun.jna.platform bundles and the net.bytebuddy stuff to be on the classpath.
*
* @author Axel Uhl (d043530)
*
*/
@Ignore("This class is used only to demonstrate how injecting the JMX Prometheus Java agent works for a running VM")
public class TestAttachToVM {
@Test
public void testInjectAgentToRunningVM() throws IOException {
final VirtualMachine vm = VirtualMachine.ForHotSpot.attach("414179");
vm.loadAgent("/path/to/jmx_prometheus_javaagent-1.1.0.jar", "9000:/path/to/java/jmxPrometheusConfig.yaml");
assertNotNull(vm);
vm.detach();
}
}
@@ -1353,4 +1353,32 @@
install-size="0"
version="4.28.3"
unpack="false"/>
<plugin
id="com.sun.jna"
download-size="0"
install-size="0"
version="5.12.1.v20221103-2317"
unpack="false"/>
<plugin
id="com.sun.jna.source"
download-size="0"
install-size="0"
version="5.12.1.v20221103-2317"
unpack="false"/>
<plugin
id="com.sun.jna.platform"
download-size="0"
install-size="0"
version="5.12.1.v20221103-2317"
unpack="false"/>
<plugin
id="com.sun.jna.platform.source"
download-size="0"
install-size="0"
version="5.12.1.v20221103-2317"
unpack="false"/>
</feature>