zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an...@apache.org
Subject [05/51] [partial] zookeeper git commit: ZOOKEEPER-3032: MAVEN MIGRATION - move java server, client
Date Fri, 05 Oct 2018 12:25:58 GMT
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerTestBase.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerTestBase.java b/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerTestBase.java
deleted file mode 100644
index a357a6e..0000000
--- a/src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerTestBase.java
+++ /dev/null
@@ -1,405 +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.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.Properties;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.ZKTestCase;
-import org.apache.zookeeper.common.PathUtils;
-import org.apache.zookeeper.server.admin.AdminServer.AdminServerException;
-import org.apache.zookeeper.server.admin.JettyAdminServer;
-import org.apache.zookeeper.test.ClientBase;
-import org.apache.zookeeper.test.QuorumBase;
-
-/**
- * Has some common functionality for tests that work with QuorumPeers. Override
- * process(WatchedEvent) to implement the Watcher interface
- */
-public class QuorumPeerTestBase extends ZKTestCase implements Watcher {
-    protected static final Logger LOG = LoggerFactory
-            .getLogger(QuorumPeerTestBase.class);
-
-    public static final int TIMEOUT = 5000;
-
-    public void process(WatchedEvent event) {
-        // ignore for this test
-    }
-
-    public static class TestQPMain extends QuorumPeerMain {
-        public void shutdown() {
-            // ensure it closes - in particular wait for thread to exit
-            if (quorumPeer != null) {
-                QuorumBase.shutdown(quorumPeer);
-            }
-        }
-    }
-    
-    public static class MainThread implements Runnable {
-        final File confFile;
-        final File tmpDir;
-
-        public static final int UNSET_STATIC_CLIENTPORT = -1;
-        // standalone mode doens't need myid
-        public static final int UNSET_MYID = -1;
-
-        volatile TestQPMain main;
-
-        File baseDir;
-        private int myid;
-        private int clientPort;
-        private String quorumCfgSection;
-        private Map<String, String> otherConfigs;
-
-        /**
-         * Create a MainThread
-         *
-         * @param myid
-         * @param clientPort
-         * @param quorumCfgSection
-         * @param otherConfigs
-         * @param tickTime initLimit will be 10 and syncLimit will be 5
-         * @throws IOException
-         */
-        public MainThread(int myid, int clientPort, String quorumCfgSection,
-                Map<String, String> otherConfigs, int tickTime) throws IOException {
-            baseDir = ClientBase.createTmpDir();
-            this.myid = myid;
-            this.clientPort = clientPort;
-            this.quorumCfgSection = quorumCfgSection;
-            this.otherConfigs = otherConfigs;
-            LOG.info("id = " + myid + " tmpDir = " + baseDir + " clientPort = "
-                    + clientPort);
-            confFile = new File(baseDir, "zoo.cfg");
-
-            FileWriter fwriter = new FileWriter(confFile);
-            fwriter.write("tickTime=" + tickTime + "\n");
-            fwriter.write("initLimit=10\n");
-            fwriter.write("syncLimit=5\n");
-
-            tmpDir = new File(baseDir, "data");
-            if (!tmpDir.mkdir()) {
-                throw new IOException("Unable to mkdir " + tmpDir);
-            }
-
-            // Convert windows path to UNIX to avoid problems with "\"
-            String dir = tmpDir.toString();
-            String osname = java.lang.System.getProperty("os.name");
-            if (osname.toLowerCase().contains("windows")) {
-                dir = dir.replace('\\', '/');
-            }
-            fwriter.write("dataDir=" + dir + "\n");
-
-            fwriter.write("clientPort=" + clientPort + "\n");
-
-            // write extra configurations
-            Set<Entry<String, String>> entrySet = otherConfigs.entrySet();
-            for (Entry<String, String> entry : entrySet) {
-                fwriter.write(entry.getKey() + "=" + entry.getValue() + "\n");
-            }
-
-            fwriter.write(quorumCfgSection + "\n");
-            fwriter.flush();
-            fwriter.close();
-
-            File myidFile = new File(tmpDir, "myid");
-            fwriter = new FileWriter(myidFile);
-            fwriter.write(Integer.toString(myid));
-            fwriter.flush();
-            fwriter.close();
-        }
-
-        public MainThread(int myid, String quorumCfgSection) throws IOException {
-            this(myid, quorumCfgSection, true);
-        }
-
-        public MainThread(int myid, String quorumCfgSection, Integer secureClientPort, boolean writeDynamicConfigFile)
-                throws  IOException {
-            this(myid, UNSET_STATIC_CLIENTPORT, JettyAdminServer.DEFAULT_PORT, secureClientPort,
-                    quorumCfgSection, null, null, writeDynamicConfigFile, null);
-        }
-
-        public MainThread(int myid, String quorumCfgSection, boolean writeDynamicConfigFile)
-                throws IOException {
-            this(myid, UNSET_STATIC_CLIENTPORT, quorumCfgSection, writeDynamicConfigFile);
-        }
-
-        public MainThread(int myid, int clientPort, String quorumCfgSection, boolean writeDynamicConfigFile)
-                throws IOException {
-            this(myid, clientPort, JettyAdminServer.DEFAULT_PORT, quorumCfgSection, null, null, writeDynamicConfigFile);
-        }
-        
-        public MainThread(int myid, int clientPort, String quorumCfgSection, String peerType, boolean writeDynamicConfigFile)
-                throws IOException {
-            this(myid, clientPort, JettyAdminServer.DEFAULT_PORT, quorumCfgSection, null, peerType, writeDynamicConfigFile);
-        }
-
-        public MainThread(int myid, int clientPort, String quorumCfgSection, boolean writeDynamicConfigFile,
-                          String version) throws IOException {
-            this(myid, clientPort, JettyAdminServer.DEFAULT_PORT, quorumCfgSection, null,
-                    null, writeDynamicConfigFile, version);
-        }
-
-        public MainThread(int myid, int clientPort, String quorumCfgSection, String configs)
-                throws IOException {
-            this(myid, clientPort, JettyAdminServer.DEFAULT_PORT, quorumCfgSection, configs, null, true);
-        }
-
-        public MainThread(int myid, int clientPort, int adminServerPort, String quorumCfgSection,
-                String configs)  throws IOException {
-            this(myid, clientPort, adminServerPort, quorumCfgSection, configs, null, true);
-        }
-
-        public MainThread(int myid, int clientPort, int adminServerPort, String quorumCfgSection,
-                String configs, String peerType, boolean writeDynamicConfigFile)
-                throws IOException {
-            this(myid, clientPort, adminServerPort, quorumCfgSection, configs, peerType, writeDynamicConfigFile, null);
-        }
-
-        public MainThread(int myid, int clientPort, int adminServerPort, String quorumCfgSection,
-                          String configs, String peerType, boolean writeDynamicConfigFile, String version) throws IOException {
-            this(myid, clientPort, adminServerPort, null, quorumCfgSection, configs, peerType, writeDynamicConfigFile, version);
-        }
-
-        public MainThread(int myid, int clientPort, int adminServerPort, Integer secureClientPort,
-                          String quorumCfgSection, String configs, String peerType, boolean writeDynamicConfigFile, String version)
-                throws IOException {
-            tmpDir = ClientBase.createTmpDir();
-            LOG.info("id = " + myid + " tmpDir = " + tmpDir + " clientPort = "
-                    + clientPort + " adminServerPort = " + adminServerPort);
-
-            File dataDir = new File(tmpDir, "data");
-            if (!dataDir.mkdir()) {
-                throw new IOException("Unable to mkdir " + dataDir);
-            }
-
-            confFile = new File(tmpDir, "zoo.cfg");
-
-            FileWriter fwriter = new FileWriter(confFile);
-            fwriter.write("tickTime=4000\n");
-            fwriter.write("initLimit=10\n");
-            fwriter.write("syncLimit=5\n");
-            if(configs != null){
-                fwriter.write(configs);
-            }
-
-            // Convert windows path to UNIX to avoid problems with "\"
-            String dir = PathUtils.normalizeFileSystemPath(dataDir.toString());
-
-            fwriter.write("dataDir=" + dir + "\n");
-            fwriter.write("admin.serverPort=" + adminServerPort + "\n");
-
-            // For backward compatibility test, some tests create dynamic configuration
-            // without setting client port.
-            // This could happen both in static file or dynamic file.
-            if (clientPort != UNSET_STATIC_CLIENTPORT) {
-                fwriter.write("clientPort=" + clientPort + "\n");
-            }
-
-            if (secureClientPort != null) {
-                fwriter.write("secureClientPort=" + secureClientPort + "\n");
-            }
-            
-            if (peerType != null) {
-                fwriter.write("peerType=" + peerType + "\n");
-            }
-
-            if (writeDynamicConfigFile) {
-                String dynamicConfigFilename = createDynamicFile(quorumCfgSection, version);
-                fwriter.write("dynamicConfigFile=" + dynamicConfigFilename + "\n");
-            } else {
-                fwriter.write(quorumCfgSection);
-            }
-            fwriter.flush();
-            fwriter.close();
-
-            File myidFile = new File(dataDir, "myid");
-            fwriter = new FileWriter(myidFile);
-            fwriter.write(Integer.toString(myid));
-            fwriter.flush();
-            fwriter.close();
-
-            ClientBase.createInitializeFile(dataDir);
-        }
-
-        private String createDynamicFile(String quorumCfgSection, String version)
-                throws IOException {
-            String filename = "zoo.cfg.dynamic";
-            if( version != null ){
-                filename = filename + "." + version;
-            }
-
-            File dynamicConfigFile = new File(tmpDir, filename);
-            String dynamicConfigFilename = PathUtils.normalizeFileSystemPath(dynamicConfigFile.toString());
-
-            FileWriter fDynamicConfigWriter = new FileWriter(dynamicConfigFile);
-            fDynamicConfigWriter.write(quorumCfgSection);
-            fDynamicConfigWriter.flush();
-            fDynamicConfigWriter.close();
-
-            return dynamicConfigFilename;
-        }
-
-        public File[] getDynamicFiles() {
-            return getFilesWithPrefix("zoo.cfg.dynamic");
-        }
-
-        public File[] getFilesWithPrefix(final String prefix) {
-            return tmpDir.listFiles(new FilenameFilter() {      
-                @Override
-                public boolean accept(File dir, String name) {
-                    return name.startsWith(prefix);
-                }});
-        }
-
-        public File getFileByName(String filename) {
-            File f = new File(tmpDir.getPath(), filename);
-            return f.isFile() ? f : null;
-        }
-
-        public void writeTempDynamicConfigFile(String nextQuorumCfgSection, String version)
-                throws IOException {
-            File nextDynamicConfigFile = new File(tmpDir,
-                    "zoo.cfg" + QuorumPeerConfig.nextDynamicConfigFileSuffix);
-            FileWriter fwriter = new FileWriter(nextDynamicConfigFile);
-            fwriter.write(nextQuorumCfgSection
-                    + "\n"
-                    + "version=" + version);
-            fwriter.flush();
-            fwriter.close();
-        }
-
-        public MainThread(int myid, int clientPort, String quorumCfgSection)
-                throws IOException {
-            this(myid, clientPort, quorumCfgSection,
-                    new HashMap<String, String>());
-        }
-
-        public MainThread(int myid, int clientPort, String quorumCfgSection,
-                          Map<String, String> otherConfigs) throws IOException {
-            this(myid, clientPort, quorumCfgSection, otherConfigs, 4000);
-        }
-
-        Thread currentThread;
-
-        synchronized public void start() {
-            main = getTestQPMain();
-            currentThread = new Thread(this);
-            currentThread.start();
-        }
-
-        public TestQPMain getTestQPMain() {
-            return new TestQPMain();
-        }
-
-        public void run() {
-            String args[] = new String[1];
-            args[0] = confFile.toString();
-            try {
-                main.initializeAndRun(args);
-            } catch (Exception e) {
-                // test will still fail even though we just log/ignore
-                LOG.error("unexpected exception in run", e);
-            } finally {
-                currentThread = null;
-            }
-        }
-
-        public void shutdown() throws InterruptedException {
-            Thread t = currentThread;
-            if (t != null && t.isAlive()) {
-                main.shutdown();
-                t.join(500);
-            }
-        }
-
-        public void join(long timeout) throws InterruptedException {
-            Thread t = currentThread;
-            if (t != null) {
-                t.join(timeout);
-            }
-        }
-
-        public boolean isAlive() {
-            Thread t = currentThread;
-            return t != null && t.isAlive();
-        }
-
-        public void reinitialize() throws IOException {
-            File dataDir = main.quorumPeer.getTxnFactory().getDataDir();
-            ClientBase.recursiveDelete(dataDir);
-            ClientBase.createInitializeFile(dataDir.getParentFile());
-        }
-
-        public boolean isQuorumPeerRunning() {
-            return main.quorumPeer != null;
-        }
-
-        public String getPropFromStaticFile(String key) throws IOException {
-            Properties props = new Properties();
-            props.load(new FileReader(confFile));
-            return props.getProperty(key, "");
-        }
-
-        public QuorumPeer getQuorumPeer() {
-            return main.quorumPeer;
-        }
-
-
-        public void deleteBaseDir() {
-            ClientBase.recursiveDelete(baseDir);
-        }
-
-        public int getMyid() {
-            return myid;
-        }
-
-        public int getClientPort() {
-            return clientPort;
-        }
-
-        public String getQuorumCfgSection() {
-            return quorumCfgSection;
-        }
-
-        public Map<String, String> getOtherConfigs() {
-            return otherConfigs;
-        }
-
-        public File getConfFile() {
-            return confFile;
-        }
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/test/org/apache/zookeeper/server/quorum/QuorumRequestPipelineTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/quorum/QuorumRequestPipelineTest.java b/src/java/test/org/apache/zookeeper/server/quorum/QuorumRequestPipelineTest.java
deleted file mode 100644
index 5fce0b4..0000000
--- a/src/java/test/org/apache/zookeeper/server/quorum/QuorumRequestPipelineTest.java
+++ /dev/null
@@ -1,193 +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.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import org.apache.zookeeper.AsyncCallback.VoidCallback;
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.TestableZooKeeper;
-import org.apache.zookeeper.ZooDefs.Ids;
-import org.apache.zookeeper.data.Stat;
-import org.apache.zookeeper.server.quorum.QuorumPeer.ServerState;
-import org.apache.zookeeper.test.QuorumBase;
-import org.apache.zookeeper.ZKParameterized;
-
-@RunWith(Parameterized.class)
-@Parameterized.UseParametersRunnerFactory(ZKParameterized.RunnerFactory.class)
-public class QuorumRequestPipelineTest extends QuorumBase {
-    protected ServerState serverState;
-    protected final CountDownLatch callComplete = new CountDownLatch(1);
-    protected boolean complete = false;
-    protected final static String PARENT_PATH = "/foo";
-    protected final static Set<String> CHILDREN = new HashSet<String>(Arrays.asList("1", "2", "3"));
-    protected final static String AUTH_PROVIDER = "digest";
-    protected final static byte[] AUTH = "hello".getBytes();
-    protected final static byte[] DATA = "Hint Water".getBytes();
-
-    protected TestableZooKeeper zkClient;
-
-    @Parameterized.Parameters
-    public static Collection<Object[]> data() {
-        return Arrays.asList(
-            new Object[][] {
-                {ServerState.LEADING},
-                {ServerState.FOLLOWING},
-                {ServerState.OBSERVING}});
-    }
-
-    public QuorumRequestPipelineTest(ServerState state) {
-        this.serverState = state;
-    }
-
-    @Before
-    public void setUp() throws Exception {
-        CountdownWatcher clientWatch = new CountdownWatcher();
-        super.setUp(true);
-        zkClient = createClient(clientWatch, getPeersMatching(serverState));
-        zkClient.addAuthInfo(AUTH_PROVIDER, AUTH);
-        clientWatch.waitForConnected(CONNECTION_TIMEOUT);
-    }
-
-    @After
-    public void tearDown() throws Exception {
-        zkClient.close();
-        super.tearDown();
-    }
-
-    private Stat create2EmptyNode(TestableZooKeeper zkClient, String path) throws Exception {
-        Stat stat = new Stat();
-        zkClient.create(path, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT, stat);
-        return stat;
-    }
-
-    @Test
-    public void testCreate() throws Exception {
-        zkClient.create(PARENT_PATH, DATA, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-        Assert.assertArrayEquals(
-            String.format("%s Node created (create) with expected value", serverState),
-            DATA,
-            zkClient.getData(PARENT_PATH, false, null));
-    }
-
-    @Test
-    public void testCreate2() throws Exception {
-        zkClient.create(PARENT_PATH, DATA, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT, null);
-        Assert.assertArrayEquals(
-            String.format("%s Node created (create2) with expected value", serverState),
-            DATA,
-            zkClient.getData(PARENT_PATH, false, null));
-    }
-
-    @Test
-    public void testDelete() throws Exception {
-        create2EmptyNode(zkClient, PARENT_PATH);
-        zkClient.delete(PARENT_PATH, -1);
-        Assert.assertNull(
-            String.format("%s Node no longer exists", serverState),
-            zkClient.exists(PARENT_PATH, false));
-    }
-
-    @Test
-    public void testExists() throws Exception {
-        Stat stat = create2EmptyNode(zkClient, PARENT_PATH);
-        Assert.assertEquals(
-            String.format("%s Exists returns correct node stat", serverState),
-            stat,
-            zkClient.exists(PARENT_PATH, false));
-    }
-
-    @Test
-    public void testSetAndGetData() throws Exception {
-        create2EmptyNode(zkClient, PARENT_PATH);
-        zkClient.setData(PARENT_PATH, DATA, -1);
-        Assert.assertArrayEquals(
-            String.format("%s Node updated with expected value", serverState),
-            DATA,
-            zkClient.getData(PARENT_PATH, false, null));
-    }
-
-    @Test
-    public void testSetAndGetACL() throws Exception {
-        create2EmptyNode(zkClient, PARENT_PATH);
-        Assert.assertEquals(
-            String.format("%s Node has open ACL", serverState),
-            Ids.OPEN_ACL_UNSAFE,
-            zkClient.getACL(PARENT_PATH, new Stat()));
-        zkClient.setACL(PARENT_PATH, Ids.READ_ACL_UNSAFE, -1);
-        Assert.assertEquals(
-            String.format("%s Node has world read-only ACL", serverState),
-            Ids.READ_ACL_UNSAFE,
-            zkClient.getACL(PARENT_PATH, new Stat()));
-    }
-
-    @Test
-    public void testSetAndGetChildren() throws Exception {
-        create2EmptyNode(zkClient, PARENT_PATH);
-        for (String child : CHILDREN) {
-            create2EmptyNode(zkClient, PARENT_PATH + "/" + child);
-        }
-        Assert.assertEquals(
-            String.format("%s Parent has expected children", serverState),
-            CHILDREN,
-            new HashSet<String>(zkClient.getChildren(PARENT_PATH, false)));
-    }
-
-    @Test
-    public void testSetAndGetChildren2() throws Exception {
-        create2EmptyNode(zkClient, PARENT_PATH);
-        for (String child : CHILDREN) {
-            create2EmptyNode(zkClient, PARENT_PATH + "/" + child);
-        }
-        Assert.assertEquals(
-            String.format("%s Parent has expected children", serverState),
-            CHILDREN,
-            new HashSet<String>(zkClient.getChildren(PARENT_PATH, false, null)));
-    }
-
-    @Test
-    public void testSync() throws Exception {
-        complete = false;
-        create2EmptyNode(zkClient, PARENT_PATH);
-        VoidCallback onSync = new VoidCallback() {
-            @Override
-            public void processResult(int rc, String path, Object ctx) {
-                complete = true;
-                callComplete.countDown();
-            }
-        };
-        zkClient.sync(PARENT_PATH, onSync, null);
-        callComplete.await(30, TimeUnit.SECONDS);
-        Assert.assertTrue(
-            String.format("%s Sync completed", serverState),
-            complete);
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/test/org/apache/zookeeper/server/quorum/QuorumServerTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/quorum/QuorumServerTest.java b/src/java/test/org/apache/zookeeper/server/quorum/QuorumServerTest.java
deleted file mode 100644
index 78c16af..0000000
--- a/src/java/test/org/apache/zookeeper/server/quorum/QuorumServerTest.java
+++ /dev/null
@@ -1,86 +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 org.apache.zookeeper.ZKTestCase;
-import org.apache.zookeeper.server.quorum.QuorumPeer.QuorumServer;
-import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class QuorumServerTest extends ZKTestCase {
-    @Test
-    public void testToString() throws ConfigException {
-        String config = "127.0.0.1:1234:1236:participant;0.0.0.0:1237";
-        String expected = "127.0.0.1:1234:1236:participant;0.0.0.0:1237";
-        QuorumServer qs = new QuorumServer(0, config);
-        Assert.assertEquals("Use IP address", expected, qs.toString());
-
-        config = "127.0.0.1:1234:1236;0.0.0.0:1237";
-        expected = "127.0.0.1:1234:1236:participant;0.0.0.0:1237";
-        qs = new QuorumServer(0, config);
-        Assert.assertEquals("Type unspecified", expected, qs.toString());
-
-        config = "127.0.0.1:1234:1236:observer;0.0.0.0:1237";
-        expected = "127.0.0.1:1234:1236:observer;0.0.0.0:1237";
-        qs = new QuorumServer(0, config);
-        Assert.assertEquals("Observer type", expected, qs.toString());
-
-        config = "127.0.0.1:1234:1236:participant;1237";
-        expected = "127.0.0.1:1234:1236:participant;0.0.0.0:1237";
-        qs = new QuorumServer(0, config);
-        Assert.assertEquals("Client address unspecified",
-                            expected, qs.toString());
-
-        config = "127.0.0.1:1234:1236:participant;1.2.3.4:1237";
-        expected = "127.0.0.1:1234:1236:participant;1.2.3.4:1237";
-        qs = new QuorumServer(0, config);
-        Assert.assertEquals("Client address specified",
-                            expected, qs.toString());
-
-        config = "example.com:1234:1236:participant;1237";
-        expected = "example.com:1234:1236:participant;0.0.0.0:1237";
-        qs = new QuorumServer(0, config);
-        Assert.assertEquals("Use hostname", expected, qs.toString());
-    }
-
-    @Test
-    public void constructionUnderstandsIpv6LiteralsInServerConfig() throws ConfigException {
-        String config = "[::1]:1234:1236:participant";
-        QuorumServer qs = new QuorumServer(0, config);
-        assertEquals("[0:0:0:0:0:0:0:1]:1234:1236:participant", qs.toString());
-    }
-
-    @Test
-    public void constructionUnderstandsIpv6LiteralsInClientConfig() throws ConfigException {
-        String config = "127.0.0.1:1234:1236:participant;[::1]:1237";
-        QuorumServer qs = new QuorumServer(0, config);
-        assertEquals("127.0.0.1:1234:1236:participant;[0:0:0:0:0:0:0:1]:1237", qs.toString());
-    }
-
-    @Test(expected = ConfigException.class)
-    public void unbalancedIpv6LiteralsInServerConfigFailToBeParsed() throws ConfigException {
-        new QuorumServer(0, "[::1:1234:1236:participant");
-    }
-
-    @Test(expected = ConfigException.class)
-    public void unbalancedIpv6LiteralsInClientConfigFailToBeParsed() throws ConfigException {
-        new QuorumServer(0, "127.0.0.1:1234:1236:participant;[::1:1237");
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/test/org/apache/zookeeper/server/quorum/RaceConditionTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/quorum/RaceConditionTest.java b/src/java/test/org/apache/zookeeper/server/quorum/RaceConditionTest.java
deleted file mode 100644
index e96d273..0000000
--- a/src/java/test/org/apache/zookeeper/server/quorum/RaceConditionTest.java
+++ /dev/null
@@ -1,251 +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.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.net.SocketException;
-import java.nio.ByteBuffer;
-
-import org.apache.zookeeper.PortAssignment;
-import org.apache.zookeeper.ZooDefs;
-import org.apache.zookeeper.server.FinalRequestProcessor;
-import org.apache.zookeeper.server.PrepRequestProcessor;
-import org.apache.zookeeper.server.Request;
-import org.apache.zookeeper.server.RequestProcessor;
-import org.apache.zookeeper.server.SyncRequestProcessor;
-import org.apache.zookeeper.server.ZooKeeperServer;
-import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
-import org.apache.zookeeper.server.quorum.QuorumPeer.ServerState;
-import org.apache.zookeeper.test.ClientBase;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.security.sasl.SaslException;
-
-/**
- * This test class contains test cases related to race condition in complete
- * ZooKeeper
- */
-public class RaceConditionTest extends QuorumPeerTestBase {
-    protected static final Logger LOG = LoggerFactory.getLogger(RaceConditionTest.class);
-    private static int SERVER_COUNT = 3;
-    private MainThread[] mt;
-
-    /**
-     * Test case for https://issues.apache.org/jira/browse/ZOOKEEPER-2380.
-     * Deadlock while shutting down the ZooKeeper
-     */
-
-    @Test(timeout = 30000)
-    public void testRaceConditionBetweenLeaderAndAckRequestProcessor() throws Exception {
-        mt = startQuorum();
-        // get leader
-        QuorumPeer leader = getLeader(mt);
-        long oldLeaderCurrentEpoch = leader.getCurrentEpoch();
-        assertNotNull("Leader should not be null", leader);
-        // shutdown 2 followers so that leader does not have majority and goes
-        // into looking state or following/leading state.
-        shutdownFollowers(mt);
-        /**
-         * <pre>
-         * Verify that there is no deadlock in following ways:
-         * 1) If leader is in LOOKING or FOLLOWING, we are sure there is no deadlock.
-         * 2) If leader in in LEADING state then we have to check that this LEADING state is
-         * after the leader election, not the old LEADING state.
-         * </pre>
-         */
-        boolean leaderStateChanged = ClientBase.waitForServerState(leader, 15000,
-                QuorumStats.Provider.LOOKING_STATE, QuorumStats.Provider.FOLLOWING_STATE);
-        // Wait for the old leader to start completely
-        Assert.assertTrue("Failed to bring up the old leader server", ClientBase
-                .waitForServerUp("127.0.0.1:" + leader.getClientPort(), CONNECTION_TIMEOUT));
-        assertTrue(
-                "Leader failed to transition to new state. Current state is "
-                        + leader.getServerState(),
-                leaderStateChanged || (leader.getCurrentEpoch() > oldLeaderCurrentEpoch));
-    }
-
-    @After
-    public void tearDown() {
-        // stop all severs
-        if (null != mt) {
-            for (int i = 0; i < SERVER_COUNT; i++) {
-                try {
-                    // With the defect, leader hangs here also, but with fix
-                    // it does not
-                    mt[i].shutdown();
-                } catch (InterruptedException e) {
-                    LOG.warn("Quorum Peer interrupted while shutting it down", e);
-                }
-            }
-        }
-    }
-
-    private MainThread[] startQuorum() throws IOException {
-        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];
-
-        // start all the servers
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            mt[i] = new MainThread(i, clientPorts[i], currentQuorumCfgSection, false) {
-                @Override
-                public TestQPMain getTestQPMain() {
-                    return new MockTestQPMain();
-                }
-            };
-            mt[i].start();
-        }
-
-        // ensure all servers 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));
-        }
-        return mt;
-    }
-
-    private QuorumPeer getLeader(MainThread[] mt) {
-        for (int i = mt.length - 1; i >= 0; i--) {
-            QuorumPeer quorumPeer = mt[i].getQuorumPeer();
-            if (quorumPeer != null && ServerState.LEADING == quorumPeer.getPeerState()) {
-                return quorumPeer;
-            }
-        }
-        return null;
-    }
-
-    private void shutdownFollowers(MainThread[] mt) {
-        for (int i = 0; i < mt.length; i++) {
-            CustomQuorumPeer quorumPeer = (CustomQuorumPeer) mt[i].getQuorumPeer();
-            if (quorumPeer != null && ServerState.FOLLOWING == quorumPeer.getPeerState()) {
-                quorumPeer.setStopPing(true);
-            }
-        }
-    }
-
-    private static class CustomQuorumPeer extends QuorumPeer {
-        private boolean stopPing;
-
-        public CustomQuorumPeer() throws SaslException {
-        }
-
-        public void setStopPing(boolean stopPing) {
-            this.stopPing = stopPing;
-        }
-
-        @Override
-        protected Follower makeFollower(FileTxnSnapLog logFactory) throws IOException {
-
-            return new Follower(this, new FollowerZooKeeperServer(logFactory, this, this.getZkDb())) {
-                @Override
-                protected void processPacket(QuorumPacket qp) throws Exception {
-                    if (stopPing && qp.getType() == Leader.PING) {
-                        LOG.info("Follower skipped ping");
-                        throw new SocketException("Socket time out while sending the ping response");
-                    } else {
-                        super.processPacket(qp);
-                    }
-                }
-            };
-        }
-
-        @Override
-        protected Leader makeLeader(FileTxnSnapLog logFactory) throws IOException {
-            LeaderZooKeeperServer zk = new LeaderZooKeeperServer(logFactory, this, this.getZkDb()) {
-                @Override
-                protected void setupRequestProcessors() {
-                    /**
-                     * This method is overridden to make a place to inject
-                     * MockSyncRequestProcessor
-                     */
-                    RequestProcessor finalProcessor = new FinalRequestProcessor(this);
-                    RequestProcessor toBeAppliedProcessor = new Leader.ToBeAppliedRequestProcessor(finalProcessor,
-                            getLeader());
-                    commitProcessor = new CommitProcessor(toBeAppliedProcessor, Long.toString(getServerId()), false,
-                            getZooKeeperServerListener());
-                    commitProcessor.start();
-                    ProposalRequestProcessor proposalProcessor = new MockProposalRequestProcessor(this,
-                            commitProcessor);
-                    proposalProcessor.initialize();
-                    prepRequestProcessor = new PrepRequestProcessor(this, proposalProcessor);
-                    prepRequestProcessor.start();
-                    firstProcessor = new LeaderRequestProcessor(this, prepRequestProcessor);
-                }
-
-            };
-            return new Leader(this, zk);
-        }
-    }
-
-    private static class MockSyncRequestProcessor extends SyncRequestProcessor {
-
-        public MockSyncRequestProcessor(ZooKeeperServer zks, RequestProcessor nextProcessor) {
-            super(zks, nextProcessor);
-        }
-
-        @Override
-        public void shutdown() {
-            /**
-             * Add a request so that something is there for SyncRequestProcessor
-             * to process, while we are in shutdown flow
-             */
-            Request request = new Request(null, 0, 0, ZooDefs.OpCode.delete,
-                    ByteBuffer.wrap("/deadLockIssue".getBytes()), null);
-            processRequest(request);
-            super.shutdown();
-        }
-    }
-
-    private static class MockProposalRequestProcessor extends ProposalRequestProcessor {
-        public MockProposalRequestProcessor(LeaderZooKeeperServer zks, RequestProcessor nextProcessor) {
-            super(zks, nextProcessor);
-
-            /**
-             * The only purpose here is to inject the mocked
-             * SyncRequestProcessor
-             */
-            AckRequestProcessor ackProcessor = new AckRequestProcessor(zks.getLeader());
-            syncProcessor = new MockSyncRequestProcessor(zks, ackProcessor);
-        }
-    }
-
-    private static class MockTestQPMain extends TestQPMain {
-
-        @Override
-        protected QuorumPeer getQuorumPeer() throws SaslException {
-            return new CustomQuorumPeer();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/test/org/apache/zookeeper/server/quorum/ReconfigBackupTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/quorum/ReconfigBackupTest.java b/src/java/test/org/apache/zookeeper/server/quorum/ReconfigBackupTest.java
deleted file mode 100644
index 8bc04bd..0000000
--- a/src/java/test/org/apache/zookeeper/server/quorum/ReconfigBackupTest.java
+++ /dev/null
@@ -1,361 +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.PortAssignment;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.admin.ZooKeeperAdmin;
-import org.apache.zookeeper.common.StringUtils;
-import org.apache.zookeeper.test.ClientBase;
-import org.apache.zookeeper.test.ReconfigTest;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Properties;
-import java.util.Scanner;
-
-import static org.apache.zookeeper.test.ClientBase.CONNECTION_TIMEOUT;
-
-public class ReconfigBackupTest extends QuorumPeerTestBase {
-
-    public static String getVersionFromConfigStr(String config) throws IOException {
-        Properties props = new Properties();
-        props.load(new StringReader(config));
-        return props.getProperty("version", "");
-    }
-
-    // upgrade this once we have Google-Guava or Java 7+
-    public static String getFileContent(File file) throws FileNotFoundException {
-        Scanner sc = new Scanner(file);
-        StringBuilder sb = new StringBuilder();
-        while (sc.hasNextLine()) {
-            sb.append(sc.nextLine() + "\n");
-        }
-        return sb.toString();
-    }
-
-    @Before
-    public void setup() {
-        ClientBase.setupTestEnv();
-        System.setProperty("zookeeper.DigestAuthenticationProvider.superDigest",
-                "super:D/InIHSb7yEEbrWz8b9l71RjZJU="/* password is 'test'*/);
-    }
-
-    /**
-     * This test checks that it will backup static file on bootup.
-     */
-    @Test
-    public void testBackupStatic() throws Exception {
-        final int SERVER_COUNT = 3;
-        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 + "=localhost:" + PortAssignment.unique()
-                    + ":" + PortAssignment.unique() + ":participant;localhost:"
-                    + clientPorts[i];
-            sb.append(server + "\n");
-        }
-
-        String currentQuorumCfgSection = sb.toString();
-
-        MainThread mt[] = new MainThread[SERVER_COUNT];
-        String[] staticFileContent = new String[SERVER_COUNT];
-        String[] staticBackupContent = new String[SERVER_COUNT];
-
-        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.assertNull("static file backup shouldn't exist before bootup",
-                    mt[i].getFileByName("zoo.cfg.bak"));
-            staticFileContent[i] = getFileContent(mt[i].confFile);
-            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));
-            File backupFile = mt[i].getFileByName("zoo.cfg.bak");
-            Assert.assertNotNull("static file backup should exist", backupFile);
-            staticBackupContent[i] = getFileContent(backupFile);
-            Assert.assertEquals(staticFileContent[i], staticBackupContent[i]);
-        }
-
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            mt[i].shutdown();
-        }
-    }
-
-    /**
-     * This test checks that on reconfig, a new dynamic file will be created with
-     * current version appended to file name. Meanwhile, the dynamic file pointer
-     * in static config file should also be changed.
-     */
-    @Test
-    public void testReconfigCreateNewVersionFile() throws Exception {
-        final int SERVER_COUNT = 3;
-        final int NEW_SERVER_COUNT = 5;
-
-        final int clientPorts[] = new int[NEW_SERVER_COUNT];
-        final int quorumPorts[] = new int[NEW_SERVER_COUNT];
-        final int electionPorts[] = new int[NEW_SERVER_COUNT];
-        final String servers[] = new String[NEW_SERVER_COUNT];
-
-        StringBuilder sb = new StringBuilder();
-        ArrayList<String> oldServers = new ArrayList<String>();
-        ArrayList<String> newServers = new ArrayList<String>();
-
-        for (int i = 0; i < NEW_SERVER_COUNT; i++) {
-            clientPorts[i] = PortAssignment.unique();
-            quorumPorts[i] = PortAssignment.unique();
-            electionPorts[i] = PortAssignment.unique();
-            servers[i] = "server." + i + "=localhost:" + quorumPorts[i]
-                    + ":" + electionPorts[i] + ":participant;localhost:"
-                    + clientPorts[i];
-
-            newServers.add(servers[i]);
-
-            if (i >= SERVER_COUNT) {
-                continue;
-            }
-            oldServers.add(servers[i]);
-            sb.append(servers[i] + "\n");
-        }
-
-        String quorumCfgSection = sb.toString();
-
-        MainThread mt[] = new MainThread[NEW_SERVER_COUNT];
-        ZooKeeper zk[] = new ZooKeeper[NEW_SERVER_COUNT];
-        ZooKeeperAdmin zkAdmin[] = new ZooKeeperAdmin[NEW_SERVER_COUNT];
-
-        // start old cluster
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            mt[i] = new MainThread(i, clientPorts[i], quorumCfgSection, "reconfigEnabled=true\n");
-            mt[i].start();
-        }
-
-        String firstVersion = null, secondVersion = null;
-
-        // test old cluster
-        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());
-
-            Properties cfg = ReconfigLegacyTest.readPropertiesFromFile(mt[i].confFile);
-            String filename = cfg.getProperty("dynamicConfigFile", "");
-
-            String version = QuorumPeerConfig.getVersionFromFilename(filename);
-            Assert.assertNotNull(version);
-
-            String configStr = ReconfigTest.testServerHasConfig(
-                    zk[i], oldServers, null);
-
-            String configVersion = getVersionFromConfigStr(configStr);
-            // the version appended to filename should be the same as
-            // the one of quorum verifier.
-            Assert.assertEquals(version, configVersion);
-
-            if (i == 0) {
-                firstVersion = version;
-            } else {
-                Assert.assertEquals(firstVersion, version);
-            }
-        }
-
-        ReconfigTest.reconfig(zkAdmin[1], null, null, newServers, -1);
-
-        // start additional new servers
-        for (int i = SERVER_COUNT; i < NEW_SERVER_COUNT; i++) {
-            mt[i] = new MainThread(i, clientPorts[i], quorumCfgSection + servers[i]);
-            mt[i].start();
-        }
-
-        // wait for new servers to be up running
-        for (int i = SERVER_COUNT; i < NEW_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]);
-        }
-
-        // test that all servers have:
-        // a different, larger version dynamic file
-        for (int i = 0; i < NEW_SERVER_COUNT; i++) {
-            Properties cfg = ReconfigLegacyTest.readPropertiesFromFile(mt[i].confFile);
-            String filename = cfg.getProperty("dynamicConfigFile", "");
-
-            String version = QuorumPeerConfig.getVersionFromFilename(filename);
-            Assert.assertNotNull(version);
-
-            String configStr = ReconfigTest.testServerHasConfig(zk[i],
-                    newServers, null);
-
-            String quorumVersion = getVersionFromConfigStr(configStr);
-            Assert.assertEquals(version, quorumVersion);
-
-            if (i == 0) {
-                secondVersion = version;
-                Assert.assertTrue(
-                        Long.parseLong(secondVersion, 16)
-                                > Long.parseLong(firstVersion, 16));
-            } else {
-                Assert.assertEquals(secondVersion, version);
-            }
-        }
-
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            mt[i].shutdown();
-            zk[i].close();
-            zkAdmin[i].close();
-        }
-    }
-
-    /**
-     * This test checks that if a version is appended to dynamic file,
-     * then peer should use that version as quorum config version.
-     * <p/>
-     * The scenario: one server has an older version of 3 servers, and
-     * four others have newer version of 5 servers. Finally, the lag-off one
-     * should have server config of 5 servers.
-     */
-    @Test
-    public void testVersionOfDynamicFilename() throws Exception {
-        final int SERVER_COUNT = 5;
-        final int oldServerCount = 3;
-        final int lagOffServerId = 0;
-        final int clientPorts[] = new int[SERVER_COUNT];
-        StringBuilder sb = new StringBuilder();
-        String server;
-        StringBuilder oldSb = new StringBuilder();
-        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];
-            sb.append(server + "\n");
-            allServers.add(server);
-
-            if (i < oldServerCount) {
-                // only take in the first 3 servers as old quorum config.
-                oldSb.append(server + "\n");
-            }
-        }
-
-        String currentQuorumCfgSection = sb.toString();
-
-        String oldQuorumCfg = oldSb.toString();
-
-        MainThread mt[] = new MainThread[SERVER_COUNT];
-
-
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            if (i == lagOffServerId) {
-                mt[i] = new MainThread(i, clientPorts[i], oldQuorumCfg, true, "100000000");
-            } else {
-                mt[i] = new MainThread(i, clientPorts[i], currentQuorumCfgSection,
-                        true, "200000000");
-            }
-
-            // before connecting to quorum, servers should have set up dynamic file
-            // version and pointer. And the lag-off server is using the older
-            // version dynamic file.
-            if (i == lagOffServerId) {
-                Assert.assertNotNull(
-                        mt[i].getFileByName("zoo.cfg.dynamic.100000000"));
-                Assert.assertNull(
-                        mt[i].getFileByName("zoo.cfg.dynamic.200000000"));
-                Assert.assertTrue(
-                        mt[i].getPropFromStaticFile("dynamicConfigFile")
-                                .endsWith(".100000000"));
-            } else {
-                Assert.assertNotNull(
-                        mt[i].getFileByName("zoo.cfg.dynamic.200000000"));
-                Assert.assertTrue(
-                        mt[i].getPropFromStaticFile("dynamicConfigFile")
-                                .endsWith(".200000000"));
-            }
-
-            mt[i].start();
-        }
-
-        String dynamicFileContent = null;
-
-        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[i]);
-
-            // we should see that now all servers have the same config of 5 servers
-            // including the lag-off server.
-            String configStr = ReconfigTest.testServerHasConfig(zk, allServers, null);
-            Assert.assertEquals("200000000", getVersionFromConfigStr(configStr));
-            
-            List<String> configLines = Arrays.asList(configStr.split("\n"));
-            Collections.sort(configLines);
-            String sortedConfigStr = StringUtils.joinStrings(configLines, "\n");
-            
-             File dynamicConfigFile = mt[i].getFileByName("zoo.cfg.dynamic.200000000");
-             Assert.assertNotNull(dynamicConfigFile);
-
-            // All dynamic files created with the same version should have
-            // same configs, and they should be equal to the config we get from QuorumPeer.
-            if (i == 0) {
-                dynamicFileContent = getFileContent(dynamicConfigFile);                
-                Assert.assertEquals(sortedConfigStr, dynamicFileContent + 
-                        "version=200000000");
-            } else {
-                String otherDynamicFileContent = getFileContent(dynamicConfigFile);
-                Assert.assertEquals(dynamicFileContent, otherDynamicFileContent);
-            }
-
-            zk.close();
-        }
-
-        // finally, we should also check that the lag-off server has updated
-        // the dynamic file pointer.
-        Assert.assertTrue(
-                mt[lagOffServerId].getPropFromStaticFile("dynamicConfigFile")
-                        .endsWith(".200000000"));
-
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            mt[i].shutdown();
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/test/org/apache/zookeeper/server/quorum/ReconfigDuringLeaderSyncTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/server/quorum/ReconfigDuringLeaderSyncTest.java b/src/java/test/org/apache/zookeeper/server/quorum/ReconfigDuringLeaderSyncTest.java
deleted file mode 100644
index f350abf..0000000
--- a/src/java/test/org/apache/zookeeper/server/quorum/ReconfigDuringLeaderSyncTest.java
+++ /dev/null
@@ -1,269 +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.assertFalse;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.Map;
-
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.PortAssignment;
-import org.apache.zookeeper.ZooDefs;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.admin.ZooKeeperAdmin;
-import org.apache.zookeeper.server.ServerCnxnFactory;
-import org.apache.zookeeper.server.admin.AdminServer.AdminServerException;
-import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
-import org.apache.zookeeper.server.quorum.flexible.QuorumMaj;
-import org.apache.zookeeper.test.ClientBase;
-import org.apache.zookeeper.test.ClientBase.CountdownWatcher;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ReconfigDuringLeaderSyncTest extends QuorumPeerTestBase {
-    protected static final Logger LOG = LoggerFactory.getLogger(ReconfigDuringLeaderSyncTest.class);
-    private static int SERVER_COUNT = 3;
-    private MainThread[] mt;
-
-    @Before
-    public void setup() {
-        System.setProperty("zookeeper.DigestAuthenticationProvider.superDigest",
-                "super:D/InIHSb7yEEbrWz8b9l71RjZJU="/* password is 'test'*/);
-        QuorumPeerConfig.setReconfigEnabled(true);
-    }
-
-    /**
-     * <pre>
-     * Test case for https://issues.apache.org/jira/browse/ZOOKEEPER-2172.
-     * Cluster crashes when reconfig a new node as a participant.
-     * </pre>
-     *
-     * This issue occurs when reconfig's PROPOSAL and COMMITANDACTIVATE come in
-     * between the snapshot and the UPTODATE. In this case processReconfig was
-     * not invoked on the newly added node, and zoo.cfg.dynamic.next wasn't
-     * deleted.
-     */
-
-    @Test
-    public void testDuringLeaderSync() throws Exception {
-        final int clientPorts[] = new int[SERVER_COUNT + 1];
-        StringBuilder sb = new StringBuilder();
-        String[] serverConfig = new String[SERVER_COUNT + 1];
-
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            clientPorts[i] = PortAssignment.unique();
-            serverConfig[i] = "server." + i + "=127.0.0.1:" + PortAssignment.unique() + ":" + PortAssignment.unique()
-                    + ":participant;127.0.0.1:" + clientPorts[i];
-            sb.append(serverConfig[i] + "\n");
-        }
-        String currentQuorumCfgSection = sb.toString();
-        mt = new MainThread[SERVER_COUNT + 1];
-
-        // start 3 servers
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            mt[i] = new MainThread(i, clientPorts[i], currentQuorumCfgSection, false);
-            mt[i].start();
-        }
-
-        // ensure all servers 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));
-        }
-        CountdownWatcher watch = new CountdownWatcher();
-        ZooKeeperAdmin preReconfigClient = new ZooKeeperAdmin("127.0.0.1:" + clientPorts[0],
-                ClientBase.CONNECTION_TIMEOUT, watch);
-        preReconfigClient.addAuthInfo("digest", "super:test".getBytes());
-        watch.waitForConnected(ClientBase.CONNECTION_TIMEOUT);
-
-        // new server joining
-        int joinerId = SERVER_COUNT;
-        clientPorts[joinerId] = PortAssignment.unique();
-        serverConfig[joinerId] = "server." + joinerId + "=127.0.0.1:" + PortAssignment.unique() + ":"
-                + PortAssignment.unique() + ":participant;127.0.0.1:" + clientPorts[joinerId];
-
-        // Find leader id.
-        int leaderId = -1;
-        for (int i = 0; i < SERVER_COUNT; i++) {
-            if (mt[i].main.quorumPeer.leader != null) {
-                leaderId = i;
-                break;
-            }
-        }
-        assertFalse(leaderId == -1);
-
-        // Joiner initial config consists of itself and the leader.
-        sb = new StringBuilder();
-        sb.append(serverConfig[leaderId] + "\n").append(serverConfig[joinerId] + "\n");
-
-        /**
-         * This server will delay the response to a NEWLEADER message, and run
-         * reconfig command so that message at this processed in bellow order
-         *
-         * <pre>
-         * NEWLEADER
-         * reconfig's PROPOSAL
-         * reconfig's COMMITANDACTIVATE
-         * UPTODATE
-         * </pre>
-         */
-        mt[joinerId] = new MainThread(joinerId, clientPorts[joinerId], sb.toString(), false) {
-            @Override
-            public TestQPMain getTestQPMain() {
-                return new MockTestQPMain();
-            }
-        };
-        mt[joinerId].start();
-        CustomQuorumPeer qp = getCustomQuorumPeer(mt[joinerId]);
-
-        // delete any already existing .next file
-        String nextDynamicConfigFilename = qp.getNextDynamicConfigFilename();
-        File nextDynaFile = new File(nextDynamicConfigFilename);
-        nextDynaFile.delete();
-
-        // call reconfig API when the new server has received
-        // Leader.NEWLEADER
-        while (true) {
-            if (qp.isNewLeaderMessage()) {
-                preReconfigClient.reconfigure(serverConfig[joinerId], null, null, -1, null, null);
-                break;
-            } else {
-                // sleep for 10 millisecond and then again check
-                Thread.sleep(10);
-            }
-        }
-        watch = new CountdownWatcher();
-        ZooKeeper postReconfigClient = new ZooKeeper("127.0.0.1:" + clientPorts[joinerId],
-                ClientBase.CONNECTION_TIMEOUT, watch);
-        watch.waitForConnected(ClientBase.CONNECTION_TIMEOUT);
-        // do one successful operation on the newly added node
-        postReconfigClient.create("/reconfigIssue", "".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-        assertFalse("zoo.cfg.dynamic.next is not deleted.", nextDynaFile.exists());
-
-        // verify that joiner has up-to-date config, including all four servers.
-        for (long j = 0; j <= SERVER_COUNT; j++) {
-            assertNotNull("server " + j + " is not present in the new quorum",
-                    qp.getQuorumVerifier().getVotingMembers().get(j));
-        }
-
-        // close clients
-        preReconfigClient.close();
-        postReconfigClient.close();
-    }
-
-    private static CustomQuorumPeer getCustomQuorumPeer(MainThread mt) {
-        while (true) {
-            QuorumPeer quorumPeer = mt.getQuorumPeer();
-            if (null != quorumPeer) {
-                return (CustomQuorumPeer) quorumPeer;
-            } else {
-                try {
-                    Thread.sleep(10);
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-    }
-
-    @After
-    public void tearDown() {
-        // stop all severs
-        if (null != mt) {
-            for (int i = 0; i < mt.length; i++) {
-                try {
-                    mt[i].shutdown();
-                } catch (InterruptedException e) {
-                    LOG.warn("Quorum Peer interrupted while shutting it down", e);
-                }
-            }
-        }
-    }
-
-    private static class CustomQuorumPeer extends QuorumPeer {
-        private boolean newLeaderMessage = false;
-
-        public CustomQuorumPeer(Map<Long, QuorumServer> quorumPeers, File snapDir, File logDir, int clientPort,
-                int electionAlg, long myid, int tickTime, int initLimit, int syncLimit)
-                throws IOException {
-            super(quorumPeers, snapDir, logDir, electionAlg, myid, tickTime, initLimit, syncLimit, false,
-                    ServerCnxnFactory.createFactory(new InetSocketAddress(clientPort), -1), new QuorumMaj(quorumPeers));
-        }
-
-        /**
-         * If true, after 100 millisecond NEWLEADER response is send to leader
-         *
-         * @return
-         */
-        public boolean isNewLeaderMessage() {
-            return newLeaderMessage;
-        }
-
-        @Override
-        protected Follower makeFollower(FileTxnSnapLog logFactory) throws IOException {
-
-            return new Follower(this, new FollowerZooKeeperServer(logFactory, this, this.getZkDb())) {
-
-                @Override
-                void writePacket(QuorumPacket pp, boolean flush) throws IOException {
-                    if (pp != null && pp.getType() == Leader.ACK) {
-                        newLeaderMessage = true;
-                        try {
-                            /**
-                             * Delaying the ACK message, a follower sends as
-                             * response to a NEWLEADER message, so that the
-                             * leader has a chance to send the reconfig and only
-                             * then the UPTODATE message.
-                             */
-                            Thread.sleep(100);
-                        } catch (InterruptedException e) {
-                            e.printStackTrace();
-                        }
-                    }
-                    super.writePacket(pp, flush);
-                }
-            };
-        }
-    }
-
-    private static class MockTestQPMain extends TestQPMain {
-        @Override
-        public void runFromConfig(QuorumPeerConfig config)
-                throws IOException, AdminServerException {
-            quorumPeer = new CustomQuorumPeer(config.getQuorumVerifier().getAllMembers(), config.getDataDir(),
-                    config.getDataLogDir(), config.getClientPortAddress().getPort(), config.getElectionAlg(),
-                    config.getServerId(), config.getTickTime(), config.getInitLimit(), config.getSyncLimit());
-            quorumPeer.setConfigFileName(config.getConfigFilename());
-            quorumPeer.start();
-            try {
-                quorumPeer.join();
-            } catch (InterruptedException e) {
-                LOG.warn("Quorum Peer interrupted", e);
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/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 a0b9760..0000000
--- a/src/java/test/org/apache/zookeeper/server/quorum/ReconfigFailureCasesTest.java
+++ /dev/null
@@ -1,287 +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 java.util.Set;
-
-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
-        Set<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();
-        }
-    }
-}


Mime
View raw message