You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2020/02/01 01:27:15 UTC

[GitHub] [helix] narendly opened a new pull request #712: Upgrade ZkTestBase with multi-ZK support

narendly opened a new pull request #712: Upgrade ZkTestBase with multi-ZK support
URL: https://github.com/apache/helix/pull/712
 
 
   ### Issues
   
   - [x] My PR addresses the following Helix issues and references them in the PR description:
   
   Resolves #711 
   
   ### Description
   
   - [x] Here are some details about my PR, including screenshots of any UI changes:
   
   Prior to instrumenting Helix APIs and components so that they would be aware of multiple ZKs for horizontal scalability, we need to have a way to run all integration tests involving ZooKeeper in different environments: one with a single ZK and another with multiple ZKs.
   Changelist:
   1. Implement the logic in ZkTestBase so that in conjunction with maven-surefire-plugin configs, there will be two executions of the test suite
   
   ### Tests
   
   - [x] The following tests are written for this issue:
   
   Manual testing by way of mvn test:
   
   [INFO]  T E S T S
   [INFO] -------------------------------------------------------
   [INFO] Running TestSuite
   Start zookeeper at localhost:2183 in thread main
   Start zookeeper at localhost:2184 in thread main
   Start zookeeper at localhost:2185 in thread main
   
   Spins up 3 ZKs as expected.
   
   - [ ] The following is the result of the "mvn test" command on the appropriate module:
   
   (Copy & paste the result of "mvn test")
   
   ### Commits
   
   - [x] My commits all reference appropriate Apache Helix GitHub issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Code Quality
   
   - [x] My diff has been formatted using helix-style.xml
   
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] NealSun96 commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support

Posted by GitBox <gi...@apache.org>.
NealSun96 commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support
URL: https://github.com/apache/helix/pull/712#discussion_r373748951
 
 

 ##########
 File path: helix-core/src/test/java/org/apache/helix/common/ZkTestBase.java
 ##########
 @@ -154,8 +215,29 @@ public void afterSuite() throws IOException {
       }
     }
 
+    // Close ZK-related resources
+    _gSetupTool.close();
+    _baseAccessor.close();
     _gZkClient.close();
     TestHelper.stopZkServer(_zkServer);
