Author: michim Date: Tue Mar 11 01:44:30 2014 New Revision: 1576174 URL: http://svn.apache.org/r1576174 Log: ZOOKEEPER-1662. Fix to two small bugs in ReconfigTest.testPortChange() (Alexander Shraer via michim)
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=1576174&r1=1576173&r2=1576174&view=diff ============================================================================== --- zookeeper/trunk/CHANGES.txt (original) +++ zookeeper/trunk/CHANGES.txt Tue Mar 11 01:44:30 2014 @@ -567,6 +567,9 @@ BUGFIXES: ZOOKEEPER-1888. ZkCli.cmd commands fail with "'java' is not recognized as an internal or external command" (Ivan Mitic via michim) + ZOOKEEPER-1662. Fix to two small bugs in ReconfigTest.testPortChange() + (Alexander Shraer via michim) + 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=1576174&r1=1576173&r2=1576174&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 Tue Mar 11 01:44:30 2014 @@ -539,25 +539,37 @@ public class ReconfigTest extends ZKTest joiningServers.add("server." + observerIndex + "=localhost:" + port1 + ":" + port2 + ":observer;localhost:" + port3); + // create a /test znode and check that read/write works before + // any reconfig is invoked + testNormalOperation(zkArr[observerIndex], zkArr[followerIndex]); + reconfig(zkArr[followerIndex], joiningServers, null, null, -1); - try { - zkArr[observerIndex].create("/test", "asdfg".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); - Assert.fail("client port didn't change"); + // the change of port may not be immediate -- we repeatedly + // invoke an operation expecting it to eventually fail once + // the client port of observerIndex changes. If it didn't + // change -- that's an error. + try { + for (int i=0; i < 30; i++) { + Thread.sleep(1000); + zkArr[observerIndex].setData("/test", "teststr".getBytes(), -1); + } + Assert.fail("client port didn't change"); } catch (KeeperException.ConnectionLossException e) { zkArr[observerIndex] = new ZooKeeper("127.0.0.1:" + qu.getPeer(observerIndex).peer.getClientPort(), - ClientBase.CONNECTION_TIMEOUT, null); + ClientBase.CONNECTION_TIMEOUT, new Watcher() { + public void process(WatchedEvent event) {}}); } - + leaderIndex = getLeaderId(qu); followerIndex = 1; while (followerIndex == leaderIndex || followerIndex == observerIndex) followerIndex++; - + testNormalOperation(zkArr[observerIndex], zkArr[followerIndex]); - + testServerHasConfig(zkArr[observerIndex], joiningServers, null); Assert.assertTrue(qu.getPeer(observerIndex).peer.getQuorumAddress()