Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Fix failure in IT test with external cluster #393

Merged
merged 4 commits into from
Mar 24, 2020
Merged
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.junit.Before;

import javax.management.MBeanServerInvocationHandler;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
Expand Down Expand Up @@ -107,23 +106,25 @@ public interface IProxy {
}

@AfterClass
public static void dumpCoverage() throws IOException, MalformedObjectNameException {
public static void dumpCoverage() {
// jacoco.dir is set in sqlplugin-coverage.gradle, if it doesn't exist we don't
// want to collect coverage so we can return early
String jacocoBuildPath = System.getProperty("jacoco.dir");
if (jacocoBuildPath.isEmpty()) {
if (jacocoBuildPath == null || jacocoBuildPath.isEmpty()) {
dai-chen marked this conversation as resolved.
Show resolved Hide resolved
return;
}

String serverUrl = "service:jmx:rmi:///jndi/rmi://127.0.0.1:7777/jmxrmi";
JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(serverUrl));
IProxy proxy = MBeanServerInvocationHandler.newProxyInstance(
connector.getMBeanServerConnection(), new ObjectName("org.jacoco:type=Runtime"), IProxy.class,
false);

Path path = Paths.get(jacocoBuildPath + "/integTest.exec");
Files.write(path, proxy.getExecutionData(false));
connector.close();
try(JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(serverUrl))) {
IProxy proxy = MBeanServerInvocationHandler.newProxyInstance(
connector.getMBeanServerConnection(), new ObjectName("org.jacoco:type=Runtime"), IProxy.class,
false);

Path path = Paths.get(jacocoBuildPath + "/integTest.exec");
Files.write(path, proxy.getExecutionData(false));
} catch (Exception ex) {
throw new RuntimeException("Failed to dump coverage: " + ex);
dai-chen marked this conversation as resolved.
Show resolved Hide resolved
}
}

/**
Expand Down