Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 038F2200BC1 for ; Wed, 16 Nov 2016 19:38:37 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 021E2160B08; Wed, 16 Nov 2016 18:38:37 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2141B160B02 for ; Wed, 16 Nov 2016 19:38:35 +0100 (CET) Received: (qmail 90591 invoked by uid 500); 16 Nov 2016 18:38:35 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 90582 invoked by uid 99); 16 Nov 2016 18:38:35 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Nov 2016 18:38:35 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id A06831A048E for ; Wed, 16 Nov 2016 18:38:34 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.219 X-Spam-Level: X-Spam-Status: No, score=-6.219 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id jEI_uCmMbWJQ for ; Wed, 16 Nov 2016 18:38:32 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 9F03E5F472 for ; Wed, 16 Nov 2016 18:38:31 +0000 (UTC) Received: (qmail 90546 invoked by uid 99); 16 Nov 2016 18:38:30 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Nov 2016 18:38:30 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9CECEE07ED; Wed, 16 Nov 2016 18:38:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bschuchardt@apache.org To: commits@geode.incubator.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: incubator-geode git commit: GEODE-2073 CI Failure: GMSHealthMonitorJUnitTest.testHMNextNeighborAfterTimeout Date: Wed, 16 Nov 2016 18:38:30 +0000 (UTC) archived-at: Wed, 16 Nov 2016 18:38:37 -0000 Repository: incubator-geode Updated Branches: refs/heads/develop 216a10917 -> bb7a5e218 GEODE-2073 CI Failure: GMSHealthMonitorJUnitTest.testHMNextNeighborAfterTimeout I modified the test to wait longer and not require that the "next neighbor" be an exact member but merely a different one than the initial "next neigbor". Also, the diagnostic test in the exception thrown by this method was including the JoinLeave membership view but that is null in these tests. Instead it needs to show the HealthMonitor's membership view. I added a method to GMSHealthMonitor to allow access to its view. Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/bb7a5e21 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/bb7a5e21 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/bb7a5e21 Branch: refs/heads/develop Commit: bb7a5e218e446e296df8f71b3578daf152ab0c8c Parents: 216a109 Author: Bruce Schuchardt Authored: Wed Nov 16 10:26:08 2016 -0800 Committer: Bruce Schuchardt Committed: Wed Nov 16 10:27:22 2016 -0800 ---------------------------------------------------------------------- .../membership/gms/fd/GMSHealthMonitor.java | 8 ++++ .../gms/fd/GMSHealthMonitorJUnitTest.java | 39 +++++++++++--------- 2 files changed, 30 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bb7a5e21/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitor.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitor.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitor.java index b04c6a1..e62fee8 100644 --- a/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitor.java +++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitor.java @@ -845,6 +845,14 @@ public class GMSHealthMonitor implements HealthMonitor, MessageHandler { setNextNeighbor(newView, null); } + /** + * this method is primarily for tests. The current view should be pulled from JoinLeave or the + * MembershipManager (which includes surprise members) + */ + public synchronized NetView getView() { + return currentView; + } + /*** * This method sets next neighbour which it needs to watch in current view. * http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/bb7a5e21/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java index 547a200..505c010 100644 --- a/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/distributed/internal/membership/gms/fd/GMSHealthMonitorJUnitTest.java @@ -74,6 +74,7 @@ public class GMSHealthMonitorJUnitTest { final long memberTimeout = 1000l; private int[] portRange = new int[] {0, 65535}; private boolean useGMSHealthMonitorTestClass = false; + private final int myAddressIndex = 3; @Before public void initMocks() throws UnknownHostException { @@ -124,8 +125,8 @@ public class GMSHealthMonitorJUnitTest { mockMembers.add(mbr); } } - when(joinLeave.getMemberID()).thenReturn(mockMembers.get(3)); - when(messenger.getMemberID()).thenReturn(mockMembers.get(3)); + when(joinLeave.getMemberID()).thenReturn(mockMembers.get(myAddressIndex)); + when(messenger.getMemberID()).thenReturn(mockMembers.get(myAddressIndex)); gmsHealthMonitor = new GMSHealthMonitorTest(); gmsHealthMonitor.init(services); gmsHealthMonitor.start(); @@ -161,30 +162,34 @@ public class GMSHealthMonitorJUnitTest { @Test public void testHMNextNeighborVerify() throws IOException { installAView(); - Assert.assertEquals(mockMembers.get(4), gmsHealthMonitor.getNextNeighbor()); + Assert.assertEquals(mockMembers.get(myAddressIndex + 1), gmsHealthMonitor.getNextNeighbor()); } - @Category(FlakyTest.class) // GEODE-2073 + // @Category(FlakyTest.class) // GEODE-2073 @Test public void testHMNextNeighborAfterTimeout() throws Exception { System.out.println("testHMNextNeighborAfterTimeout starting"); + installAView(); + InternalDistributedMember initialNeighbor = mockMembers.get(myAddressIndex + 1); // allow the monitor to give up on the initial "next neighbor" and // move on to the one after it - long giveup = System.currentTimeMillis() + memberTimeout + 1500; - InternalDistributedMember expected = mockMembers.get(5); + long giveup = System.currentTimeMillis() + (2 * memberTimeout) + 1500; InternalDistributedMember neighbor = gmsHealthMonitor.getNextNeighbor(); - while (System.currentTimeMillis() < giveup && neighbor != expected) { - Thread.sleep(5); + while (System.currentTimeMillis() < giveup && neighbor == initialNeighbor) { + Thread.sleep(50); neighbor = gmsHealthMonitor.getNextNeighbor(); } - // neighbor should change to 5th + // neighbor should change. In order to not be a flaky test we don't demand + // that it be myAddressIndex+2 but just require that the neighbor being + // monitored has changed System.out.println("testHMNextNeighborAfterTimeout ending"); - Assert.assertEquals( - "expected " + expected + " but found " + neighbor + ". view=" + joinLeave.getView(), - expected, neighbor); + Assert.assertNotNull(gmsHealthMonitor.getView()); + Assert.assertNotEquals("neighbor to not be " + neighbor + "; my ID is " + + mockMembers.get(myAddressIndex) + "; view=" + gmsHealthMonitor.getView(), + initialNeighbor, neighbor); } /** @@ -204,9 +209,9 @@ public class GMSHealthMonitorJUnitTest { } // neighbor should be same System.out.println("next neighbor is " + gmsHealthMonitor.getNextNeighbor() + "\nmy address is " - + mockMembers.get(3) + "\nview is " + joinLeave.getView()); + + mockMembers.get(myAddressIndex) + "\nview is " + joinLeave.getView()); - Assert.assertEquals(mockMembers.get(4), gmsHealthMonitor.getNextNeighbor()); + Assert.assertEquals(mockMembers.get(myAddressIndex + 1), gmsHealthMonitor.getNextNeighbor()); } /*** @@ -221,7 +226,7 @@ public class GMSHealthMonitorJUnitTest { Thread.sleep(3 * memberTimeout + 100); System.out.println("testSuspectMembersCalledThroughMemberCheckThread ending"); - assertTrue(gmsHealthMonitor.isSuspectMember(mockMembers.get(4))); + assertTrue(gmsHealthMonitor.isSuspectMember(mockMembers.get(myAddressIndex + 1))); Assert.assertTrue(gmsHealthMonitor.getStats().getHeartbeatRequestsSent() > 0); Assert.assertTrue(gmsHealthMonitor.getStats().getSuspectsSent() > 0); } @@ -231,7 +236,7 @@ public class GMSHealthMonitorJUnitTest { NetView v = new NetView(mockMembers.get(0), 2, mockMembers); // 3rd is current member - when(messenger.getMemberID()).thenReturn(mockMembers.get(3)); + when(messenger.getMemberID()).thenReturn(mockMembers.get(myAddressIndex)); gmsHealthMonitor.started(); gmsHealthMonitor.installView(v); @@ -400,7 +405,7 @@ public class GMSHealthMonitorJUnitTest { // coordinator as.add(sr); SuspectMembersMessage sm = new SuspectMembersMessage(recipient, as); - sm.setSender(mockMembers.get(4));// member 4 sends suspect message + sm.setSender(mockMembers.get(myAddressIndex + 1));// member 4 sends suspect message gmsHealthMonitor.processMessage(sm);