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 8C6D4200C61 for ; Tue, 25 Apr 2017 19:52:21 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 8B1C7160BBF; Tue, 25 Apr 2017 17:52:21 +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 DB7ED160B8E for ; Tue, 25 Apr 2017 19:52:20 +0200 (CEST) Received: (qmail 47111 invoked by uid 500); 25 Apr 2017 17:52:20 -0000 Mailing-List: contact commits-help@geode.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.apache.org Delivered-To: mailing list commits@geode.apache.org Received: (qmail 47102 invoked by uid 99); 25 Apr 2017 17:52:20 -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; Tue, 25 Apr 2017 17:52:20 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id EB585DFBC8; Tue, 25 Apr 2017 17:52:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: klund@apache.org To: commits@geode.apache.org Date: Tue, 25 Apr 2017 17:52:19 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [01/10] geode git commit: GEODE-2785: Fix a test issue to allow certain additional afterSecondary callbacks. [Forced Update!] archived-at: Tue, 25 Apr 2017 17:52:21 -0000 Repository: geode Updated Branches: refs/heads/feature/GEODE-2632-6-1 1025b009b -> 8ac3c0185 (forced update) GEODE-2785: Fix a test issue to allow certain additional afterSecondary callbacks. Project: http://git-wip-us.apache.org/repos/asf/geode/repo Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/673e768b Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/673e768b Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/673e768b Branch: refs/heads/feature/GEODE-2632-6-1 Commit: 673e768b6279d90d1a048762a5411f23cfff3a75 Parents: 9f8ba8d Author: eshu Authored: Mon Apr 24 17:56:50 2017 -0700 Committer: eshu Committed: Mon Apr 24 17:56:50 2017 -0700 ---------------------------------------------------------------------- .../cache/PartitionListenerDUnitTest.java | 42 +++++++++++++------- 1 file changed, 28 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode/blob/673e768b/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionListenerDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionListenerDUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionListenerDUnitTest.java index 7fd470f..882b1e9 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionListenerDUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/cache/PartitionListenerDUnitTest.java @@ -28,8 +28,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.apache.geode.cache.AttributesFactory; import org.apache.geode.cache.Cache; @@ -140,24 +142,36 @@ public class PartitionListenerDUnitTest extends JUnit4CacheTestCase { List afterSecondaryCalledForVM1 = getAfterSecondaryCallbackBucketIds(vm1, regionName); List afterSecondaryCalledForVM2 = getAfterSecondaryCallbackBucketIds(vm2, regionName); + // Eliminate the duplicate, prevent afterSecondary being called multiple times on the same + // bucket + Set afterSecondaryCalledForVM1Set = new HashSet(afterSecondaryCalledForVM1); + afterSecondaryCalledForVM1.removeAll(afterSecondaryCalledForVM1Set); + assertTrue( + "afterSecondary invoked more than once for bucket " + + (afterSecondaryCalledForVM1.isEmpty() ? " " : afterSecondaryCalledForVM1.get(0)), + afterSecondaryCalledForVM1.isEmpty()); + + Set afterSecondaryCalledForVM2Set = new HashSet(afterSecondaryCalledForVM2); + afterSecondaryCalledForVM2.removeAll(afterSecondaryCalledForVM2Set); + assertTrue( + "afterSecondary invoked more than once for bucket " + + (afterSecondaryCalledForVM2.isEmpty() ? " " : afterSecondaryCalledForVM2.get(0)), + afterSecondaryCalledForVM2.isEmpty()); + List newVm1ActualPrimaries = getPrimariesOn(vm1, regionName); List newVM2ActualPrimaries = getPrimariesOn(vm2, regionName); // calculate and verify expected afterSecondary calls - List bucketsThatRemainInVM1 = new ArrayList(vm1ActualPrimaries); - bucketsThatRemainInVM1.retainAll(newVm1ActualPrimaries); - // All previous primary bucket ids - all overlapping/retained current bucket ids = all the - // secondary buckets - int expectedAfterSecondaryCalls = vm1ActualPrimaries.size() - bucketsThatRemainInVM1.size(); - assertEquals(expectedAfterSecondaryCalls, afterSecondaryCalledForVM1.size()); - - List bucketsThatRemainInVM2 = new ArrayList(vm2ActualPrimaries); - bucketsThatRemainInVM2.retainAll(newVM2ActualPrimaries); - // All previous primary bucket ids - all overlapping/retained current bucket ids = all the - // secondary buckets - expectedAfterSecondaryCalls = vm2ActualPrimaries.size() - bucketsThatRemainInVM2.size(); - assertEquals(expectedAfterSecondaryCalls, afterSecondaryCalledForVM2.size()); - + List bucketsNoLongerPrimaryInVM1 = new ArrayList(vm1ActualPrimaries); + bucketsNoLongerPrimaryInVM1.removeAll(newVm1ActualPrimaries); + // GEODE-2785: it is possible a secondary bucket becomes primary during moving bucket stage, + // and it then become secondary during primary selection stage. This may cause additional + // afterSecondary callback being invoked. + assertTrue(afterSecondaryCalledForVM1Set.containsAll(bucketsNoLongerPrimaryInVM1)); + + List bucketsNoLongerPrimaryInVM2 = new ArrayList(vm2ActualPrimaries); + bucketsNoLongerPrimaryInVM2.removeAll(newVM2ActualPrimaries); + assertTrue(afterSecondaryCalledForVM2Set.containsAll(bucketsNoLongerPrimaryInVM2)); } protected DistributedMember createPR(VM vm, final String regionName, final boolean isAccessor)