+
+    // If there are multiple ZooKeepers, close them all
+    if (System.getProperty(MULTI_ZK_PROPERTY_KEY) != null) {
+      for (int i = 0; i < _numZk; i++) {
+        if (_baseDataAccessorMap != null && _baseDataAccessorMap.containsKey(i)) {
+          _baseDataAccessorMap.get(i).close();
+        }
+        if (_clusterSetupMap != null && _clusterSetupMap.containsKey(i)) {
+          _clusterSetupMap.get(i).close();
+        }
+        if (_helixZkClientMap != null && _helixZkClientMap.containsKey(i)) {
+          _helixZkClientMap.get(i).close();
+        }
+        if (_zkServerMap != null && _zkServerMap.containsKey(i)) {
+          TestHelper.stopZkServer(_zkServerMap.get(i));
+        }
 
 Review comment:
   Nit: could use `values()` to close without `get()` and checking every time.  

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] narendly commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support in helix-core

Posted by GitBox <gi...@apache.org>.
narendly commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support in helix-core
URL: https://github.com/apache/helix/pull/712#discussion_r374866998
 
 

 ##########
 File path: helix-core/src/test/java/org/apache/helix/common/ZkTestBase.java
 ##########
 @@ -123,8 +136,45 @@ public void beforeSuite() throws Exception {
     System.setProperty("zookeeper.4lw.commands.whitelist", "*");
     System.setProperty(SystemPropertyKeys.CONTROLLER_MESSAGE_PURGE_DELAY, "3000");
 
+    // Start an in-memory ZooKeeper
     _zkServer = TestHelper.startZkServer(ZK_ADDR);
     AssertJUnit.assertNotNull(_zkServer);
+    HelixZkClient.ZkClientConfig clientConfig = new HelixZkClient.ZkClientConfig();
+    clientConfig.setZkSerializer(new ZNRecordSerializer());
+    _gZkClient = DedicatedZkClientFactory.getInstance()
+        .buildZkClient(new HelixZkClient.ZkConnectionConfig(ZK_ADDR), clientConfig);
+    _gSetupTool = new ClusterSetup(_gZkClient);
+    _baseAccessor = new ZkBaseDataAccessor<>(_gZkClient);
+    _numZk++; // Now we have 1 ZK
+
+    // If multi-ZooKeeper is enabled, start more ZKs
+    String multiZkConfig = System.getProperty(MULTI_ZK_PROPERTY_KEY);
+    if (multiZkConfig != null && multiZkConfig.equalsIgnoreCase(Boolean.TRUE.toString())) {
+      String numZkFromConfig = System.getProperty(NUM_ZK_PROPERTY_KEY);
+      if (numZkFromConfig != null) {
+        try {
+          int numZkFromConfigInt = Integer.parseInt(numZkFromConfig);
+          // Initialize maps to track multiple ZK servers
+          // Initialize maps to track multiple ZK servers
+          _zkServerMap = new HashMap<>();
+          _helixZkClientMap = new HashMap<>();
+          _clusterSetupMap = new HashMap<>();
+          _baseDataAccessorMap = new HashMap<>();
+          _zkServerMap.put(0, _zkServer);
+          _helixZkClientMap.put(0, _gZkClient);
+          _clusterSetupMap.put(0, _gSetupTool);
+          _baseDataAccessorMap.put(0, _baseAccessor);
 
 Review comment:
   Removed duplicate code

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] narendly commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support

Posted by GitBox <gi...@apache.org>.
narendly commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support
URL: https://github.com/apache/helix/pull/712#discussion_r373753849
 
 

 ##########
 File path: helix-core/src/test/java/org/apache/helix/common/ZkTestBase.java
 ##########
 @@ -154,8 +215,29 @@ public void afterSuite() throws IOException {
       }
     }
 
+    // Close ZK-related resources
+    _gSetupTool.close();
+    _baseAccessor.close();
     _gZkClient.close();
     TestHelper.stopZkServer(_zkServer);
+
+    // If there are multiple ZooKeepers, close them all
+    if (System.getProperty(MULTI_ZK_PROPERTY_KEY) != null) {
+      for (int i = 0; i < _numZk; i++) {
+        if (_baseDataAccessorMap != null && _baseDataAccessorMap.containsKey(i)) {
+          _baseDataAccessorMap.get(i).close();
+        }
+        if (_clusterSetupMap != null && _clusterSetupMap.containsKey(i)) {
+          _clusterSetupMap.get(i).close();
+        }
+        if (_helixZkClientMap != null && _helixZkClientMap.containsKey(i)) {
+          _helixZkClientMap.get(i).close();
+        }
+        if (_zkServerMap != null && _zkServerMap.containsKey(i)) {
+          TestHelper.stopZkServer(_zkServerMap.get(i));
+        }
 
 Review comment:
   Null checks are necessary, and your point about .values() is a matter of style.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] jiajunwang commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support in helix-core

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support in helix-core
URL: https://github.com/apache/helix/pull/712#discussion_r374844185
 
 

 ##########
 File path: helix-core/src/test/java/org/apache/helix/common/ZkTestBase.java
 ##########
 @@ -107,12 +109,23 @@
   private Map<String, Map<String, HelixZkClient>> _liveInstanceOwners = new HashMap<>();
 
   public static final String ZK_ADDR = "localhost:2183";
 
 Review comment:
   nit: ZK_ADD = ZK_PREFIX + ZK_START_PORT ?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] narendly merged pull request #712: Upgrade ZkTestBase with multi-ZK support in helix-core

Posted by GitBox <gi...@apache.org>.
narendly merged pull request #712: Upgrade ZkTestBase with multi-ZK support in helix-core
URL: https://github.com/apache/helix/pull/712
 
 
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] narendly commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support

Posted by GitBox <gi...@apache.org>.
narendly commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support
URL: https://github.com/apache/helix/pull/712#discussion_r373753849
 
 

 ##########
 File path: helix-core/src/test/java/org/apache/helix/common/ZkTestBase.java
 ##########
 @@ -154,8 +215,29 @@ public void afterSuite() throws IOException {
       }
     }
 
+    // Close ZK-related resources
+    _gSetupTool.close();
+    _baseAccessor.close();
     _gZkClient.close();
     TestHelper.stopZkServer(_zkServer);
+
+    // If there are multiple ZooKeepers, close them all
+    if (System.getProperty(MULTI_ZK_PROPERTY_KEY) != null) {
+      for (int i = 0; i < _numZk; i++) {
+        if (_baseDataAccessorMap != null && _baseDataAccessorMap.containsKey(i)) {
+          _baseDataAccessorMap.get(i).close();
+        }
+        if (_clusterSetupMap != null && _clusterSetupMap.containsKey(i)) {
+          _clusterSetupMap.get(i).close();
+        }
+        if (_helixZkClientMap != null && _helixZkClientMap.containsKey(i)) {
+          _helixZkClientMap.get(i).close();
+        }
+        if (_zkServerMap != null && _zkServerMap.containsKey(i)) {
+          TestHelper.stopZkServer(_zkServerMap.get(i));
+        }
 
 Review comment:
   Null checks are necessary, and the rest is a matter of style.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] narendly commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support

Posted by GitBox <gi...@apache.org>.
narendly commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support
URL: https://github.com/apache/helix/pull/712#discussion_r373753841
 
 

 ##########
 File path: pom.xml
 ##########
 @@ -633,11 +633,6 @@ under the License.
               </goals>
               <id>default-test</id>
               <phase>test</phase>
-              <configuration>
-                <systemPropertyVariables>
-                  <multiZk>false</multiZk>
-                </systemPropertyVariables>
-              </configuration>
 
 Review comment:
   Good point! I'll add the explicit check for the string value "true".

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] narendly commented on issue #712: Upgrade ZkTestBase with multi-ZK support in helix-core

Posted by GitBox <gi...@apache.org>.
narendly commented on issue #712: Upgrade ZkTestBase with multi-ZK support in helix-core
URL: https://github.com/apache/helix/pull/712#issuecomment-582092795
 
 
   This PR is ready to be merged, approved by @jiajunwang
   
   Upgrade ZkTestBase with multi-ZK support in helix-core
   -----
   Prior to instrumenting Helix APIs and components so that they would be aware of multiple ZKs for horizontal scalability, we need to have a way to run all integration tests involving ZooKeeper in different environments: one with a single ZK and another with multiple ZKs.
   Changelist:
   
   Implement the logic in ZkTestBase so that in conjunction with maven-surefire-plugin configs, there will be two executions of the test suite
   Remove system property variable from default-test since it's unnecessary

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] jiajunwang commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support in helix-core

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support in helix-core
URL: https://github.com/apache/helix/pull/712#discussion_r374844000
 
 

 ##########
 File path: helix-core/src/test/java/org/apache/helix/common/ZkTestBase.java
 ##########
 @@ -107,12 +109,23 @@
   private Map<String, Map<String, HelixZkClient>> _liveInstanceOwners = new HashMap<>();
 
   public static final String ZK_ADDR = "localhost:2183";
+  private static final String ZK_PREFIX = "localhost:";
+  private static final int ZK_START_PORT = 2183;
   protected static final String CLUSTER_PREFIX = "CLUSTER";
   protected static final String CONTROLLER_CLUSTER_PREFIX = "CONTROLLER_CLUSTER";
   protected final String CONTROLLER_PREFIX = "controller";
   protected final String PARTICIPANT_PREFIX = "localhost";
   private static final long MANUAL_GC_PAUSE = 4000L;
 
+  /*
+   * Multiple ZK references
+   */
+  protected int _numZk = 0;
 
 Review comment:
   Instead of multiple lists, can we have a class like a tuple in Python to hold the related objects? That would be much easier to use comparing if I need to remember the index in every test case.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] NealSun96 commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support

Posted by GitBox <gi...@apache.org>.
NealSun96 commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support
URL: https://github.com/apache/helix/pull/712#discussion_r373748835
 
 

 ##########
 File path: pom.xml
 ##########
 @@ -633,11 +633,6 @@ under the License.
               </goals>
               <id>default-test</id>
               <phase>test</phase>
-              <configuration>
-                <systemPropertyVariables>
-                  <multiZk>false</multiZk>
-                </systemPropertyVariables>
-              </configuration>
 
 Review comment:
   If someone expands the test environments and adds another environment, based on pom.xml content alone he/she might add `<multiZk>false</multiZk>`, then the if statement in ZkTestBase.java will be incorrectly triggered. Using boolean for the if statement seems better to me. 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] narendly commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support in helix-core

