HDFS-10318. TestJMXGet hides the real error in case of test failure. Contributed by Andras Bokor.
This commit is contained in:
parent
bec5b4cd8c
commit
10f0f7851a
|
@ -31,6 +31,7 @@ import java.io.PrintStream;
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import javax.management.MBeanServerConnection;
|
import javax.management.MBeanServerConnection;
|
||||||
import javax.management.ObjectName;
|
import javax.management.ObjectName;
|
||||||
|
@ -55,6 +56,7 @@ import org.junit.Test;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TestJMXGet {
|
public class TestJMXGet {
|
||||||
|
public static final String WRONG_METRIC_VALUE_ERROR_MSG = "Unable to get the correct value for %s.";
|
||||||
|
|
||||||
private Configuration config;
|
private Configuration config;
|
||||||
private MiniDFSCluster cluster;
|
private MiniDFSCluster cluster;
|
||||||
|
@ -106,9 +108,12 @@ public class TestJMXGet {
|
||||||
assertTrue("error printAllValues", checkPrintAllValues(jmx));
|
assertTrue("error printAllValues", checkPrintAllValues(jmx));
|
||||||
|
|
||||||
//get some data from different source
|
//get some data from different source
|
||||||
DFSTestUtil.waitForMetric(jmx, "NumLiveDataNodes", numDatanodes);
|
try {
|
||||||
assertEquals(numDatanodes, Integer.parseInt(
|
DFSTestUtil.waitForMetric(jmx, "NumLiveDataNodes", numDatanodes);
|
||||||
|
} catch (TimeoutException e) {
|
||||||
|
assertEquals(String.format(WRONG_METRIC_VALUE_ERROR_MSG, "NumLiveDataNodes"),numDatanodes, Integer.parseInt(
|
||||||
jmx.getValue("NumLiveDataNodes")));
|
jmx.getValue("NumLiveDataNodes")));
|
||||||
|
}
|
||||||
assertGauge("CorruptBlocks", Long.parseLong(jmx.getValue("CorruptBlocks")),
|
assertGauge("CorruptBlocks", Long.parseLong(jmx.getValue("CorruptBlocks")),
|
||||||
getMetrics("FSNamesystem"));
|
getMetrics("FSNamesystem"));
|
||||||
|
|
||||||
|
@ -158,8 +163,11 @@ public class TestJMXGet {
|
||||||
String serviceName = "DataNode";
|
String serviceName = "DataNode";
|
||||||
jmx.setService(serviceName);
|
jmx.setService(serviceName);
|
||||||
jmx.init();
|
jmx.init();
|
||||||
DFSTestUtil.waitForMetric(jmx, "BytesWritten", fileSize);
|
try {
|
||||||
assertEquals(fileSize, Integer.parseInt(jmx.getValue("BytesWritten")));
|
DFSTestUtil.waitForMetric(jmx, "BytesWritten", fileSize);
|
||||||
|
} catch (TimeoutException e) {
|
||||||
|
assertEquals(String.format(WRONG_METRIC_VALUE_ERROR_MSG, "BytesWritten"), fileSize, Integer.parseInt(jmx.getValue("BytesWritten")));
|
||||||
|
}
|
||||||
|
|
||||||
cluster.shutdown();
|
cluster.shutdown();
|
||||||
MBeanServerConnection mbsc = ManagementFactory.getPlatformMBeanServer();
|
MBeanServerConnection mbsc = ManagementFactory.getPlatformMBeanServer();
|
||||||
|
|
Loading…
Reference in New Issue