Return-Path: X-Original-To: apmail-geode-commits-archive@minotaur.apache.org Delivered-To: apmail-geode-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 9D70B188C0 for ; Wed, 16 Mar 2016 21:13:58 +0000 (UTC) Received: (qmail 95771 invoked by uid 500); 16 Mar 2016 21:13:58 -0000 Delivered-To: apmail-geode-commits-archive@geode.apache.org Received: (qmail 95738 invoked by uid 500); 16 Mar 2016 21:13:58 -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 95728 invoked by uid 99); 16 Mar 2016 21:13:58 -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 Mar 2016 21:13:58 +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 1E28B1A0B0E for ; Wed, 16 Mar 2016 21:13:58 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.549 X-Spam-Level: X-Spam-Status: No, score=-3.549 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=-0.329] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id NKjAxu2sqoeo for ; Wed, 16 Mar 2016 21:13:56 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with SMTP id 8F3EA5FB06 for ; Wed, 16 Mar 2016 21:13:55 +0000 (UTC) Received: (qmail 95713 invoked by uid 99); 16 Mar 2016 21:13:55 -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 Mar 2016 21:13:55 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 01507DFA42; Wed, 16 Mar 2016 21:13:54 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: klund@apache.org To: commits@geode.incubator.apache.org Message-Id: <7c8fcea68a9449828b6649f18e118630@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-geode git commit: Overhaul dunit because it keeps leaving around a system causing later failures Date: Wed, 16 Mar 2016 21:13:54 +0000 (UTC) Repository: incubator-geode Updated Branches: refs/heads/feature/GEODE-1050 8a1a162a4 -> 1b60b46f7 Overhaul dunit because it keeps leaving around a system causing later failures Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/1b60b46f Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/1b60b46f Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/1b60b46f Branch: refs/heads/feature/GEODE-1050 Commit: 1b60b46f7728cdecb4cda3ca51e1eb294ea859a1 Parents: 8a1a162 Author: Kirk Lund Authored: Wed Mar 16 14:13:34 2016 -0700 Committer: Kirk Lund Committed: Wed Mar 16 14:13:34 2016 -0700 ---------------------------------------------------------------------- .../cache/tier/sockets/HABug36738DUnitTest.java | 174 +++++++------------ 1 file changed, 58 insertions(+), 116 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1b60b46f/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HABug36738DUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HABug36738DUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HABug36738DUnitTest.java index dfcd59f..a82061e 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HABug36738DUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/tier/sockets/HABug36738DUnitTest.java @@ -16,8 +16,9 @@ */ package com.gemstone.gemfire.internal.cache.tier.sockets; -import java.util.Iterator; -import java.util.Properties; +import static com.gemstone.gemfire.test.dunit.Invoke.*; +import static com.jayway.awaitility.Awaitility.*; +import static com.jayway.awaitility.Duration.*; import com.gemstone.gemfire.cache.AttributesFactory; import com.gemstone.gemfire.cache.Cache; @@ -25,23 +26,16 @@ import com.gemstone.gemfire.cache.CacheFactory; import com.gemstone.gemfire.cache.DataPolicy; import com.gemstone.gemfire.cache.MirrorType; import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.RegionAttributes; import com.gemstone.gemfire.cache.Scope; -import com.gemstone.gemfire.distributed.DistributedSystem; import com.gemstone.gemfire.internal.cache.EnumListenerEvent; import com.gemstone.gemfire.internal.cache.EventID; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; import com.gemstone.gemfire.internal.cache.HARegion; import com.gemstone.gemfire.internal.cache.LocalRegion; import com.gemstone.gemfire.internal.cache.ha.HAHelper; -import com.gemstone.gemfire.internal.cache.ha.HARegionQueue; -import com.gemstone.gemfire.internal.cache.tier.sockets.ClientProxyMembershipID; -import com.gemstone.gemfire.internal.cache.tier.sockets.ClientUpdateMessage; import com.gemstone.gemfire.test.dunit.DistributedTestCase; import com.gemstone.gemfire.test.dunit.Host; -import com.gemstone.gemfire.test.dunit.LogWriterUtils; import com.gemstone.gemfire.test.dunit.VM; -import com.gemstone.gemfire.test.dunit.Wait; /** * This is the bugtest for bug no. 36738. When Object of class @@ -52,141 +46,89 @@ import com.gemstone.gemfire.test.dunit.Wait; * 2. Perform put operations on HARegion with the value as ClientUpdateMessage. * 3. Create server2 and HARegion in it so that GII will happen. * 4. Perform get operations from server2. - * */ - -public class HABug36738DUnitTest extends DistributedTestCase -{ - - static VM server1 = null; - - static VM server2 = null; - - private static int NO_OF_PUTS = 10; +public class HABug36738DUnitTest extends DistributedTestCase { private static final String REGION_NAME = "HABug36738DUnitTest_Region"; + private static final String HAREGION_NAME = "haRegion"; + private static final int COUNT = 10; - protected static Cache cache = null; + private static Cache cache; - protected static HARegionQueue messageQueue = null; - - static Region haRegion = null; - - final static String HAREGION_NAME = "haRegion"; + private Region haRegion; public HABug36738DUnitTest(String name) { super(name); } @Override - public final void postSetUp() throws Exception { - final Host host = Host.getHost(0); - server1 = host.getVM(0); - server2 = host.getVM(1); - } - - @Override public final void preTearDown() throws Exception { - server1.invoke(() -> HABug36738DUnitTest.closeCache()); - server2.invoke(() -> HABug36738DUnitTest.closeCache()); - } - - public void testBug36768() throws Exception - { - createServer1(); - Wait.pause(10000); - server1.invoke(() -> HABug36738DUnitTest.checkRegionQueueSize()); - createServer2(); - server1.invoke(() -> HABug36738DUnitTest.checkRegionQueueSize()); - server2.invoke(() -> HABug36738DUnitTest.checkRegionQueueSize()); - server2.invoke(() -> HABug36738DUnitTest.printRecs()); + disconnectAllFromDS(); + invokeInEveryVM( () -> cache = null ); } - public static void printRecs() - { - HARegion region = (HARegion)cache.getRegion(Region.SEPARATOR - + HAHelper.getRegionQueueName(HAREGION_NAME)); - assertNotNull(region); - Iterator itr = region.keys().iterator(); - while (itr.hasNext()) { - Object key = itr.next(); - ClientUpdateMessage value = (ClientUpdateMessage)region.get(key); - LogWriterUtils.getLogWriter().info("key : " + key + "Value " + value.getValue()); - - } + public void testBug36768() throws Exception { + final VM server1 = Host.getHost(0).getVM(0); + final VM server2 = Host.getHost(0).getVM(1); - } + server1.invoke(() -> createServerCacheWithHAAndRegion()); + await().atMost(TEN_SECONDS).until( () -> regionExists(server1, HAREGION_NAME) ); + server1.invoke(() -> checkRegionQueueSize()); - // function to create server and region in it. - private void createServer1() throws Exception - { - server1.invoke(() -> HABug36738DUnitTest.createServerCache( new Boolean(true) )); - } + server2.invoke(() -> createServerCacheWithHA()); - // function to create server without region. - private void createServer2() throws Exception - { - server2.invoke(() -> HABug36738DUnitTest.createServerCache( new Boolean(false) )); + server1.invoke(() -> checkRegionQueueSize()); + server2.invoke(() -> checkRegionQueueSize()); } - public static void createServerCache(Boolean isRegion) throws Exception - { - new HABug36738DUnitTest("temp").createCache(new Properties()); - if (isRegion.booleanValue()) { - AttributesFactory factory = new AttributesFactory(); - factory.setScope(Scope.DISTRIBUTED_ACK); - factory.setEnableConflation(true); - factory.setDataPolicy(DataPolicy.REPLICATE); - RegionAttributes attrs = factory.createRegionAttributes(); - cache.createVMRegion(REGION_NAME, attrs); - + private void createServerCacheWithHAAndRegion() throws Exception { + createServerCacheWithHA(); + assertNotNull(cache); + assertNotNull(this.haRegion); + + final AttributesFactory factory = new AttributesFactory(); + factory.setScope(Scope.DISTRIBUTED_ACK); + factory.setEnableConflation(true); + factory.setDataPolicy(DataPolicy.REPLICATE); + + cache.createVMRegion(REGION_NAME, factory.createRegionAttributes()); + + for (int i = 0; i < COUNT; i++) { + ClientUpdateMessage clientMessage = new ClientUpdateMessageImpl( + EnumListenerEvent.AFTER_UPDATE, + (LocalRegion)this.haRegion, + null, + ("value" + i).getBytes(), + (byte)0x01, + null, + new ClientProxyMembershipID(), + new EventID(("memberID" + i).getBytes(), i, i)); + + this.haRegion.put(i, clientMessage); } + } - AttributesFactory factoryForHARegion = new AttributesFactory(); - factoryForHARegion.setMirrorType(MirrorType.KEYS_VALUES); - factoryForHARegion.setScope(Scope.DISTRIBUTED_ACK); - RegionAttributes ra = factoryForHARegion.createRegionAttributes(); - haRegion = HARegion.getInstance(HAREGION_NAME, (GemFireCacheImpl)cache, null, - ra); - - if (isRegion.booleanValue()) { - for (int i = 0; i < NO_OF_PUTS; i++) { - ClientUpdateMessage clientMessage = new ClientUpdateMessageImpl( - EnumListenerEvent.AFTER_UPDATE, (LocalRegion)haRegion, null, ("value" + i) - .getBytes(), (byte)0x01, null, new ClientProxyMembershipID(), - new EventID(("memberID" + i).getBytes(), i, i)); + private void createServerCacheWithHA() throws Exception { + cache = CacheFactory.create(getSystem()); - haRegion.put(new Long(i), clientMessage); - LogWriterUtils.getLogWriter().info("Putting in the message Queue"); + final AttributesFactory factory = new AttributesFactory(); + factory.setMirrorType(MirrorType.KEYS_VALUES); + factory.setScope(Scope.DISTRIBUTED_ACK); - } - } + haRegion = HARegion.getInstance(HAREGION_NAME, (GemFireCacheImpl) cache, null, factory.createRegionAttributes()); } - private void createCache(Properties props) throws Exception - { - DistributedSystem ds = getSystem(props); - assertNotNull(ds); - ds.disconnect(); - ds = getSystem(props); - cache = CacheFactory.create(ds); - assertNotNull(cache); + private void checkRegionQueueSize() { + final HARegion region = (HARegion) cache.getRegion(Region.SEPARATOR + HAHelper.getRegionQueueName(HAREGION_NAME)); + assertNotNull(region); + assertEquals(COUNT, region.size()); } - public static void closeCache() - { - if (cache != null && !cache.isClosed()) { - cache.close(); - cache.getDistributedSystem().disconnect(); - } + private boolean regionExists(final VM vm, final String name) { + return vm.invoke(() -> regionExists(name)); } - public static void checkRegionQueueSize() - { - HARegion region = (HARegion)cache.getRegion(Region.SEPARATOR - + HAHelper.getRegionQueueName(HAREGION_NAME)); - assertNotNull(region); - LogWriterUtils.getLogWriter().info("Size of the Queue : " + region.size()); - + private boolean regionExists(final String name) { + return cache.getRegion(Region.SEPARATOR + HAHelper.getRegionQueueName(HAREGION_NAME)) != null; } }