zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an...@apache.org
Subject [06/51] [partial] zookeeper git commit: ZOOKEEPER-3032: MAVEN MIGRATION - branch-3.5 - move java server, client
Date Fri, 05 Oct 2018 13:36:34 GMT
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/quorum/ReconfigFailureCasesTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/quorum/ReconfigFailureCasesTest.java b/src/java/test/org/apache/zookeeper/server/quorum/ReconfigFailureCasesTest.java
deleted file mode 100644
index 8120d0f..0000000
--- a/src/java/test/org/apache/zookeeper/server/quorum/ReconfigFailureCasesTest.java
+++ /dev/null
@@ -1,286 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zookeeper.server.quorum;
-
-import static org.apache.zookeeper.test.ClientBase.CONNECTION_TIMEOUT;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.KeeperException.NewConfigNoQuorum;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.admin.ZooKeeperAdmin;
-import org.apache.zookeeper.data.Stat;
-import org.apache.zookeeper.test.ClientBase;
-import org.apache.zookeeper.test.QuorumUtil;
-import org.apache.zookeeper.test.ReconfigTest;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ReconfigFailureCasesTest extends QuorumPeerTestBase {
-
-    private QuorumUtil qu;
-
-    @Before
-    public void setup() {
-        QuorumPeerConfig.setReconfigEnabled(true);
-        System.setProperty("zookeeper.DigestAuthenticationProvider.superDigest",
-                "super:D/InIHSb7yEEbrWz8b9l71RjZJU="/* password is 'test'*/);
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        if (qu != null) {
-            qu.tearDown();
-        }
-    }
-
-    /*
-     * Tests that an incremental reconfig fails if the current config is hiearchical.
-     */
-    @Test
-    public void testIncrementalReconfigInvokedOnHiearchicalQS() throws Exception {
-        qu = new QuorumUtil(2); // create 5 servers
-        qu.disableJMXTest = true;
-        qu.startAll();
-        ZooKeeper[] zkArr = ReconfigTest.createHandles(qu);
-        ZooKeeperAdmin[] zkAdminArr = ReconfigTest.createAdminHandles(qu);
-
-        ArrayList<String> members = new ArrayList<String>();
-        members.add("group.1=3:4:5");
-        members.add("group.2=1:2");
-        members.add("weight.1=0");
-        members.add("weight.2=0");
-        members.add("weight.3=1");
-        members.add("weight.4=1");
-        members.add("weight.5=1");
-
-        for (int i = 1; i <= 5; i++) {
-            members.add("server." + i + "=127.0.0.1:"
-                    + qu.getPeer(i).peer.getQuorumAddress().getPort() + ":"
-                    + qu.getPeer(i).peer.getElectionAddress().getPort() + ";"
-                    + "127.0.0.1:" + qu.getPeer(i).peer.getClientPort());
-        }
-
-        // Change the quorum system from majority to hierarchical.
-        ReconfigTest.reconfig(zkAdminArr[1], null, null, members, -1);
-        ReconfigTest.testNormalOperation(zkArr[1], zkArr[2]);
-
-        // Attempt an incremental reconfig.
-        List<String> leavingServers = new ArrayList<String>();
-        leavingServers.add("3");
-        try {
-             zkAdminArr[1].reconfigure(null, leavingServers, null, -1, null);
-            Assert.fail("Reconfig should have failed since the current config isn't Majority QS");
-        } catch (KeeperException.BadArgumentsException e) {
-            // We expect this to happen.
-        } catch (Exception e) {
-            Assert.fail("Should have been BadArgumentsException!");
-        }
-
-        ReconfigTest.closeAllHandles(zkArr, zkAdminArr);
-    }
-
-    /*
-     * Test that a reconfiguration fails if the proposed change would leave the
-     * cluster with less than 2 participants (StandaloneEnabled = true).
-     * StandaloneDisabledTest.java (startSingleServerTest) checks that if
-     * StandaloneEnabled = false its legal to remove all but one remaining
-     * server.
-     */
-    @Test
-    public void testTooFewRemainingPariticipants() throws Exception {
-        qu = new QuorumUtil(1); // create 3 servers
-        qu.disableJMXTest = true;
-        qu.startAll();
-        ZooKeeper[] zkArr = ReconfigTest.createHandles(qu);
-        ZooKeeperAdmin[] zkAdminArr = ReconfigTest.createAdminHandles(qu);
-
-        List<String> leavingServers = new ArrayList<String>();
-        leavingServers.add("2");
-        leavingServers.add("3");
-        try {
-             zkAdminArr[1].reconfigure(null, leavingServers, null, -1, null);
-            Assert.fail("Reconfig should have failed since the current config version is not 8");
-        } catch (KeeperException.BadArgumentsException e) {
-            // We expect this to happen.
-        } catch (Exception e) {
-            Assert.fail("Should have been BadArgumentsException!");
-        }
-
-        ReconfigTest.closeAllHandles(zkArr, zkAdminArr);
-    }
-
-    /*
-     * Tests that a conditional reconfig fails if the specified version doesn't correspond
-     * to the version of the current config.
-     */
-    @Test
-    public void testReconfigVersionConditionFails() throws Exception {
-        qu = new QuorumUtil(1); // create 3 servers
-        qu.disableJMXTest = true;
-        qu.startAll();
-        ZooKeeper[] zkArr = ReconfigTest.createHandles(qu);
-        ZooKeeperAdmin[] zkAdminArr = ReconfigTest.createAdminHandles(qu);
-
-        List<String> leavingServers = new ArrayList<String>();
-        leavingServers.add("3");
-        try {
-             zkAdminArr[1].reconfigure(null, leavingServers, null, 8, null);
-            Assert.fail("Reconfig should have failed since the current config version is not 8");
-        } catch (KeeperException.BadVersionException e) {
-            // We expect this to happen.
-        } catch (Exception e) {
-            Assert.fail("Should have been BadVersionException!");
-        }
-
-        ReconfigTest.closeAllHandles(zkArr, zkAdminArr);
-    }
-
-    /*
-     * Tests that if a quorum of a new config is synced with the leader and a reconfig
-     * is allowed to start but then the new quorum is lost, the leader will time out and
-     * we go to leader election.
-     */
-    @Test
-    public void testLeaderTimesoutOnNewQuorum() throws Exception {
-        qu = new QuorumUtil(1); // create 3 servers
-        qu.disableJMXTest = true;
-        qu.startAll();
-        ZooKeeper[] zkArr = ReconfigTest.createHandles(qu);
-        ZooKeeperAdmin[] zkAdminArr = ReconfigTest.createAdminHandles(qu);
-
-        List<String> leavingServers = new ArrayList<String>();
-        leavingServers.add("3");
-        qu.shutdown(2);
-        try {
-            // Since we just shut down server 2, its still considered "synced"
-            // by the leader, which allows us to start the reconfig
-            // (PrepRequestProcessor checks that a quorum of the new
-            // config is synced before starting a reconfig).
-            // We try to remove server 3, which requires a quorum of {1,2,3}
-            // (we have that) and of {1,2}, but 2 is down so we won't get a
-            // quorum of new config ACKs.
-            zkAdminArr[1].reconfigure(null, leavingServers, null, -1, null);
-            Assert.fail("Reconfig should have failed since we don't have quorum of new config");
-        } catch (KeeperException.ConnectionLossException e) {
-            // We expect leader to lose quorum of proposed config and time out
-        } catch (Exception e) {
-            Assert.fail("Should have been ConnectionLossException!");
-        }
-
-        // The leader should time out and remaining servers should go into
-        // LOOKING state. A new leader won't be established since that
-        // would require completing the reconfig, which is not possible while
-        // 2 is down.
-        Assert.assertEquals(QuorumStats.Provider.LOOKING_STATE,
-                qu.getPeer(1).peer.getServerState());
-        Assert.assertEquals(QuorumStats.Provider.LOOKING_STATE,
-                qu.getPeer(3).peer.getServerState());
-        ReconfigTest.closeAllHandles(zkArr, zkAdminArr);
-    }
-
-    /*
-     * Converting an observer into a participant may sometimes fail with a
-     * NewConfigNoQuorum exception. This test-case demonstrates the scenario.
-     * Current configuration is (A, B, C, D), where A, B and C are participant
-     * and D is an observer. Suppose that B has crashed (or never booted). If a
-     * reconfiguration is submitted where D is said to become a participant, it
-     * will fail with NewConfigNoQuorum since in this configuration, a majority
-     * of voters in the new configuration (any 3 voters), must be connected and
-     * up-to-date with the leader. An observer cannot acknowledge the history
-     * prefix sent during reconfiguration, and therefore it does not count towards
-     * these 3 required servers and the reconfiguration will be aborted. In case
-     * this happens, a client can achieve the same task by two reconfig commands:
-     * first invoke a reconfig to remove D from the configuration and then invoke a
-     * second command to add it back as a participant (follower). During the
-     * intermediate state D is a non-voting follower and can ACK the state
-     * transfer performed during the second reconfig command.
-     */
-    @Test
-    public void testObserverToParticipantConversionFails() throws Exception {
-        ClientBase.setupTestEnv();
-
-        final int SERVER_COUNT = 4;
-        int[][] ports = ReconfigRecoveryTest.generatePorts(SERVER_COUNT);
-
-        // generate old config string
-        HashSet<Integer> observers = new HashSet<Integer>();
-        observers.add(3);
-        StringBuilder sb = ReconfigRecoveryTest.generateConfig(SERVER_COUNT, ports, observers);
-        String currentQuorumCfgSection = sb.toString();
-        String nextQuorumCfgSection = currentQuorumCfgSection.replace("observer", "participant");
-
-        MainThread mt[] = new MainThread[SERVER_COUNT];
-        ZooKeeper zk[] = new ZooKeeper[SERVER_COUNT];
-        ZooKeeperAdmin zkAdmin[] = new ZooKeeperAdmin[SERVER_COUNT];
-
-        // Server 0 stays down
-        for (int i = 1; i < SERVER_COUNT; i++) {
-            mt[i] = new MainThread(i, ports[i][2], currentQuorumCfgSection,
-                    true, "100000000");
-            mt[i].start();
-            zk[i] = new ZooKeeper("127.0.0.1:" + ports[i][2],
-                    ClientBase.CONNECTION_TIMEOUT, this);
-            zkAdmin[i] = new ZooKeeperAdmin("127.0.0.1:" + ports[i][2],
-                    ClientBase.CONNECTION_TIMEOUT, this);
-            zkAdmin[i].addAuthInfo("digest", "super:test".getBytes());
-        }
-
-        for (int i = 1; i < SERVER_COUNT; i++) {
-            Assert.assertTrue("waiting for server " + i + " being up",
-                    ClientBase.waitForServerUp("127.0.0.1:" + ports[i][2],
-                            CONNECTION_TIMEOUT * 2));
-        }
-
-        try {
-            zkAdmin[1].reconfigure("", "", nextQuorumCfgSection, -1, new Stat());
-            Assert.fail("Reconfig should have failed with NewConfigNoQuorum");
-        } catch (NewConfigNoQuorum e) {
-            // This is expected case since server 0 is down and 3 can't vote
-            // (observer in current role) and we need 3 votes from 0, 1, 2, 3,
-        } catch (Exception e) {
-            Assert.fail("Reconfig should have failed with NewConfigNoQuorum");
-        }
-        // In this scenario to change 3's role to participant we need to remove it first
-        ArrayList<String> leavingServers = new ArrayList<String>();
-        leavingServers.add("3");
-        ReconfigTest.reconfig(zkAdmin[1], null, leavingServers, null, -1);
-        ReconfigTest.testNormalOperation(zk[2], zk[3]);
-        ReconfigTest.testServerHasConfig(zk[3], null, leavingServers);
-
-        // Now we're adding it back as a participant and everything should work.
-        List<String> newMembers = Arrays.asList(nextQuorumCfgSection.split("\n"));
-        ReconfigTest.reconfig(zkAdmin[1], null, null, newMembers, -1);
-        ReconfigTest.testNormalOperation(zk[2], zk[3]);
-        for (int i = 1; i < SERVER_COUNT; i++) {
-            ReconfigTest.testServerHasConfig(zk[i], newMembers, null);
-        }
-        for (int i = 1; i < SERVER_COUNT; i++) {
-            zk[i].close();
-            zkAdmin[i].close();
-            mt[i].shutdown();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/quorum/ReconfigLegacyTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/quorum/ReconfigLegacyTest.java b/src/java/test/org/apache/zookeeper/server/quorum/ReconfigLegacyTest.java
deleted file mode 100644
index 80a8bfe..0000000
--- a/src/java/test/org/apache/zookeeper/server/quorum/ReconfigLegacyTest.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zookeeper.server.quorum;
-
-import static org.apache.zookeeper.test.ClientBase.CONNECTION_TIMEOUT;
-import static org.junit.Assert.assertEquals;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Properties;
-
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.PortAssignment;
-import org.apache.zookeeper.ZooDefs.Ids;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.admin.ZooKeeperAdmin;
-import org.apache.zookeeper.test.ClientBase;
-import org.apache.zookeeper.test.ReconfigTest;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ReconfigLegacyTest extends QuorumPeerTestBase {
-
-    private static final int SERVER_COUNT = 3;
-
-    @Before
-    public void setup() {
-        ClientBase.setupTestEnv();
-        QuorumPeerConfig.setReconfigEnabled(true);
-        System.setProperty("zookeeper.DigestAuthenticationProvider.superDigest",
-                "super:D/InIHSb7yEEbrWz8b9l71RjZJU="/* password is 'test'*/);
-    }
-
-    /**
-     * This test checks that when started with a single static config file the
-     * servers will create a valid dynamic config file. Also checks that when
-     * the static config includes a clientPort but the dynamic definition also
-     * includes it, the static definition is erased.
-     */
-    @Test
-    public void testConfigFileBackwardCompatibility() throws Exception {
-        final int clientPorts[] = new int[SERVER_COUNT];
-        StringBuilder sb = new StringBuilder();
-        String server;
-        ArrayList<String> allServers = new ArrayList<String>();
-
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            clientPorts[i] = PortAssignment.unique();
-            server = "server." + i + "=localhost:" + PortAssignment.unique()
-                    + ":" + PortAssignment.unique() + ":participant;localhost:"
-                    + clientPorts[i];
-            allServers.add(server);
-            sb.append(server + "\n");
-        }
-        String currentQuorumCfgSection = sb.toString();
-
-        MainThread mt[] = new MainThread[SERVER_COUNT];
-        ZooKeeper zk[] = new ZooKeeper[SERVER_COUNT];
-
-        // Start the servers with a static config file, without a dynamic
-        // config file.
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            mt[i] = new MainThread(i, clientPorts[i], currentQuorumCfgSection, false);
-            // check that a dynamic configuration file doesn't exist
-            Assert.assertEquals( mt[i].getDynamicFiles().length, 0 );
-            mt[i].start();
-        }
-        // Check that the servers are up, have the right config and can process operations.
-        // Check that the static config was split into static and dynamic files correctly.
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            Assert.assertTrue("waiting for server " + i + " being up",
-                    ClientBase.waitForServerUp("127.0.0.1:" + clientPorts[i],
-                            CONNECTION_TIMEOUT));
-            zk[i] = ClientBase.createZKClient("127.0.0.1:" + clientPorts[i]);
-            File[] dynamicFiles = mt[i].getDynamicFiles();
-
-            Assert.assertTrue( dynamicFiles.length== 1 );
-            ReconfigTest.testServerHasConfig(zk[i], allServers, null);
-            // check that static config file doesn't include membership info
-            // and has a pointer to the dynamic configuration file
-            Properties cfg = readPropertiesFromFile(mt[i].confFile);
-            for (int j = 0; j < SERVER_COUNT; j++) {
-                Assert.assertFalse(cfg.containsKey("server." + j));
-            }
-            Assert.assertTrue(cfg.containsKey("dynamicConfigFile"));
-            Assert.assertFalse(cfg.containsKey("clientPort"));
-
-            // check that the dynamic configuration file contains the membership info
-            cfg = readPropertiesFromFile(dynamicFiles[0]);
-            for (int j = 0; j < SERVER_COUNT; j++) {
-                String serverLine = cfg.getProperty("server." + j, "");
-                Assert.assertEquals(allServers.get(j), "server." + j + "="
-                        + serverLine);
-            }
-            Assert.assertFalse(cfg.containsKey("dynamicConfigFile"));
-        }
-        ReconfigTest.testNormalOperation(zk[0], zk[1]);
-
-        // now shut down the servers and restart them
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            zk[i].close();
-            mt[i].shutdown();
-        }
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            mt[i].start();
-        }
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            Assert.assertTrue("waiting for server " + i + " being up",
-                    ClientBase.waitForServerUp("127.0.0.1:" + clientPorts[i],
-                            CONNECTION_TIMEOUT));
-            zk[i] = ClientBase.createZKClient("127.0.0.1:" + clientPorts[i]);
-            ReconfigTest.testServerHasConfig(zk[i], allServers, null);
-        }
-        ReconfigTest.testNormalOperation(zk[0], zk[1]);
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            mt[i].shutdown();
-            zk[i].close();
-        }
-    }
-
-    /**
-     * {@link https://issues.apache.org/jira/browse/ZOOKEEPER-1992}
-     * 1. When a server starts from old style static config, without a client port in the server
-     *    specification, it should keep the client port in static config file.
-     * 2. After port reconfig, the old port should be removed from static file
-     *    and new port added to dynamic file.
-     * @throws Exception
-     */
-    @Test
-    public void testReconfigRemoveClientFromStatic() throws Exception {
-        final int clientPorts[] = new int[SERVER_COUNT];
-        final int quorumPorts[] = new int[SERVER_COUNT];
-        final int electionPorts[] = new int[SERVER_COUNT];
-
-        final int changedServerId = 0;
-        final int newClientPort = PortAssignment.unique();
-
-        StringBuilder sb = new StringBuilder();
-        ArrayList<String> allServers = new ArrayList<String>();
-        ArrayList<String> newServers = new ArrayList<String>();
-
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            clientPorts[i] = PortAssignment.unique();
-            quorumPorts[i] = PortAssignment.unique();
-            electionPorts[i] = PortAssignment.unique();
-
-            String server = "server." + i + "=localhost:" + quorumPorts[i]
-                    +":" + electionPorts[i] + ":participant";
-            allServers.add(server);
-            sb.append(server + "\n");
-
-            if(i == changedServerId) {
-                newServers.add(server + ";0.0.0.0:" + newClientPort);
-            } else {
-                newServers.add(server);
-            }
-        }
-        String quorumCfgSection = sb.toString();
-
-        MainThread mt[] = new MainThread[SERVER_COUNT];
-        ZooKeeper zk[] = new ZooKeeper[SERVER_COUNT];
-        ZooKeeperAdmin zkAdmin[] = new ZooKeeperAdmin[SERVER_COUNT];
-
-        // Start the servers with a static config file, without a dynamic config file.
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            mt[i] = new MainThread(i, clientPorts[i], quorumCfgSection, false);
-            mt[i].start();
-        }
-
-        // Check that when a server starts from old style config, it should keep the client
-        // port in static config file.
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            Assert.assertTrue("waiting for server " + i + " being up",
-                    ClientBase.waitForServerUp("127.0.0.1:" + clientPorts[i],
-                            CONNECTION_TIMEOUT));
-            zk[i] = ClientBase.createZKClient("127.0.0.1:" + clientPorts[i]);
-            zkAdmin[i] = new ZooKeeperAdmin("127.0.0.1:" + clientPorts[i],
-                    ClientBase.CONNECTION_TIMEOUT, this);
-            zkAdmin[i].addAuthInfo("digest", "super:test".getBytes());
-
-            ReconfigTest.testServerHasConfig(zk[i], allServers, null);
-            Properties cfg = readPropertiesFromFile(mt[i].confFile);
-
-            Assert.assertTrue(cfg.containsKey("dynamicConfigFile"));
-            Assert.assertTrue(cfg.containsKey("clientPort"));
-        }
-        ReconfigTest.testNormalOperation(zk[0], zk[1]);
-
-        ReconfigTest.reconfig(zkAdmin[1], null, null, newServers, -1);
-        ReconfigTest.testNormalOperation(zk[0], zk[1]);
-
-        // Sleep since writing the config files may take time.
-        Thread.sleep(1000);
-
-        // Check that new dynamic config includes the updated client port.
-        // Check that server changedServerId erased clientPort from static config.
-        // Check that other servers still have clientPort in static config.
-
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            ReconfigTest.testServerHasConfig(zk[i], newServers, null);
-            Properties staticCfg = readPropertiesFromFile(mt[i].confFile);
-            if (i == changedServerId) {
-                Assert.assertFalse(staticCfg.containsKey("clientPort"));
-            } else {
-                Assert.assertTrue(staticCfg.containsKey("clientPort"));
-            }
-        }
-
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            mt[i].shutdown();
-            zk[i].close();
-            zkAdmin[i].close();
-        }
-    }
-
-    public static Properties readPropertiesFromFile(File file) throws IOException {
-        Properties cfg = new Properties();
-        FileInputStream in = new FileInputStream(file);
-        try {
-            cfg.load(in);
-        } finally {
-            in.close();
-        }
-        return cfg;
-    }
-
-    /**
-     * Test case for https://issues.apache.org/jira/browse/ZOOKEEPER-2244
-     *
-     * @throws Exception
-     */
-    @Test(timeout = 120000)
-    public void testRestartZooKeeperServer() throws Exception {
-        final int clientPorts[] = new int[SERVER_COUNT];
-        StringBuilder sb = new StringBuilder();
-        String server;
-
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            clientPorts[i] = PortAssignment.unique();
-            server = "server." + i + "=127.0.0.1:" + PortAssignment.unique()
-                    + ":" + PortAssignment.unique() + ":participant;127.0.0.1:"
-                    + clientPorts[i];
-            sb.append(server + "\n");
-        }
-        String currentQuorumCfgSection = sb.toString();
-        MainThread mt[] = new MainThread[SERVER_COUNT];
-
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            mt[i] = new MainThread(i, clientPorts[i], currentQuorumCfgSection,
-                    false);
-            mt[i].start();
-        }
-
-        // ensure server started
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            Assert.assertTrue("waiting for server " + i + " being up",
-                    ClientBase.waitForServerUp("127.0.0.1:" + clientPorts[i],
-                            CONNECTION_TIMEOUT));
-        }
-
-        ZooKeeper zk = ClientBase.createZKClient("127.0.0.1:" + clientPorts[0]);
-
-        String zNodePath="/serverRestartTest";
-        String data = "originalData";
-        zk.create(zNodePath, data.getBytes(), Ids.OPEN_ACL_UNSAFE,
-                CreateMode.PERSISTENT);
-        zk.close();
-
-        /**
-         * stop two servers out of three and again start them
-         */
-        mt[0].shutdown();
-        mt[1].shutdown();
-        mt[0].start();
-        mt[1].start();
-        // ensure server started
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            Assert.assertTrue("waiting for server " + i + " being up",
-                    ClientBase.waitForServerUp("127.0.0.1:" + clientPorts[i],
-                            CONNECTION_TIMEOUT));
-        }
-        zk = ClientBase.createZKClient("127.0.0.1:" + clientPorts[0]);
-
-        byte[] dataBytes = zk.getData(zNodePath, null, null);
-        String receivedData = new String(dataBytes);
-        assertEquals(data, receivedData);
-
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            mt[i].shutdown();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/quorum/ReconfigRecoveryTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/quorum/ReconfigRecoveryTest.java b/src/java/test/org/apache/zookeeper/server/quorum/ReconfigRecoveryTest.java
deleted file mode 100644
index 4de9b97..0000000
--- a/src/java/test/org/apache/zookeeper/server/quorum/ReconfigRecoveryTest.java
+++ /dev/null
@@ -1,584 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zookeeper.server.quorum;
-
-import static org.apache.zookeeper.test.ClientBase.CONNECTION_TIMEOUT;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-
-import org.apache.zookeeper.PortAssignment;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.test.ClientBase;
-import org.apache.zookeeper.test.ReconfigTest;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ReconfigRecoveryTest extends QuorumPeerTestBase {
-    @Before
-    public void setup() {
-        QuorumPeerConfig.setReconfigEnabled(true);
-    }
-
-    /**
-     * Reconfiguration recovery - test that a reconfiguration is completed if
-     * leader has .next file during startup and new config is not running yet
-     */
-    @Test
-    public void testNextConfigCompletion() throws Exception {
-        ClientBase.setupTestEnv();
-
-        // 2 servers in current config, 3 in next config
-        final int SERVER_COUNT = 3;
-        final int clientPorts[] = new int[SERVER_COUNT];
-        StringBuilder sb = new StringBuilder();
-        String server;
-        ArrayList<String> allServers = new ArrayList<String>();
-
-        String currentQuorumCfgSection = null, nextQuorumCfgSection;
-
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            clientPorts[i] = PortAssignment.unique();
-            server = "server." + i + "=localhost:" + PortAssignment.unique()
-                    + ":" + PortAssignment.unique() + ":participant;localhost:"
-                    + clientPorts[i];
-            allServers.add(server);
-            sb.append(server + "\n");
-            if (i == 1)
-                currentQuorumCfgSection = sb.toString();
-        }
-        nextQuorumCfgSection = sb.toString();
-
-        // Both servers 0 and 1 will have the .next config file, which means
-        // for them that a reconfiguration was in progress when they failed
-        // and the leader will complete it
-        MainThread mt[] = new MainThread[SERVER_COUNT];
-        ZooKeeper zk[] = new ZooKeeper[SERVER_COUNT];
-        for (int i = 0; i < SERVER_COUNT - 1; i++) {
-            mt[i] = new MainThread(i, clientPorts[i], currentQuorumCfgSection,
-                    true, "100000000");
-            // note that we should run the server, shut it down and only then
-            // simulate a reconfig in progress by writing the temp file, but here no
-            // other server is competing with them in FLE, so we can skip this step
-            // (server 2 is booted after FLE ends)
-            mt[i].writeTempDynamicConfigFile(nextQuorumCfgSection, "200000000");
-            mt[i].start();
-            zk[i] = new ZooKeeper("127.0.0.1:" + clientPorts[i],
-                    ClientBase.CONNECTION_TIMEOUT, this);
-        }
-
-        Assert.assertTrue("waiting for server 0 being up", ClientBase
-                .waitForServerUp("127.0.0.1:" + clientPorts[0],
-                        CONNECTION_TIMEOUT));
-        Assert.assertTrue("waiting for server 1 being up", ClientBase
-                .waitForServerUp("127.0.0.1:" + clientPorts[1],
-                        CONNECTION_TIMEOUT));
-
-        int leader = mt[0].main.quorumPeer.leader == null ? 1 : 0;
-
-        // the new server's config is going to include itself and the current leader
-        sb = new StringBuilder();
-        sb.append(allServers.get(leader) + "\n");
-        sb.append(allServers.get(2) + "\n");
-
-        // suppose that this new server never heard about the reconfig proposal
-        String newServerInitialConfig = sb.toString();
-        mt[2] = new MainThread(2, clientPorts[2], newServerInitialConfig);
-        mt[2].start();
-        zk[2] = new ZooKeeper("127.0.0.1:" + clientPorts[2],
-                ClientBase.CONNECTION_TIMEOUT, this);
-
-        Assert.assertTrue("waiting for server 2 being up", ClientBase
-                .waitForServerUp("127.0.0.1:" + clientPorts[2],
-                        CONNECTION_TIMEOUT));
-
-        ReconfigTest.testServerHasConfig(zk[0], allServers, null);
-        ReconfigTest.testServerHasConfig(zk[1], allServers, null);
-        ReconfigTest.testServerHasConfig(zk[2], allServers, null);
-
-        ReconfigTest.testNormalOperation(zk[0], zk[2]);
-        ReconfigTest.testNormalOperation(zk[2], zk[1]);
-
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            mt[i].shutdown();
-            zk[i].close();
-        }
-    }
-
-    /**
-     * Reconfiguration recovery - current config servers discover .next file,
-     * but they're both observers and their ports change in next config. Suppose
-     * that next config wasn't activated yet. Should complete reconfiguration.
-     */
-    @Test
-    public void testCurrentServersAreObserversInNextConfig() throws Exception {
-        ClientBase.setupTestEnv();
-
-        // 2 servers in current config, 5 in next config
-        final int SERVER_COUNT = 5;
-        final int clientPorts[] = new int[SERVER_COUNT];
-        final int oldClientPorts[] = new int[2];
-        StringBuilder sb = new StringBuilder();
-        String server;
-
-        String currentQuorumCfg, nextQuorumCfgSection;
-
-        ArrayList<String> allServersNext = new ArrayList<String>();
-
-        for (int i = 0; i < 2; i++) {
-            oldClientPorts[i] = PortAssignment.unique();
-            server = "server." + i + "=localhost:" + PortAssignment.unique()
-                    + ":" + PortAssignment.unique() + ":participant;localhost:"
-                    + oldClientPorts[i];
-            sb.append(server + "\n");
-        }
-
-        currentQuorumCfg = sb.toString();
-
-        sb = new StringBuilder();
-        String role;
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            clientPorts[i] = PortAssignment.unique();
-            if (i < 2) {
-                role = "observer";
-            } else {
-                role = "participant";
-            }
-            server = "server." + i + "=localhost:" + PortAssignment.unique()
-                    + ":" + PortAssignment.unique() + ":" + role
-                    + ";localhost:" + clientPorts[i];
-            allServersNext.add(server);
-            sb.append(server + "\n");
-        }
-        nextQuorumCfgSection = sb.toString();
-
-        MainThread mt[] = new MainThread[SERVER_COUNT];
-        ZooKeeper zk[] = new ZooKeeper[SERVER_COUNT];
-
-        // run servers 0 and 1 normally
-        for (int i = 0; i < 2; i++) {
-            mt[i] = new MainThread(i, oldClientPorts[i], currentQuorumCfg,
-                    true, "100000000");
-            mt[i].start();
-            zk[i] = new ZooKeeper("127.0.0.1:" + oldClientPorts[i],
-                    ClientBase.CONNECTION_TIMEOUT, this);
-        }
-
-        for (int i = 0; i < 2; i++) {
-            Assert.assertTrue("waiting for server " + i + " being up",
-                    ClientBase.waitForServerUp(
-                            "127.0.0.1:" + oldClientPorts[i],
-                            CONNECTION_TIMEOUT * 2));
-        }
-
-        ReconfigTest.testNormalOperation(zk[0], zk[1]);
-
-        // shut them down and then simulate a reboot with a reconfig in progress
-        for (int i = 0; i < 2; i++) {
-            mt[i].shutdown();
-            zk[i].close();
-        }
-
-        for (int i = 0; i < 2; i++) {
-            Assert.assertTrue(
-                    "waiting for server " + i + " being up",
-                    ClientBase.waitForServerDown("127.0.0.1:"
-                            + oldClientPorts[i], CONNECTION_TIMEOUT * 2));
-        }
-
-        for (int i = 0; i < 2; i++) {
-            mt[i].writeTempDynamicConfigFile(nextQuorumCfgSection, "200000000");
-            mt[i].start();
-            zk[i] = new ZooKeeper("127.0.0.1:" + clientPorts[i],
-                    ClientBase.CONNECTION_TIMEOUT, this);
-        }
-
-        // new members are initialized with current config + the new server
-        for (int i = 2; i < SERVER_COUNT; i++) {
-            mt[i] = new MainThread(i, clientPorts[i], currentQuorumCfg
-                    + allServersNext.get(i));
-            mt[i].start();
-            zk[i] = new ZooKeeper("127.0.0.1:" + clientPorts[i],
-                    ClientBase.CONNECTION_TIMEOUT, this);
-        }
-
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            Assert.assertTrue("waiting for server " + i + " being up",
-                    ClientBase.waitForServerUp("127.0.0.1:" + clientPorts[i],
-                            CONNECTION_TIMEOUT * 2));
-            ReconfigTest.testServerHasConfig(zk[i], allServersNext, null);
-        }
-
-        ReconfigTest.testNormalOperation(zk[0], zk[2]);
-        ReconfigTest.testNormalOperation(zk[4], zk[1]);
-
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            zk[i].close();
-            mt[i].shutdown();
-        }
-    }
-
-    /**
-     * Reconfiguration recovery - test that if servers in old config have a
-     * .next file but no quorum of new config is up then no progress should be
-     * possible (no progress will happen to ensure safety as the new config
-     * might be actually up but partitioned from old config)
-     */
-    @Test
-    public void testNextConfigUnreachable() throws Exception {
-        ClientBase.setupTestEnv();
-
-        // 2 servers in current config, 5 in next config
-        final int SERVER_COUNT = 5;
-        final int clientPorts[] = new int[SERVER_COUNT];
-        StringBuilder sb = new StringBuilder();
-        String server;
-
-        String currentQuorumCfgSection = null, nextQuorumCfgSection;
-
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            clientPorts[i] = PortAssignment.unique();
-            server = "server." + i + "=localhost:" + PortAssignment.unique()
-                    + ":" + PortAssignment.unique() + ":participant;localhost:"
-                    + clientPorts[i];
-            sb.append(server + "\n");
-            if (i == 1)
-                currentQuorumCfgSection = sb.toString();
-        }
-        nextQuorumCfgSection = sb.toString();
-
-        MainThread mt[] = new MainThread[SERVER_COUNT];
-        ZooKeeper zk[] = new ZooKeeper[SERVER_COUNT];
-
-        // Both servers 0 and 1 will have the .next config file, which means
-        // for them that a reconfiguration was in progress when they failed
-        for (int i = 0; i < 2; i++) {
-            mt[i] = new MainThread(i, clientPorts[i], currentQuorumCfgSection,
-                    true, "100000000");
-            // note that we should run the server, shut it down and only then
-            // simulate a reconfig in progress by writing the temp file, but here no
-            // other server is competing with them in FLE, so we can skip this step
-            mt[i].writeTempDynamicConfigFile(nextQuorumCfgSection, "200000000");
-            mt[i].start();
-            zk[i] = new ZooKeeper("127.0.0.1:" + clientPorts[i],
-                    ClientBase.CONNECTION_TIMEOUT, this);
-        }
-
-        Thread.sleep(CONNECTION_TIMEOUT * 2);
-
-        // make sure servers 0, 1 don't come online - this should be the case
-        // since they can't complete the reconfig
-        for (int i = 0; i < 2; i++) {
-            Assert.assertFalse("server " + i + " is up but shouldn't be",
-                    ClientBase.waitForServerUp("127.0.0.1:" + clientPorts[i],
-                            CONNECTION_TIMEOUT / 10));
-        }
-
-        for (int i = 0; i < 2; i++) {
-            zk[i].close();
-            mt[i].shutdown();
-        }
-    }
-
-    /**
-     * Reconfiguration recovery - test that old config members will join the new
-     * config if its already active, and not try to complete the reconfiguration
-     */
-    @Test
-    public void testNextConfigAlreadyActive() throws Exception {
-        ClientBase.setupTestEnv();
-
-        // 2 servers in current config, 5 in next config
-        final int SERVER_COUNT = 5;
-        final int clientPorts[] = new int[SERVER_COUNT];
-        StringBuilder sb = new StringBuilder();
-        String server;
-
-        String currentQuorumCfgSection = null, nextQuorumCfgSection;
-
-        ArrayList<String> allServers = new ArrayList<String>();
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            clientPorts[i] = PortAssignment.unique();
-            server = "server." + i + "=localhost:" + PortAssignment.unique()
-                    + ":" + PortAssignment.unique() + ":participant;localhost:"
-                    + clientPorts[i];
-            allServers.add(server);
-            sb.append(server + "\n");
-            if (i == 1) currentQuorumCfgSection = sb.toString();
-        }
-        nextQuorumCfgSection = sb.toString();
-
-        // lets start servers 2, 3, 4 with the new config
-        MainThread mt[] = new MainThread[SERVER_COUNT];
-        ZooKeeper zk[] = new ZooKeeper[SERVER_COUNT];
-        for (int i = 2; i < SERVER_COUNT; i++) {
-            mt[i] = new MainThread(i, clientPorts[i], nextQuorumCfgSection,
-                    true, "200000000");
-            mt[i].start();
-            zk[i] = new ZooKeeper("127.0.0.1:" + clientPorts[i],
-                    ClientBase.CONNECTION_TIMEOUT, this);
-        }
-        for (int i = 2; i < SERVER_COUNT; i++) {
-            Assert.assertTrue("waiting for server " + i + " being up",
-                    ClientBase.waitForServerUp("127.0.0.1:" + clientPorts[i],
-                            CONNECTION_TIMEOUT));
-        }
-
-        ReconfigTest.testNormalOperation(zk[2], zk[3]);
-
-        long epoch = mt[2].main.quorumPeer.getAcceptedEpoch();
-
-        // Both servers 0 and 1 will have the .next config file, which means
-        // for them that a reconfiguration was in progress when they failed
-        // and the leader will complete it.
-        for (int i = 0; i < 2; i++) {
-            mt[i] = new MainThread(i, clientPorts[i], currentQuorumCfgSection,
-                    true, "100000000");
-            mt[i].writeTempDynamicConfigFile(nextQuorumCfgSection, "200000000");
-            mt[i].start();
-            zk[i] = new ZooKeeper("127.0.0.1:" + clientPorts[i],
-                    ClientBase.CONNECTION_TIMEOUT, this);
-        }
-
-        // servers 0 and 1 should connect to all servers, including the one in
-        // their .next file during startup, and will find the next config and join it
-        for (int i = 0; i < 2; i++) {
-            Assert.assertTrue("waiting for server " + i + " being up",
-                    ClientBase.waitForServerUp("127.0.0.1:" + clientPorts[i],
-                            CONNECTION_TIMEOUT * 2));
-        }
-
-        // make sure they joined the new config without any change to it
-        Assert.assertEquals(epoch, mt[0].main.quorumPeer.getAcceptedEpoch());
-        Assert.assertEquals(epoch, mt[1].main.quorumPeer.getAcceptedEpoch());
-        Assert.assertEquals(epoch, mt[2].main.quorumPeer.getAcceptedEpoch());
-
-        ReconfigTest.testServerHasConfig(zk[0], allServers, null);
-        ReconfigTest.testServerHasConfig(zk[1], allServers, null);
-
-        ReconfigTest.testNormalOperation(zk[0], zk[2]);
-        ReconfigTest.testNormalOperation(zk[4], zk[1]);
-
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            zk[i].close();
-            mt[i].shutdown();
-        }
-    }
-
-    /**
-     * Tests conversion of observer to participant AFTER new config was already
-     * committed. Old config: servers 0 (participant), 1 (participant), 2
-     * (observer) New config: servers 2 (participant), 3 (participant) We start
-     * server 2 with old config and start server 3 with new config. All other
-     * servers are down. In order to terminate FLE, server 3 must 'convince'
-     * server 2 to adopt the new config and turn into a participant.
-     */
-    @Test
-    public void testObserverConvertedToParticipantDuringFLE() throws Exception {
-        ClientBase.setupTestEnv();
-
-        final int SERVER_COUNT = 4;
-        int[][] ports = generatePorts(SERVER_COUNT);
-        String currentQuorumCfgSection, nextQuorumCfgSection;
-
-        // generate old config string
-        HashSet<Integer> observers = new HashSet<Integer>();
-        observers.add(2);
-        StringBuilder sb = generateConfig(3, ports, observers);
-        currentQuorumCfgSection = sb.toString();
-
-        // generate new config string
-        ArrayList<String> allServersNext = new ArrayList<String>();
-        sb = new StringBuilder();
-        for (int i = 2; i < SERVER_COUNT; i++) {
-            String server = "server." + i + "=localhost:" + ports[i][0] + ":"
-                    + ports[i][1] + ":participant;localhost:" + ports[i][2];
-            allServersNext.add(server);
-            sb.append(server + "\n");
-        }
-        nextQuorumCfgSection = sb.toString();
-
-        MainThread mt[] = new MainThread[SERVER_COUNT];
-        ZooKeeper zk[] = new ZooKeeper[SERVER_COUNT];
-
-        // start server 2 with old config, where it is an observer
-        mt[2] = new MainThread(2, ports[2][2], currentQuorumCfgSection,
-                true, "100000000");
-        mt[2].start();
-        zk[2] = new ZooKeeper("127.0.0.1:" + ports[2][2],
-                ClientBase.CONNECTION_TIMEOUT, this);
-
-        // start server 3 with new config
-        mt[3] = new MainThread(3, ports[3][2], nextQuorumCfgSection,
-                true, "200000000");
-        mt[3].start();
-        zk[3] = new ZooKeeper("127.0.0.1:" + ports[3][2],
-                ClientBase.CONNECTION_TIMEOUT, this);
-
-        for (int i = 2; i < SERVER_COUNT; i++) {
-            Assert.assertTrue("waiting for server " + i + " being up",
-                    ClientBase.waitForServerUp("127.0.0.1:" + ports[i][2],
-                            CONNECTION_TIMEOUT * 2));
-            ReconfigTest.testServerHasConfig(zk[i], allServersNext, null);
-        }
-
-        Assert.assertEquals(nextQuorumCfgSection + "version=200000000",
-                ReconfigTest.testServerHasConfig(zk[2], null, null));
-        Assert.assertEquals(nextQuorumCfgSection + "version=200000000",
-                ReconfigTest.testServerHasConfig(zk[3], null, null));
-        ReconfigTest.testNormalOperation(zk[2], zk[2]);
-        ReconfigTest.testNormalOperation(zk[3], zk[2]);
-
-        for (int i = 2; i < SERVER_COUNT; i++) {
-            zk[i].close();
-            mt[i].shutdown();
-        }
-    }
-
-    /**
-     * Tests conversion of observer to participant during reconfig recovery, new
-     * config was not committed yet. Old config: servers 0 (participant), 1
-     * (participant), 2 (observer) New config: servers 2 (participant), 3
-     * (participant) We start server servers 0, 1, 2 with old config and a .next
-     * file indicating a reconfig in progress. We start server 3 with old config
-     * + itself in config file. In this scenario server 2 can't be converted to
-     * participant during reconfig since we don't gossip about proposed
-     * configurations, only about committed ones. This tests that new config can
-     * be completed, which requires server 2's ack for the newleader message,
-     * even though its an observer.
-     */
-    @Test
-    public void testCurrentObserverIsParticipantInNewConfig() throws Exception {
-        ClientBase.setupTestEnv();
-
-        final int SERVER_COUNT = 4;
-        int[][] ports = generatePorts(SERVER_COUNT);
-        String currentQuorumCfg, nextQuorumCfgSection;
-
-        // generate old config string
-        HashSet<Integer> observers = new HashSet<Integer>();
-        observers.add(2);
-
-        StringBuilder sb = generateConfig(3, ports, observers);
-        currentQuorumCfg = sb.toString();
-
-        // Run servers 0..2 for a while
-        MainThread mt[] = new MainThread[SERVER_COUNT];
-        ZooKeeper zk[] = new ZooKeeper[SERVER_COUNT];
-        for (int i = 0; i <= 2; i++) {
-            mt[i] = new MainThread(i, ports[i][2], currentQuorumCfg
-                    , true, "100000000");
-            mt[i].start();
-            zk[i] = new ZooKeeper("127.0.0.1:" + ports[i][2],
-                    ClientBase.CONNECTION_TIMEOUT, this);
-        }
-
-        ReconfigTest.testNormalOperation(zk[0], zk[2]);
-
-        for (int i = 0; i <= 2; i++) {
-            Assert.assertTrue("waiting for server " + i + " being up",
-                    ClientBase.waitForServerUp("127.0.0.1:" + ports[i][2],
-                            CONNECTION_TIMEOUT * 2));
-        }
-
-        // shut servers 0..2 down
-        for (int i = 0; i <= 2; i++) {
-            mt[i].shutdown();
-            zk[i].close();
-        }
-
-        // generate new config string
-        ArrayList<String> allServersNext = new ArrayList<String>();
-        sb = new StringBuilder();
-        for (int i = 2; i < SERVER_COUNT; i++) {
-            String server = "server." + i + "=localhost:" + ports[i][0] + ":"
-                    + ports[i][1] + ":participant;localhost:" + ports[i][2];
-            allServersNext.add(server);
-            sb.append(server + "\n");
-        }
-        nextQuorumCfgSection = sb.toString();
-
-        // simulate reconfig in progress - servers 0..2 have a temp reconfig
-        // file when they boot
-        for (int i = 0; i <= 2; i++) {
-            mt[i].writeTempDynamicConfigFile(nextQuorumCfgSection, "200000000");
-            mt[i].start();
-            zk[i] = new ZooKeeper("127.0.0.1:" + ports[i][2],
-                    ClientBase.CONNECTION_TIMEOUT, this);
-        }
-        // new server 3 has still its invalid joiner config - everyone in old
-        // config + itself
-        mt[3] = new MainThread(3, ports[3][2], currentQuorumCfg
-                + allServersNext.get(1));
-        mt[3].start();
-        zk[3] = new ZooKeeper("127.0.0.1:" + ports[3][2],
-                ClientBase.CONNECTION_TIMEOUT, this);
-
-        for (int i = 2; i < SERVER_COUNT; i++) {
-            Assert.assertTrue("waiting for server " + i + " being up",
-                    ClientBase.waitForServerUp("127.0.0.1:" + ports[i][2],
-                            CONNECTION_TIMEOUT * 3));
-            ReconfigTest.testServerHasConfig(zk[i], allServersNext, null);
-        }
-
-        ReconfigTest.testNormalOperation(zk[0], zk[2]);
-        ReconfigTest.testNormalOperation(zk[3], zk[1]);
-        Assert.assertEquals(nextQuorumCfgSection + "version=200000000",
-                ReconfigTest.testServerHasConfig(zk[2], null, null));
-        Assert.assertEquals(nextQuorumCfgSection + "version=200000000",
-                ReconfigTest.testServerHasConfig(zk[3], null, null));
-
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            zk[i].close();
-            mt[i].shutdown();
-        }
-    }
-
-    /*
-     * Generates 3 ports per server
-     */
-    public static int[][] generatePorts(int numServers) {
-        int[][] ports = new int[numServers][];
-        for (int i = 0; i < numServers; i++) {
-            ports[i] = new int[3];
-            for (int j = 0; j < 3; j++) {
-                ports[i][j] = PortAssignment.unique();
-            }
-        }
-        return ports;
-    }
-
-    /*
-     * Creates a configuration string for servers 0..numServers-1 Ids in
-     * observerIds correspond to observers, other ids are for participants.
-     */
-    public static StringBuilder generateConfig(int numServers, int[][] ports,
-            HashSet<Integer> observerIds) {
-        StringBuilder sb = new StringBuilder();
-        for (int i = 0; i < numServers; i++) {
-            String server = "server." + i + "=localhost:" + ports[i][0] + ":"
-                    + ports[i][1] + ":"
-                    + (observerIds.contains(i) ? "observer" : "participant")
-                    + ";localhost:" + ports[i][2];
-            sb.append(server + "\n");
-        }
-        return sb;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/quorum/ReconfigRollingRestartCompatibilityTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/quorum/ReconfigRollingRestartCompatibilityTest.java b/src/java/test/org/apache/zookeeper/server/quorum/ReconfigRollingRestartCompatibilityTest.java
deleted file mode 100644
index 65ec469..0000000
--- a/src/java/test/org/apache/zookeeper/server/quorum/ReconfigRollingRestartCompatibilityTest.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zookeeper.server.quorum;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.Set;
-import java.util.List;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.ArrayList;
-
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.PortAssignment;
-import org.apache.zookeeper.test.ClientBase;
-import org.apache.zookeeper.test.ReconfigTest;
-import org.junit.Assert;
-import org.junit.Test;
-
-import static org.apache.zookeeper.test.ClientBase.CONNECTION_TIMEOUT;
-
-/**
- * ReconfigRollingRestartCompatibilityTest - we want to make sure that users
- * can continue using the rolling restart approach when reconfig feature is disabled.
- * It is important to stay compatible with rolling restart because dynamic reconfig
- * has its limitation: it requires a quorum of server to work. When no quorum can be formed,
- * rolling restart is the only approach to reconfigure the ensemble (e.g. removing bad nodes
- * such that a new quorum with smaller number of nodes can be formed.).
- *
- * See ZOOKEEPER-2819 for more details.
- */
-public class ReconfigRollingRestartCompatibilityTest extends QuorumPeerTestBase {
-    private static final String ZOO_CFG_BAK_FILE = "zoo.cfg.bak";
-
-    Map<Integer, Integer> clientPorts = new HashMap<>(5);
-    Map<Integer, String> serverAddress = new HashMap<>(5);
-
-    private String generateNewQuorumConfig(int serverCount) {
-        StringBuilder sb = new StringBuilder();
-        String server;
-        for (int i = 0; i < serverCount; i++) {
-            clientPorts.put(i, PortAssignment.unique());
-            server = "server." + i + "=localhost:" + PortAssignment.unique()
-                    + ":" + PortAssignment.unique() + ":participant;localhost:"
-                    + clientPorts.get(i);
-            serverAddress.put(i, server);
-            sb.append(server + "\n");
-        }
-        return sb.toString();
-    }
-
-    private String updateExistingQuorumConfig(List<Integer> sidsToAdd, List<Integer> sidsToRemove) {
-        StringBuilder sb = new StringBuilder();
-        for (Integer sid : sidsToAdd) {
-            clientPorts.put(sid, PortAssignment.unique());
-            serverAddress.put(sid, "server." + sid + "=localhost:" + PortAssignment.unique()
-                    + ":" + PortAssignment.unique() + ":participant;localhost:"
-                    + clientPorts.get(sid));
-        }
-
-        for (Integer sid : sidsToRemove) {
-            clientPorts.remove(sid);
-            serverAddress.remove(sid);
-        }
-
-        for (String server : serverAddress.values()) {
-            sb.append(server + "\n");
-        }
-
-        return sb.toString();
-    }
-
-    @Test(timeout = 60000)
-    // Verify no zoo.cfg.dynamic and zoo.cfg.bak files existing locally
-    // when reconfig feature flag is off by default.
-    public void testNoLocalDynamicConfigAndBackupFiles()
-            throws InterruptedException, IOException {
-        int serverCount = 3;
-        String config = generateNewQuorumConfig(serverCount);
-        QuorumPeerTestBase.MainThread mt[] = new QuorumPeerTestBase.MainThread[serverCount];
-        String[] staticFileContent = new String[serverCount];
-
-        for (int i = 0; i < serverCount; i++) {
-            mt[i] = new QuorumPeerTestBase.MainThread(i, clientPorts.get(i),
-                    config, false);
-            mt[i].start();
-        }
-
-        for (int i = 0; i < serverCount; i++) {
-            Assert.assertTrue("waiting for server " + i + " being up",
-                    ClientBase.waitForServerUp("127.0.0.1:" + clientPorts.get(i),
-                            CONNECTION_TIMEOUT));
-            Assert.assertNull("static file backup (zoo.cfg.bak) shouldn't exist!",
-                    mt[i].getFileByName(ZOO_CFG_BAK_FILE));
-            Assert.assertNull("dynamic configuration file (zoo.cfg.dynamic.*) shouldn't exist!",
-                    mt[i].getFileByName(mt[i].getQuorumPeer().getNextDynamicConfigFilename()));
-            staticFileContent[i] = Files.readAllLines(mt[i].confFile.toPath(), StandardCharsets.UTF_8).toString();
-            Assert.assertTrue("static config file should contain server entry " + serverAddress.get(i),
-                    staticFileContent[i].contains(serverAddress.get(i)));
-        }
-
-        for (int i = 0; i < serverCount; i++) {
-            mt[i].shutdown();
-        }
-    }
-
-    @Test(timeout = 60000)
-    // This test simulate the usual rolling restart with no membership change:
-    // 1. A node is shutdown first (e.g. to upgrade software, or hardware, or cleanup local data.).
-    // 2. After upgrade, start the node.
-    // 3. Do this for every node, one at a time.
-    public void testRollingRestartWithoutMembershipChange() throws Exception {
-        int serverCount = 3;
-        String config = generateNewQuorumConfig(serverCount);
-        List<String> joiningServers = new ArrayList<>();
-        QuorumPeerTestBase.MainThread mt[] = new QuorumPeerTestBase.MainThread[serverCount];
-        for (int i = 0; i < serverCount; ++i) {
-            mt[i] = new QuorumPeerTestBase.MainThread(i, clientPorts.get(i),
-                    config, false);
-            mt[i].start();
-            joiningServers.add(serverAddress.get(i));
-        }
-
-        for (int i = 0; i < serverCount; ++i) {
-            Assert.assertTrue("waiting for server " + i + " being up",
-                    ClientBase.waitForServerUp("127.0.0.1:" + clientPorts.get(i),
-                            CONNECTION_TIMEOUT));
-        }
-
-        for (int i = 0; i < serverCount; ++i) {
-            mt[i].shutdown();
-            mt[i].start();
-            verifyQuorumConfig(i, joiningServers, null);
-            verifyQuorumMembers(mt[i]);
-        }
-
-        for (int i = 0; i < serverCount; i++) {
-            mt[i].shutdown();
-        }
-    }
-
-    @Test(timeout = 90000)
-    // This test simulate the use case of change of membership through rolling
-    // restart. For a 3 node ensemble we expand it to a 5 node ensemble, verify
-    // during the process each node has the expected configuration setting pushed
-    // via updating local zoo.cfg file.
-    public void testRollingRestartWithMembershipChange() throws Exception {
-        int serverCount = 3;
-        String config = generateNewQuorumConfig(serverCount);
-        QuorumPeerTestBase.MainThread mt[] = new QuorumPeerTestBase.MainThread[serverCount];
-        List<String> joiningServers = new ArrayList<>();
-        for (int i = 0; i < serverCount; ++i) {
-            mt[i] = new QuorumPeerTestBase.MainThread(i, clientPorts.get(i),
-                    config, false);
-            mt[i].start();
-            joiningServers.add(serverAddress.get(i));
-        }
-
-        for (int i = 0; i < serverCount; ++i) {
-            Assert.assertTrue("waiting for server " + i + " being up",
-                    ClientBase.waitForServerUp("127.0.0.1:" + clientPorts.get(i),
-                            CONNECTION_TIMEOUT));
-        }
-
-        for (int i = 0; i < serverCount; ++i) {
-            verifyQuorumConfig(i, joiningServers, null);
-            verifyQuorumMembers(mt[i]);
-        }
-
-        Map<Integer, String> oldServerAddress = new HashMap<>(serverAddress);
-        List<String> newServers = new ArrayList<>(joiningServers);
-        config = updateExistingQuorumConfig(Arrays.asList(3, 4), new ArrayList<Integer>());
-        newServers.add(serverAddress.get(3)); newServers.add(serverAddress.get(4));
-        serverCount = serverAddress.size();
-        Assert.assertEquals("Server count should be 5 after config update.", serverCount, 5);
-
-        // We are adding two new servers to the ensemble. These two servers should have the config which includes
-        // all five servers (the old three servers, plus the two servers added). The old three servers should only
-        // have the old three server config, because disabling reconfig will prevent synchronizing configs between
-        // peers.
-        mt = Arrays.copyOf(mt, mt.length + 2);
-        for (int i = 3; i < 5; ++i) {
-            mt[i] = new QuorumPeerTestBase.MainThread(i, clientPorts.get(i),
-                    config, false);
-            mt[i].start();
-            Assert.assertTrue("waiting for server " + i + " being up",
-                    ClientBase.waitForServerUp("127.0.0.1:" + clientPorts.get(i),
-                            CONNECTION_TIMEOUT));
-            verifyQuorumConfig(i, newServers, null);
-            verifyQuorumMembers(mt[i]);
-        }
-
-        Set<String> expectedConfigs = new HashSet<>();
-        for (String conf : oldServerAddress.values()) {
-            // Remove "server.x=" prefix which quorum peer does not include.
-            expectedConfigs.add(conf.substring(conf.indexOf('=') + 1));
-        }
-
-        for (int i = 0; i < 3; ++i) {
-            verifyQuorumConfig(i, joiningServers, null);
-            verifyQuorumMembers(mt[i], expectedConfigs);
-        }
-
-        for (int i = 0; i < serverCount; ++i) {
-            mt[i].shutdown();
-        }
-    }
-
-    // Verify each quorum peer has expected config in its config zNode.
-    private void verifyQuorumConfig(int sid, List<String> joiningServers, List<String> leavingServers) throws Exception {
-        ZooKeeper zk = ClientBase.createZKClient("127.0.0.1:" + clientPorts.get(sid));
-        ReconfigTest.testNormalOperation(zk, zk);
-        ReconfigTest.testServerHasConfig(zk, joiningServers, leavingServers);
-        zk.close();
-    }
-
-    // Verify each quorum peer has expected quorum member view.
-    private void verifyQuorumMembers(QuorumPeerTestBase.MainThread mt) {
-        Set<String> expectedConfigs = new HashSet<>();
-        for (String config : serverAddress.values()) {
-            expectedConfigs.add(config.substring(config.indexOf('=') + 1));
-        }
-        verifyQuorumMembers(mt, expectedConfigs);
-    }
-
-    private void verifyQuorumMembers(QuorumPeerTestBase.MainThread mt, Set<String> expectedConfigs) {
-        Map<Long, QuorumPeer.QuorumServer> members =
-                mt.getQuorumPeer().getQuorumVerifier().getAllMembers();
-
-        Assert.assertTrue("Quorum member should not change.",
-                members.size() == expectedConfigs.size());
-
-        for (QuorumPeer.QuorumServer qs : members.values()) {
-            String actualConfig = qs.toString();
-            Assert.assertTrue("Unexpected config " + actualConfig + " found!",
-                    expectedConfigs.contains(actualConfig));
-        }
-    }
-}
-
-
-

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/quorum/RemotePeerBeanTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/quorum/RemotePeerBeanTest.java b/src/java/test/org/apache/zookeeper/server/quorum/RemotePeerBeanTest.java
deleted file mode 100644
index fbb0acc..0000000
--- a/src/java/test/org/apache/zookeeper/server/quorum/RemotePeerBeanTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zookeeper.server.quorum;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.mockito.Matchers.eq;
-
-import java.net.InetSocketAddress;
-
-import org.apache.zookeeper.server.quorum.QuorumPeer.QuorumServer;
-import org.junit.Test;
-
-public class RemotePeerBeanTest {
-
-    /**
-     * Test case for https://issues.apache.org/jira/browse/ZOOKEEPER-2269
-     */
-    @Test
-    public void testGetClientAddressShouldReturnEmptyStringWhenClientAddressIsNull() {
-        InetSocketAddress peerCommunicationAddress = null;
-        // Here peerCommunicationAddress is null, also clientAddr is null
-        QuorumServer peer = new QuorumServer(1, peerCommunicationAddress);
-        RemotePeerBean remotePeerBean = new RemotePeerBean(null, peer);
-        String clientAddress = remotePeerBean.getClientAddress();
-        assertNotNull(clientAddress);
-        assertEquals(0, clientAddress.length());
-    }
-
-    @Test
-    @SuppressWarnings("unchecked")
-    public void testIsLeader() {
-        long peerId = 7;
-        QuorumPeer.QuorumServer quorumServerMock = mock(QuorumPeer.QuorumServer.class);
-        when(quorumServerMock.getId()).thenReturn(peerId);
-        QuorumPeer peerMock = mock(QuorumPeer.class);
-        RemotePeerBean remotePeerBean = new RemotePeerBean(peerMock, quorumServerMock);
-        when(peerMock.isLeader(eq(peerId))).thenReturn(true);
-        assertTrue(remotePeerBean.isLeader());
-        when(peerMock.isLeader(eq(peerId))).thenReturn(false);
-        assertFalse(remotePeerBean.isLeader());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/quorum/StandaloneDisabledTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/quorum/StandaloneDisabledTest.java b/src/java/test/org/apache/zookeeper/server/quorum/StandaloneDisabledTest.java
deleted file mode 100644
index b08bd23..0000000
--- a/src/java/test/org/apache/zookeeper/server/quorum/StandaloneDisabledTest.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zookeeper.server.quorum;
-
-import static org.apache.zookeeper.test.ClientBase.CONNECTION_TIMEOUT;
-
-import java.util.ArrayList;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.data.Stat;
-import org.apache.zookeeper.PortAssignment;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.admin.ZooKeeperAdmin;
-import org.apache.zookeeper.client.FourLetterWordMain;
-import org.apache.zookeeper.test.ClientBase;
-import org.apache.zookeeper.test.ReconfigTest;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class StandaloneDisabledTest extends QuorumPeerTestBase {
-
-    private final int NUM_SERVERS = 5;
-    private MainThread peers[];
-    private ZooKeeper zkHandles[];
-    private ZooKeeperAdmin zkAdminHandles[];
-    private int clientPorts[];
-    private final int leaderId = 0;
-    private final int follower1 = 1;
-    private final int follower2 = 2;
-    private final int observer1 = 3;
-    private final int observer2 = 4;
-    private ArrayList<String> serverStrings;
-    private ArrayList<String> reconfigServers;
-
-    /**
-     * Test normal quorum operations work cleanly
-     * with just a single server.
-     */
-    @Test(timeout = 600000)
-    public void startSingleServerTest() throws Exception {
-        setUpData();
-
-        //start one server
-        startServer(leaderId, serverStrings.get(leaderId) + "\n");
-        ReconfigTest.testServerHasConfig(zkHandles[leaderId], null, null);
-        LOG.info("Initial Configuration:\n"
-                 + new String(zkHandles[leaderId].getConfig(this, new Stat())));
-
-        //start and add 2 followers
-        startFollowers();
-        testReconfig(leaderId, true, reconfigServers);
-        LOG.info("Configuration after adding 2 followers:\n"
-                 + new String(zkHandles[leaderId].getConfig(this, new Stat())));
-
-        //shutdown leader- quorum should still exist
-        shutDownServer(leaderId);
-        ReconfigTest.testNormalOperation(zkHandles[follower1], zkHandles[follower2]);
-
-        //should not be able to remove follower 2
-        //No quorum in new config (1/2)
-        reconfigServers.clear();
-        reconfigServers.add(Integer.toString(follower2));
-        try {
-            ReconfigTest.reconfig(zkAdminHandles[follower1], null, reconfigServers, null, -1);
-            Assert.fail("reconfig completed successfully even though there is no quorum up in new config!");
-        } catch (KeeperException.NewConfigNoQuorum e) { }
-
-        //reconfigure out leader and follower 1. Remaining follower
-        //2 should elect itself as leader and run by itself
-        reconfigServers.clear();
-        reconfigServers.add(Integer.toString(leaderId));
-        reconfigServers.add(Integer.toString(follower1));
-        testReconfig(follower2, false, reconfigServers);
-        LOG.info("Configuration after removing leader and follower 1:\n"
-                + new String(zkHandles[follower2].getConfig(this, new Stat())));
-
-        // Kill server 1 to avoid it interferences with FLE of the quorum {2, 3, 4}.
-        shutDownServer(follower1);
-
-        // Try to remove follower2, which is the only remaining server. This should fail.
-        reconfigServers.clear();
-        reconfigServers.add(Integer.toString(follower2));
-        try {
-            zkAdminHandles[follower2].reconfigure(null, reconfigServers, null, -1, new Stat());
-            Assert.fail("reconfig completed successfully even though there is no quorum up in new config!");
-        } catch (KeeperException.BadArgumentsException e) {
-            // This is expected.
-        } catch (Exception e) {
-            Assert.fail("Should have been BadArgumentsException!");
-        }
-
-        //Add two participants and change them to observers to check
-        //that we can reconfigure down to one participant with observers.
-        ArrayList<String> observerStrings = new ArrayList<String>();
-        startObservers(observerStrings);
-        testReconfig(follower2, true, reconfigServers); //add partcipants
-        testReconfig(follower2, true, observerStrings); //change to observers
-        LOG.info("Configuration after adding two observers:\n"
-                + new String(zkHandles[follower2].getConfig(this, new Stat())));
-
-        shutDownData();
-    }
-
-    /**
-     * Initialize private data for test.
-     */
-    private void setUpData() throws Exception {
-        ClientBase.setupTestEnv();
-        QuorumPeerConfig.setStandaloneEnabled(false);
-        QuorumPeerConfig.setReconfigEnabled(true);
-        peers = new MainThread[NUM_SERVERS];
-        zkHandles = new ZooKeeper[NUM_SERVERS];
-        zkAdminHandles = new ZooKeeperAdmin[NUM_SERVERS];
-        clientPorts = new int[NUM_SERVERS];
-        serverStrings = buildServerStrings();
-        reconfigServers = new ArrayList<String>();
-        System.setProperty("zookeeper.DigestAuthenticationProvider.superDigest",
-                "super:D/InIHSb7yEEbrWz8b9l71RjZJU="/* password is 'test'*/);
-    }
-
-    /**
-     * Stop server threads.
-     */
-    private void shutDownData() throws Exception {
-        for (int i = 0; i < NUM_SERVERS; i++) {
-            zkHandles[i].close();
-            zkAdminHandles[i].close();
-        }
-        for (int i = 1; i < NUM_SERVERS; i++) {
-            peers[i].shutdown();
-        }
-    }
-
-    /**
-     * Create config strings that will be used for
-     * the test servers.
-     */
-    private ArrayList<String> buildServerStrings() {
-        ArrayList<String> serverStrings = new ArrayList<String>();
-
-        for(int i = 0; i < NUM_SERVERS; i++) {
-            clientPorts[i] = PortAssignment.unique();
-            String server = "server." + i + "=localhost:" + PortAssignment.unique()
-                +":"+PortAssignment.unique() + ":participant;"
-                + "localhost:" + clientPorts[i];
-            serverStrings.add(server);
-        }
-        return serverStrings;
-    }
-
-    /**
-     * Starts a single server in replicated mode,
-     * initializes its client, and waits for it
-     * to be connected.
-     */
-    private void startServer(int id, String config) throws Exception {
-        peers[id] = new MainThread(id, clientPorts[id], config);
-        peers[id].start();
-        Assert.assertTrue("Server " + id + " is not up",
-                          ClientBase.waitForServerUp("127.0.0.1:" + clientPorts[id], CONNECTION_TIMEOUT));
-        Assert.assertTrue("Error- Server started in Standalone Mode!",
-                peers[id].isQuorumPeerRunning());
-        zkHandles[id] = ClientBase.createZKClient("127.0.0.1:" + clientPorts[id]);
-        zkAdminHandles[id] = new ZooKeeperAdmin("127.0.0.1:" + clientPorts[id], CONNECTION_TIMEOUT, this);
-        zkAdminHandles[id].addAuthInfo("digest", "super:test".getBytes());
-        String statCommandOut = FourLetterWordMain.send4LetterWord("127.0.0.1", clientPorts[id], "stat");
-        LOG.info(String.format("Started server id %d with config:\n%s\nStat output:\n%s",
-                id, config, statCommandOut));
-    }
-
-    /**
-     * Shuts down a server, waits for it to disconnect,
-     * and gives enough time for the learner handler
-     * in its ensemble to realize it's been shut down.
-     */
-    private void shutDownServer(int id) throws Exception {
-        peers[id].shutdown();
-        ClientBase.waitForServerDown("127.0.0.1:" + clientPorts[id], CONNECTION_TIMEOUT);
-        TimeUnit.SECONDS.sleep(25);
-    }
-
-    /**
-     * Starts servers 1 & 2 as participants and
-     * adds them to the list to be reconfigured
-     * into the ensemble.
-     */
-    private void startFollowers() throws Exception {
-        reconfigServers.clear();
-        for(int i = 1; i <= 2; i++) {
-            String config = serverStrings.get(leaderId) + "\n"
-                + serverStrings.get(i)  + "\n"
-                + serverStrings.get(i % 2 + 1) + "\n";
-            startServer(i, config);
-            reconfigServers.add(serverStrings.get(i));
-        }
-    }
-     /**
-     * Starts servers 1 & 2 as participants,
-     * adds them to the list to be reconfigured
-     * into the ensemble, and adds an observer
-     * version of their information to a list
-     * so they will be turned into observers later.
-     */
-    private void startObservers(ArrayList<String> observerStrings) throws Exception {
-        reconfigServers.clear();
-        for(int i = observer1; i <= observer2; i++) {
-            String config = serverStrings.get(follower2) + "\n"
-                + serverStrings.get(i) + "\n";
-            startServer(i, config);
-            reconfigServers.add(serverStrings.get(i));
-            observerStrings.add(serverStrings.get(i).replace("participant", "observer"));
-        }
-    }
-
-    /**
-     * Calls reconfig on the client corresponding to id to add or remove
-     * the given servers. Tests appropriately to make sure the
-     * reconfig succeeded.
-     */
-    private void testReconfig(int id, boolean adding,
-                              ArrayList<String> servers) throws Exception {
-        if (adding) {
-            ReconfigTest.reconfig(zkAdminHandles[id], servers, null, null, -1);
-            for (String server : servers) {
-                int id2 = Integer.parseInt(server.substring(7, 8)); //server.#
-                ReconfigTest.testNormalOperation(zkHandles[id], zkHandles[id2]);
-            }
-            ReconfigTest.testServerHasConfig(zkHandles[id], servers, null);
-        } else {
-            ReconfigTest.reconfig(zkAdminHandles[id], null, servers, null, -1);
-            ReconfigTest.testServerHasConfig(zkHandles[id], null, servers);
-        }
-
-    }
-
-   /**
-    * Ensure observer cannot start by itself
-    **/
-    @Test
-    public void startObserver() throws Exception {
-        int clientPort = PortAssignment.unique();
-        String config = "server." + observer1 + "=localhost:"+ PortAssignment.unique()
-            + ":" + clientPort +  ":observer;"
-            + "localhost:" + PortAssignment.unique();
-        MainThread observer = new MainThread(observer1, clientPort, config);
-        observer.start();
-        Assert.assertFalse("Observer was able to start by itself!",
-                           ClientBase.waitForServerUp("127.0.0.1:" + clientPort, CONNECTION_TIMEOUT));
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/quorum/StatCommandTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/quorum/StatCommandTest.java b/src/java/test/org/apache/zookeeper/server/quorum/StatCommandTest.java
deleted file mode 100644
index eccb6b1..0000000
--- a/src/java/test/org/apache/zookeeper/server/quorum/StatCommandTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zookeeper.server.quorum;
-
-import org.apache.zookeeper.server.ServerCnxn;
-import org.apache.zookeeper.server.ServerCnxnFactory;
-import org.apache.zookeeper.server.ServerStats;
-import org.apache.zookeeper.server.ZKDatabase;
-import org.apache.zookeeper.server.command.FourLetterCommands;
-import org.apache.zookeeper.server.command.StatCommand;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class StatCommandTest {
-    private StringWriter outputWriter;
-    private StatCommand statCommand;
-    private ServerStats.Provider providerMock;
-
-    @Before
-    public void setUp() {
-        outputWriter = new StringWriter();
-        ServerCnxn serverCnxnMock = mock(ServerCnxn.class);
-
-        LeaderZooKeeperServer zks = mock(LeaderZooKeeperServer.class);
-        when(zks.isRunning()).thenReturn(true);
-        providerMock = mock(ServerStats.Provider.class);
-        when(zks.serverStats()).thenReturn(new ServerStats(providerMock));
-        ZKDatabase zkDatabaseMock = mock(ZKDatabase.class);
-        when(zks.getZKDatabase()).thenReturn(zkDatabaseMock);
-        Leader leaderMock = mock(Leader.class);
-        when(leaderMock.getProposalStats()).thenReturn(new BufferStats());
-        when(zks.getLeader()).thenReturn(leaderMock);
-
-        ServerCnxnFactory serverCnxnFactory = mock(ServerCnxnFactory.class);
-        ServerCnxn serverCnxn = mock(ServerCnxn.class);
-        List<ServerCnxn> connections = new ArrayList<>();
-        connections.add(serverCnxn);
-        when(serverCnxnFactory.getConnections()).thenReturn(connections);
-
-        statCommand = new StatCommand(new PrintWriter(outputWriter), serverCnxnMock, FourLetterCommands.statCmd);
-        statCommand.setZkServer(zks);
-        statCommand.setFactory(serverCnxnFactory);
-    }
-
-    @Test
-    public void testLeaderStatCommand() {
-        // Arrange
-        when(providerMock.getState()).thenReturn("leader");
-
-        // Act
-        statCommand.commandRun();
-
-        // Assert
-        String output = outputWriter.toString();
-        assertCommonStrings(output);
-        assertThat(output, containsString("Mode: leader"));
-        assertThat(output, containsString("Proposal sizes last/min/max:"));
-    }
-
-    @Test
-    public void testFollowerStatCommand() {
-        // Arrange
-        when(providerMock.getState()).thenReturn("follower");
-
-        // Act
-        statCommand.commandRun();
-
-        // Assert
-        String output = outputWriter.toString();
-        assertCommonStrings(output);
-        assertThat(output, containsString("Mode: follower"));
-    }
-
-    private void assertCommonStrings(String output) {
-        assertThat(output, containsString("Clients:"));
-        assertThat(output, containsString("Zookeeper version:"));
-        assertThat(output, containsString("Node count:"));
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/3ce1b18b/src/java/test/org/apache/zookeeper/server/quorum/StatResetCommandTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/quorum/StatResetCommandTest.java b/src/java/test/org/apache/zookeeper/server/quorum/StatResetCommandTest.java
deleted file mode 100644
index 0c20c58..0000000
--- a/src/java/test/org/apache/zookeeper/server/quorum/StatResetCommandTest.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zookeeper.server.quorum;
-
-import org.apache.zookeeper.server.ServerCnxn;
-import org.apache.zookeeper.server.ServerStats;
-import org.apache.zookeeper.server.ZooKeeperServer;
-import org.apache.zookeeper.server.command.StatResetCommand;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
-import static org.apache.zookeeper.server.command.AbstractFourLetterCommand.ZK_NOT_SERVING;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class StatResetCommandTest {
-    private StatResetCommand statResetCommand;
-    private StringWriter outputWriter;
-    private ZooKeeperServer zks;
-    private ServerStats serverStats;
-
-    @Before
-    public void setUp() {
-        outputWriter = new StringWriter();
-        ServerCnxn serverCnxnMock = mock(ServerCnxn.class);
-
-        zks = mock(ZooKeeperServer.class);
-        when(zks.isRunning()).thenReturn(true);
-
-        serverStats = mock(ServerStats.class);
-        when(zks.serverStats()).thenReturn(serverStats);
-
-        statResetCommand = new StatResetCommand(new PrintWriter(outputWriter), serverCnxnMock);
-        statResetCommand.setZkServer(zks);
-    }
-
-    @Test
-    public void testStatResetWithZKNotRunning() {
-        // Arrange
-        when(zks.isRunning()).thenReturn(false);
-
-        // Act
-        statResetCommand.commandRun();
-
-        // Assert
-        String output = outputWriter.toString();
-        assertEquals(ZK_NOT_SERVING + "\n", output);
-    }
-
-    @Test
-    public void testStatResetWithFollower() {
-        // Arrange
-        when(zks.isRunning()).thenReturn(true);
-        when(serverStats.getServerState()).thenReturn("follower");
-
-        // Act
-        statResetCommand.commandRun();
-
-        // Assert
-        String output = outputWriter.toString();
-        assertEquals("Server stats reset.\n", output);
-        verify(serverStats, times(1)).reset();
-    }
-
-    @Test
-    public void testStatResetWithLeader() {
-        // Arrange
-        LeaderZooKeeperServer leaderZks = mock(LeaderZooKeeperServer.class);
-        when(leaderZks.isRunning()).thenReturn(true);
-        when(leaderZks.serverStats()).thenReturn(serverStats);
-        Leader leader = mock(Leader.class);
-        when(leaderZks.getLeader()).thenReturn(leader);
-        statResetCommand.setZkServer(leaderZks);
-
-        when(serverStats.getServerState()).thenReturn("leader");
-
-        BufferStats bufferStats = mock(BufferStats.class);
-        when(leader.getProposalStats()).thenReturn(bufferStats);
-
-        // Act
-        statResetCommand.commandRun();
-
-        // Assert
-        String output = outputWriter.toString();
-        assertEquals("Server stats reset.\n", output);
-        verify(serverStats, times(1)).reset();
-        verify(bufferStats, times(1)).reset();
-    }
-}


Mime
View raw message