Github user enixon commented on a diff in the pull request:
https://github.com/apache/zookeeper/pull/628#discussion_r220768593
--- Diff: src/java/test/org/apache/zookeeper/test/ObserverMasterTest.java
---
@@ -0,0 +1,764 @@
+/**
+ * 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.test;
+
+import static org.apache.zookeeper.test.ClientBase.CONNECTION_TIMEOUT;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.zookeeper.AsyncCallback;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.jmx.CommonNames;
+import org.apache.zookeeper.jmx.MBeanRegistry;
+import org.apache.zookeeper.jmx.ZKMBeanInfo;
+import org.apache.zookeeper.server.admin.Commands;
+import org.apache.zookeeper.server.quorum.DelayRequestProcessor;
+import org.apache.zookeeper.server.quorum.FollowerZooKeeperServer;
+import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
+import org.apache.zookeeper.server.util.PortForwarder;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.KeeperException.ConnectionLossException;
+import org.apache.zookeeper.PortAssignment;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.Watcher.Event.KeeperState;
+import org.apache.zookeeper.ZooDefs.Ids;
+import org.apache.zookeeper.ZooKeeper;
+import org.apache.zookeeper.ZooKeeper.States;
+import org.apache.zookeeper.admin.ZooKeeperAdmin;
+import org.apache.zookeeper.server.quorum.QuorumPeerTestBase;
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.management.Attribute;
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.InvalidAttributeValueException;
+import javax.management.MBeanException;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+import javax.management.RuntimeMBeanException;
+
+@RunWith(Parameterized.class)
+public class ObserverMasterTest extends QuorumPeerTestBase implements
Watcher{
+ protected static final Logger LOG =
LoggerFactory.getLogger(ObserverTest.class);
+
+ public ObserverMasterTest(Boolean testObserverMaster) {
+ this.testObserverMaster = testObserverMaster;
+ }
+
+ @Parameterized.Parameters
+ public static List<Object []> data() { return Arrays.asList(new Object
[][] {
+ {Boolean.TRUE},
+ {Boolean.FALSE}});
+ }
+
+ private Boolean testObserverMaster;
+
+ private CountDownLatch latch;
+ ZooKeeper zk;
+ private WatchedEvent lastEvent = null;
+
+ private int CLIENT_PORT_QP1;
+ private int CLIENT_PORT_QP2;
+ private int CLIENT_PORT_OBS;
+ private int OM_PORT;
+ private MainThread q1;
+ private MainThread q2;
+ private MainThread q3;
+
+ private PortForwarder setUp(final int omProxyPort) throws IOException {
--- End diff --
That method will not launch an Observer for us and to get a properly
configured Observer and PortForwarder out of the method, I would need to
refactor QuorumServer in QuorumPeerMainTest. Consolidation of the configuration
setup between ObserverMasterTest and QuorumPeerMainTest is nice to have but I
don't think it's critical for this patch.
---