helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hu...@apache.org
Subject [helix] branch master updated: Fix NullPointerException for testCustomCodeRunner. (#581)
Date Sun, 17 Nov 2019 01:34:22 GMT
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 644a568  Fix NullPointerException for testCustomCodeRunner. (#581)
644a568 is described below

commit 644a5687fb27b879959c6a75cbefbc6395249d08
Author: Huizhi L <ihuizhi.lu@gmail.com>
AuthorDate: Sat Nov 16 17:34:11 2019 -0800

    Fix NullPointerException for testCustomCodeRunner. (#581)
    
    The new live instance doesn't have its instance config. This causes NullPointerException
when monitor is trying to get the instance config.
    Changelist:
    Add instance config for the new live instance.
---
 .../integration/TestHelixCustomCodeRunner.java     | 24 ++++++++--------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestHelixCustomCodeRunner.java
b/helix-core/src/test/java/org/apache/helix/integration/TestHelixCustomCodeRunner.java
index 4d8a3c6..819ee8f 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestHelixCustomCodeRunner.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestHelixCustomCodeRunner.java
@@ -20,18 +20,14 @@ package org.apache.helix.integration;
  */
 
 import java.util.Date;
+
 import org.apache.helix.HelixConstants.ChangeType;
-import org.apache.helix.HelixDataAccessor;
 import org.apache.helix.HelixManager;
 import org.apache.helix.NotificationContext;
-import org.apache.helix.PropertyKey.Builder;
 import org.apache.helix.TestHelper;
 import org.apache.helix.common.ZkTestBase;
 import org.apache.helix.integration.manager.ClusterControllerManager;
 import org.apache.helix.integration.manager.MockParticipantManager;
-import org.apache.helix.manager.zk.ZKHelixDataAccessor;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
-import org.apache.helix.model.LiveInstance;
 import org.apache.helix.participant.CustomCodeCallbackHandler;
 import org.apache.helix.participant.HelixCustomCodeRunner;
 import org.apache.helix.tools.ClusterStateVerifier;
@@ -109,15 +105,11 @@ public class TestHelixCustomCodeRunner extends ZkTestBase {
     Assert.assertTrue(_callback._isCallbackInvoked);
     _callback._isCallbackInvoked = false;
 
-    // add a new live instance
-    HelixDataAccessor accessor =
-        new ZKHelixDataAccessor(_clusterName, new ZkBaseDataAccessor<>(_gZkClient));
-    Builder keyBuilder = accessor.keyBuilder();
-
-    LiveInstance newLiveIns = new LiveInstance("newLiveInstance");
-    newLiveIns.setHelixVersion("0.6.0");
-    newLiveIns.setSessionId("randomSessionId");
-    accessor.setProperty(keyBuilder.liveInstance("newLiveInstance"), newLiveIns);
+    // add a new live instance and its instance config.
+    // instance name: localhost_1000
+    int[] newLiveInstance = new int[]{1000};
+    setupInstances(_clusterName, newLiveInstance);
+    setupLiveInstances(_clusterName, newLiveInstance);
 
     Thread.sleep(1000); // wait for the CALLBACK type callback to finish
     Assert.assertTrue(_callback._isCallbackInvoked);
@@ -127,8 +119,8 @@ public class TestHelixCustomCodeRunner extends ZkTestBase {
     for (int i = 0; i < nodeNb; i++) {
       participants[i].syncStop();
     }
-    accessor.removeProperty(keyBuilder.liveInstance("newLiveInstance"));
-    TestHelper.dropCluster(_clusterName, _gZkClient);
+    deleteLiveInstances(_clusterName);
+    deleteCluster(_clusterName);
 
     System.out.println("END " + _clusterName + " at " + new Date(System.currentTimeMillis()));
   }


Mime
View raw message