helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zzh...@apache.org
Subject [1/2] git commit: HELIX-41: fix intermittent test failures
Date Mon, 04 Feb 2013 22:40:32 GMT
HELIX-41: fix intermittent test failures


Project: http://git-wip-us.apache.org/repos/asf/incubator-helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-helix/commit/f82ddf27
Tree: http://git-wip-us.apache.org/repos/asf/incubator-helix/tree/f82ddf27
Diff: http://git-wip-us.apache.org/repos/asf/incubator-helix/diff/f82ddf27

Branch: refs/heads/master
Commit: f82ddf27009eb4e92e9fed65d90e64a267524ed0
Parents: 18d2e63
Author: zzhang <zzhang5@uci.edu>
Authored: Mon Feb 4 14:40:01 2013 -0800
Committer: zzhang <zzhang5@uci.edu>
Committed: Mon Feb 4 14:40:01 2013 -0800

----------------------------------------------------------------------
 .../apache/helix/manager/zk/ZKHelixManager.java    |   12 ++-----
 .../helix/healthcheck/TestAlertFireHistory.java    |   25 ++++++++++----
 2 files changed, 21 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f82ddf27/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
index 18c3bd5..1ba8985 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
@@ -19,15 +19,6 @@ package org.apache.helix.manager.zk;
  * under the License.
  */
 
-import static org.apache.helix.HelixConstants.ChangeType.CONFIG;
-import static org.apache.helix.HelixConstants.ChangeType.CURRENT_STATE;
-import static org.apache.helix.HelixConstants.ChangeType.EXTERNAL_VIEW;
-import static org.apache.helix.HelixConstants.ChangeType.HEALTH;
-import static org.apache.helix.HelixConstants.ChangeType.IDEAL_STATE;
-import static org.apache.helix.HelixConstants.ChangeType.LIVE_INSTANCE;
-import static org.apache.helix.HelixConstants.ChangeType.MESSAGE;
-import static org.apache.helix.HelixConstants.ChangeType.MESSAGES_CONTROLLER;
-
 import java.lang.management.ManagementFactory;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
@@ -737,6 +728,9 @@ public class ZKHelixManager implements HelixManager
                                                       defaultParticipantErrorMessageHandlerFactory);
 
       // create a new leader-election handler for a new session
+      if (_leaderElectionHandler != null) {
+    	  _leaderElectionHandler.reset();
+      }
       _leaderElectionHandler =
             createCallBackHandler(new Builder(_clusterName).controller(),
                                   new DistClusterControllerElection(_zkConnectString),

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/f82ddf27/helix-core/src/test/java/org/apache/helix/healthcheck/TestAlertFireHistory.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/healthcheck/TestAlertFireHistory.java
b/helix-core/src/test/java/org/apache/helix/healthcheck/TestAlertFireHistory.java
index d8254bd..87151aa 100644
--- a/helix-core/src/test/java/org/apache/helix/healthcheck/TestAlertFireHistory.java
+++ b/helix-core/src/test/java/org/apache/helix/healthcheck/TestAlertFireHistory.java
@@ -206,14 +206,25 @@ public class TestAlertFireHistory extends ZkStandAloneCMTestBaseWithPropertyServ
     int [] metrics6 = {0, 0, 0, 0,0};
     setHealthData(metrics5, metrics6);
     task.run();
-    Thread.sleep(500);
-    history = helixDataAccessor.getProperty(keyBuilder.alertHistory()).getRecord();
+    
+    for (int i = 0; i < 10; i++) 
+    {
+        Thread.sleep(500);
+        history = helixDataAccessor.getProperty(keyBuilder.alertHistory()).getRecord();
+        recordMap = new TreeMap<String, Map<String, String>>();
+        recordMap.putAll( history.getMapFields());
+        lastRecord = recordMap.lastEntry().getValue();
+
+        if (history.getMapFields().size() == 3 + historySize && lastRecord.size()
== 6) {
+        	break;
+        }
+    }
+    
     // reset everything
-    Assert.assertEquals(history.getMapFields().size(), 3 + historySize);
-    recordMap = new TreeMap<String, Map<String, String>>();
-    recordMap.putAll( history.getMapFields());
-    lastRecord = recordMap.lastEntry().getValue();
-    Assert.assertTrue(lastRecord.size() == 6);
+    Assert.assertEquals(history.getMapFields().size(), 3 + historySize, 
+    		"expect history-map-field size is " + (3 + historySize) + ", but was " + history);
+    Assert.assertTrue(lastRecord.size() == 6, "expect last-record size is 6, but was " +
lastRecord);
+    
     Assert.assertTrue(lastRecord.get("(localhost_12918.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
     Assert.assertTrue(lastRecord.get("(localhost_12920.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
     Assert.assertTrue(lastRecord.get("(localhost_12920.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("OFF"));


Mime
View raw message