Return-Path: X-Original-To: apmail-helix-commits-archive@minotaur.apache.org Delivered-To: apmail-helix-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4DDEBE4A2 for ; Mon, 4 Feb 2013 22:40:54 +0000 (UTC) Received: (qmail 10898 invoked by uid 500); 4 Feb 2013 22:40:54 -0000 Delivered-To: apmail-helix-commits-archive@helix.apache.org Received: (qmail 10870 invoked by uid 500); 4 Feb 2013 22:40:54 -0000 Mailing-List: contact commits-help@helix.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@helix.incubator.apache.org Delivered-To: mailing list commits@helix.incubator.apache.org Received: (qmail 10848 invoked by uid 99); 4 Feb 2013 22:40:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Feb 2013 22:40:54 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 04 Feb 2013 22:40:53 +0000 Received: (qmail 10303 invoked by uid 99); 4 Feb 2013 22:40:33 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Feb 2013 22:40:32 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id B14D5829EC7; Mon, 4 Feb 2013 22:40:32 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: zzhang@apache.org To: commits@helix.incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [1/2] git commit: HELIX-41: fix intermittent test failures Message-Id: <20130204224032.B14D5829EC7@tyr.zones.apache.org> Date: Mon, 4 Feb 2013 22:40:32 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org 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 Authored: Mon Feb 4 14:40:01 2013 -0800 Committer: zzhang 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>(); + 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>(); - 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"));