pkuwm commented on a change in pull request #765: Add DedicatedZkClient and update DedicatedZkClientFactory URL: https://github.com/apache/helix/pull/765#discussion_r381814186
########## File path: zookeeper-api/src/test/java/org/apache/helix/zookeeper/impl/client/ZkTestBase.java ########## @@ -0,0 +1,148 @@ +package org.apache.helix.zookeeper.impl.client; + +/* + * 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. + */ + +import java.io.File; +import java.io.IOException; +import java.lang.management.ManagementFactory; +import java.util.HashMap; +import java.util.Map; + +import javax.management.MBeanServerConnection; +import javax.management.ObjectName; + +import org.apache.commons.io.FileUtils; +import org.apache.helix.zookeeper.zkclient.IDefaultNameSpace; +import org.apache.helix.zookeeper.zkclient.ZkServer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.Assert; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeSuite; + + +/** + * Test base class for various integration tests with an in-memory ZooKeeper. + */ +public class ZkTestBase { + private static final Logger LOG = LoggerFactory.getLogger(ZkTestBase.class); + private static final MBeanServerConnection MBEAN_SERVER = + ManagementFactory.getPlatformMBeanServer(); + + // maven surefire-plugin's multiple ZK config keys + private static final String MULTI_ZK_PROPERTY_KEY = "multiZk"; + private static final String NUM_ZK_PROPERTY_KEY = "numZk"; + + protected static final String ZK_PREFIX = "localhost:"; + protected static final int ZK_START_PORT = 2183; Review comment: Double checked to verify my concern is valid. I think if we don't change the port, this zk could not be started at this port, because testng.xml in helix-core includes all helix packages: `<package name="org.apache.helix.*"/>` I think there are 3 options to solve this: 1. change the port to use a different one -- OK. but could create more zk servers during the tests. 2. if the port is already occupied by a running zk, we don't assert fail it but use current zk. -- Not that good. Could not get the zk server reference. 3. exclude `zookeeper` and also `rest` module in helix-core's testng.xml so all ZK servers would be shut down after all helix-core's tests. So zookeeper module can create its own ZK servers on the port 2183. -- I prefer this one so we don't create more zk servers during the tests. Cons: it takes time when restarting zk servers. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
