You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by fp...@apache.org on 2014/07/14 19:45:38 UTC
svn commit: r1610468 - in /zookeeper/trunk: CHANGES.txt
src/java/test/org/apache/zookeeper/test/ReconfigTest.java
Author: fpj
Date: Mon Jul 14 17:45:38 2014
New Revision: 1610468
URL: http://svn.apache.org/r1610468
Log:
ZOOKEEPER-1964. Fix Flaky Test in ReconfigTest.java (Hongchao Deng via fpj)
Modified:
zookeeper/trunk/CHANGES.txt
zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ReconfigTest.java
Modified: zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/trunk/CHANGES.txt?rev=1610468&r1=1610467&r2=1610468&view=diff
==============================================================================
--- zookeeper/trunk/CHANGES.txt (original)
+++ zookeeper/trunk/CHANGES.txt Mon Jul 14 17:45:38 2014
@@ -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,
Modified: zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ReconfigTest.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ReconfigTest.java?rev=1610468&r1=1610467&r2=1610468&view=diff
==============================================================================
--- zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ReconfigTest.java (original)
+++ zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ReconfigTest.java Mon Jul 14 17:45:38 2014
@@ -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 ZKTest
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!",
- HostNameUtils.getHostString(qs.clientAddr) + ":"
- + qs.clientAddr.getPort(),
- JMXEnv.ensureBeanAttribute(beanName, "ClientAddress"));
+ getNumericalAddrPort(
+ HostNameUtils.getHostString(qs.clientAddr) + ":"
+ + qs.clientAddr.getPort() ),
+ getAddrPortFromBean(beanName, "ClientAddress") );
Assert.assertEquals("Mismatches ElectionAddress!",
- 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"));
+ getNumericalAddrPort(
+ HostNameUtils.getHostString(qs.electionAddr) + ":"
+ + qs.electionAddr.getPort() ),
+ getAddrPortFromBean(beanName, "ElectionAddress") );
+ Assert.assertEquals("Mismatches QuorumAddress!",
+ getNumericalAddrPort(
+ qs.addr.getHostName() + ":"
+ + qs.addr.getPort() ),
+ getAddrPortFromBean(beanName, "QuorumAddress") );
}
}