Commit b41f8af3 authored by Flavio Paiva Junqueira's avatar Flavio Paiva Junqueira
Browse files

ZOOKEEPER-1964. Fix Flaky Test in ReconfigTest.java (Hongchao Deng via fpj)



git-svn-id: https://svn.apache.org/repos/asf/zookeeper/trunk@1610468 13f79535-47bb-0310-9956-ffa450edef68
parent bf24a01b
......@@ -689,6 +689,8 @@ BUGFIXES:
ZOOKEEPER-1222. getACL should only call DataTree.copyStat when passed in
stat is not null (Michi Mutsuzaki via rakeshr)
ZOOKEEPER-1964. Fix Flaky Test in ReconfigTest.java (Hongchao Deng via fpj)
IMPROVEMENTS:
ZOOKEEPER-1170. Fix compiler (eclipse) warnings: unused imports,
......
......@@ -19,6 +19,8 @@
package org.apache.zookeeper.test;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
......@@ -956,20 +958,42 @@ public class ReconfigTest extends ZKTestCase implements DataCallback{
beanName, "QuorumSystemInfo"));
}
String getAddrPortFromBean(String beanName, String attribute) throws Exception {
String name = (String) JMXEnv.ensureBeanAttribute(
beanName, attribute);
if ( ! name.contains(":") ) {
return name;
}
return getNumericalAddrPort(name);
}
String getNumericalAddrPort(String name) throws UnknownHostException {
String port = name.split(":")[1];
String addr = name.split(":")[0];
addr = InetAddress.getByName(addr).getHostAddress();
return addr + ":" + port;
}
private void assertRemotePeerMXBeanAttributes(QuorumServer qs,
String beanName) throws Exception {
Assert.assertEquals("Mismatches LearnerType!", qs.type.name(),
JMXEnv.ensureBeanAttribute(beanName, "LearnerType"));
Assert.assertEquals("Mismatches ClientAddress!",
getNumericalAddrPort(
HostNameUtils.getHostString(qs.clientAddr) + ":"
+ qs.clientAddr.getPort(),
JMXEnv.ensureBeanAttribute(beanName, "ClientAddress"));
+ qs.clientAddr.getPort() ),
getAddrPortFromBean(beanName, "ClientAddress") );
Assert.assertEquals("Mismatches ElectionAddress!",
getNumericalAddrPort(
HostNameUtils.getHostString(qs.electionAddr) + ":"
+ qs.electionAddr.getPort(),
JMXEnv.ensureBeanAttribute(beanName, "ElectionAddress"));
Assert.assertEquals("Mismatches QuorumAddress!", qs.addr.getHostName()
+ ":" + qs.addr.getPort(),
JMXEnv.ensureBeanAttribute(beanName, "QuorumAddress"));
+ qs.electionAddr.getPort() ),
getAddrPortFromBean(beanName, "ElectionAddress") );
Assert.assertEquals("Mismatches QuorumAddress!",
getNumericalAddrPort(
qs.addr.getHostName() + ":"
+ qs.addr.getPort() ),
getAddrPortFromBean(beanName, "QuorumAddress") );
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment