This is an automated email from the ASF dual-hosted git repository.

hulee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git


The following commit(s) were added to refs/heads/master by this push:
     new 380d519  Fix TestRebalancePipeline test (#1157)
380d519 is described below

commit 380d51919b587e56c3c44be557121cff83cd64f7
Author: Meng Zhang <[email protected]>
AuthorDate: Tue Jul 21 10:16:31 2020 -0700

    Fix TestRebalancePipeline test (#1157)
    
    In the test testDuplicateMsg from TestRebalancePipeline, currently an 
invalid session id is used.
    The wrong session id makes the following test and assertion meaningless. 
This PR uses the correct session id liveInstances.get(0).getEphemeralOwner() 
instead.
    
    Also, we found a NPE thrown during the pipeline, causing the pipeline to 
stop, due to the missing thread pool in setAsyncTasksThreadPool. This PR works 
around the issue by giving it a thread pool and adds an issue reference in the 
comment block.
---
 .../helix/controller/stages/TestRebalancePipeline.java      | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git 
a/helix-core/src/test/java/org/apache/helix/controller/stages/TestRebalancePipeline.java
 
b/helix-core/src/test/java/org/apache/helix/controller/stages/TestRebalancePipeline.java
index 04ed5cc..dde80c6 100644
--- 
a/helix-core/src/test/java/org/apache/helix/controller/stages/TestRebalancePipeline.java
+++ 
b/helix-core/src/test/java/org/apache/helix/controller/stages/TestRebalancePipeline.java
@@ -23,6 +23,8 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.UUID;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 import org.apache.helix.HelixAdmin;
 import org.apache.helix.HelixDataAccessor;
@@ -61,8 +63,12 @@ public class TestRebalancePipeline extends ZkUnitTestBase {
     HelixManager manager = new DummyClusterManager(clusterName, accessor);
     ClusterEvent event = new ClusterEvent(ClusterEventType.Unknown);
     event.addAttribute(AttributeName.helixmanager.name(), manager);
-    event.addAttribute(AttributeName.ControllerDataProvider.name(),
-        new ResourceControllerDataProvider());
+    ResourceControllerDataProvider dataCache = new 
ResourceControllerDataProvider();
+    // The AsyncTasksThreadPool needs to be set, otherwise to start pending 
message cleanup job
+    // will throw NPE and stop the pipeline. TODO: 
https://github.com/apache/helix/issues/1158
+    ExecutorService executorService = Executors.newSingleThreadExecutor();
+    dataCache.setAsyncTasksThreadPool(executorService);
+    event.addAttribute(AttributeName.ControllerDataProvider.name(), dataCache);
 
     final String resourceName = "testResource_dup";
     String[] resourceGroups = new String[] {
@@ -110,7 +116,7 @@ public class TestRebalancePipeline extends ZkUnitTestBase {
 
     // round2: updates node0 currentState to SLAVE but keep the
     // message, make sure controller should not send S->M until removal is done
-    setCurrentState(clusterName, "localhost_0", resourceName, resourceName + 
"_0", "session_1",
+    setCurrentState(clusterName, "localhost_0", resourceName, resourceName + 
"_0", liveInstances.get(0).getEphemeralOwner(),
         "SLAVE");
 
     runPipeline(event, dataRefresh);
@@ -122,6 +128,7 @@ public class TestRebalancePipeline extends ZkUnitTestBase {
 
     deleteLiveInstances(clusterName);
     deleteCluster(clusterName);
+    executorService.shutdown();
     System.out.println("END " + clusterName + " at " + new 
Date(System.currentTimeMillis()));
   }
 

Reply via email to