Posted by GitBox <gi...@apache.org>.
narendly commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support in helix-core
URL: https://github.com/apache/helix/pull/712#discussion_r374866634
 
 

 ##########
 File path: helix-core/src/test/java/org/apache/helix/common/ZkTestBase.java
 ##########
 @@ -107,12 +109,23 @@
   private Map<String, Map<String, HelixZkClient>> _liveInstanceOwners = new HashMap<>();
 
   public static final String ZK_ADDR = "localhost:2183";
 
 Review comment:
   Changed.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] narendly commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support

Posted by GitBox <gi...@apache.org>.
narendly commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support
URL: https://github.com/apache/helix/pull/712#discussion_r373753849
 
 

 ##########
 File path: helix-core/src/test/java/org/apache/helix/common/ZkTestBase.java
 ##########
 @@ -154,8 +215,29 @@ public void afterSuite() throws IOException {
       }
     }
 
+    // Close ZK-related resources
+    _gSetupTool.close();
+    _baseAccessor.close();
     _gZkClient.close();
     TestHelper.stopZkServer(_zkServer);
+
+    // If there are multiple ZooKeepers, close them all
+    if (System.getProperty(MULTI_ZK_PROPERTY_KEY) != null) {
+      for (int i = 0; i < _numZk; i++) {
+        if (_baseDataAccessorMap != null && _baseDataAccessorMap.containsKey(i)) {
+          _baseDataAccessorMap.get(i).close();
+        }
+        if (_clusterSetupMap != null && _clusterSetupMap.containsKey(i)) {
+          _clusterSetupMap.get(i).close();
+        }
+        if (_helixZkClientMap != null && _helixZkClientMap.containsKey(i)) {
+          _helixZkClientMap.get(i).close();
+        }
+        if (_zkServerMap != null && _zkServerMap.containsKey(i)) {
+          TestHelper.stopZkServer(_zkServerMap.get(i));
+        }
 
 Review comment:
   Null checks are necessary, and your point about .values() is a matter of style and I think either way is fine.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] narendly commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support in helix-core

Posted by GitBox <gi...@apache.org>.
narendly commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support in helix-core
URL: https://github.com/apache/helix/pull/712#discussion_r374866884
 
 

 ##########
 File path: helix-core/src/test/java/org/apache/helix/common/ZkTestBase.java
 ##########
 @@ -107,12 +109,23 @@
   private Map<String, Map<String, HelixZkClient>> _liveInstanceOwners = new HashMap<>();
 
   public static final String ZK_ADDR = "localhost:2183";
+  private static final String ZK_PREFIX = "localhost:";
+  private static final int ZK_START_PORT = 2183;
   protected static final String CLUSTER_PREFIX = "CLUSTER";
   protected static final String CONTROLLER_CLUSTER_PREFIX = "CONTROLLER_CLUSTER";
   protected final String CONTROLLER_PREFIX = "controller";
   protected final String PARTICIPANT_PREFIX = "localhost";
   private static final long MANUAL_GC_PAUSE = 4000L;
 
+  /*
+   * Multiple ZK references
+   */
+  protected int _numZk = 0;
 
 Review comment:
   Discussed offline.
   
   Making this 
   
   >   protected Map<String, ZkServer> _zkServerMap = new HashMap<>();
     protected Map<String, HelixZkClient> _helixZkClientMap = new HashMap<>();
     protected Map<String, ClusterSetup> _clusterSetupMap = new HashMap<>();
     protected Map<String, BaseDataAccessor> _baseDataAccessorMap = new HashMap<>();
   for the time being.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] jiajunwang commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support in helix-core

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support in helix-core
URL: https://github.com/apache/helix/pull/712#discussion_r374845269
 
 

 ##########
 File path: helix-core/src/test/java/org/apache/helix/common/ZkTestBase.java
 ##########
 @@ -123,8 +136,45 @@ public void beforeSuite() throws Exception {
     System.setProperty("zookeeper.4lw.commands.whitelist", "*");
     System.setProperty(SystemPropertyKeys.CONTROLLER_MESSAGE_PURGE_DELAY, "3000");
 
+    // Start an in-memory ZooKeeper
     _zkServer = TestHelper.startZkServer(ZK_ADDR);
     AssertJUnit.assertNotNull(_zkServer);
+    HelixZkClient.ZkClientConfig clientConfig = new HelixZkClient.ZkClientConfig();
+    clientConfig.setZkSerializer(new ZNRecordSerializer());
+    _gZkClient = DedicatedZkClientFactory.getInstance()
+        .buildZkClient(new HelixZkClient.ZkConnectionConfig(ZK_ADDR), clientConfig);
+    _gSetupTool = new ClusterSetup(_gZkClient);
+    _baseAccessor = new ZkBaseDataAccessor<>(_gZkClient);
+    _numZk++; // Now we have 1 ZK
+
+    // If multi-ZooKeeper is enabled, start more ZKs
+    String multiZkConfig = System.getProperty(MULTI_ZK_PROPERTY_KEY);
+    if (multiZkConfig != null && multiZkConfig.equalsIgnoreCase(Boolean.TRUE.toString())) {
+      String numZkFromConfig = System.getProperty(NUM_ZK_PROPERTY_KEY);
+      if (numZkFromConfig != null) {
+        try {
+          int numZkFromConfigInt = Integer.parseInt(numZkFromConfig);
+          // Initialize maps to track multiple ZK servers
+          // Initialize maps to track multiple ZK servers
+          _zkServerMap = new HashMap<>();
+          _helixZkClientMap = new HashMap<>();
+          _clusterSetupMap = new HashMap<>();
+          _baseDataAccessorMap = new HashMap<>();
+          _zkServerMap.put(0, _zkServer);
+          _helixZkClientMap.put(0, _gZkClient);
+          _clusterSetupMap.put(0, _gSetupTool);
+          _baseDataAccessorMap.put(0, _baseAccessor);
 
 Review comment:
   These are duplicate code. Can we just repeatedly call startZooKeeper() and return the tuple that I mentioned above for recording?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] narendly commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support

Posted by GitBox <gi...@apache.org>.
narendly commented on a change in pull request #712: Upgrade ZkTestBase with multi-ZK support
URL: https://github.com/apache/helix/pull/712#discussion_r373753841
 
 

 ##########
 File path: pom.xml
 ##########
 @@ -633,11 +633,6 @@ under the License.
               </goals>
               <id>default-test</id>
               <phase>test</phase>
-              <configuration>
-                <systemPropertyVariables>
-                  <multiZk>false</multiZk>
-                </systemPropertyVariables>
-              </configuration>
 
 Review comment:
   Good point! I'll add the check for the string value.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org