Github user anmolnar commented on a diff in the pull request: https://github.com/apache/zookeeper/pull/605#discussion_r215614171 --- Diff: src/java/test/org/apache/zookeeper/server/quorum/FuzzySnapshotRelatedTest.java --- @@ -0,0 +1,254 @@ +/** + * 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.util.HashMap; +import java.util.Map; +import javax.security.sasl.SaslException; + +import org.apache.jute.OutputArchive; +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.ZooKeeper.States; +import org.apache.zookeeper.data.Stat; +import org.apache.zookeeper.server.DataNode; +import org.apache.zookeeper.server.DataTree; +import org.apache.zookeeper.server.ZKDatabase; +import org.apache.zookeeper.server.ZooKeeperServer; +import org.apache.zookeeper.test.ClientBase; + +import org.junit.Assert; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Test cases used to catch corner cases due to fuzzy snapshot. + */ +public class FuzzySnapshotRelatedTest extends QuorumPeerTestBase { + + private static final Logger LOG = LoggerFactory.getLogger(FuzzySnapshotRelatedTest.class); + + MainThread[] mt = null; + ZooKeeper[] zk = null; + int leaderId; + int followerA; + + @Before + public void setup() throws Exception { --- End diff -- I see this initialization logic pretty much everywhere in unit tests. Do you think we can do some clever code sharing here with (for example) `QuorumPeerMainTest.java`? Private method `LaunchServers` does the same thing as far as I could see.
---