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 73346185B5 for ; Tue, 11 Aug 2015 21:03:11 +0000 (UTC) Received: (qmail 674 invoked by uid 500); 11 Aug 2015 21:03:11 -0000 Delivered-To: apmail-geode-commits-archive@geode.apache.org Received: (qmail 639 invoked by uid 500); 11 Aug 2015 21:03:11 -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 630 invoked by uid 99); 11 Aug 2015 21:03:11 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Aug 2015 21:03:11 +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 DEA5B1A9CDA for ; Tue, 11 Aug 2015 21:03:10 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.791 X-Spam-Level: * X-Spam-Status: No, score=1.791 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id Op0xOWezrRaH for ; Tue, 11 Aug 2015 21:03:01 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with SMTP id 06C5A20F3F for ; Tue, 11 Aug 2015 21:03:01 +0000 (UTC) Received: (qmail 552 invoked by uid 99); 11 Aug 2015 21:03:00 -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, 11 Aug 2015 21:03:00 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C4819E05D6; Tue, 11 Aug 2015 21:03:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jasonhuynh@apache.org To: commits@geode.incubator.apache.org Message-Id: <35b9624f3aac4214a65bb1532b5fb7de@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-geode git commit: GEODE-116: CopyOnReadIndexDUnitTest.testPRQueryOnLocalNode fails assertion Date: Tue, 11 Aug 2015 21:03:00 +0000 (UTC) Repository: incubator-geode Updated Branches: refs/heads/develop 96fd856db -> 18bbd9b80 GEODE-116: CopyOnReadIndexDUnitTest.testPRQueryOnLocalNode fails assertion Use a wait criterion incase the indexes are async for some reason Check index size instead of local pr size when comparing instance counts Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/18bbd9b8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/18bbd9b8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/18bbd9b8 Branch: refs/heads/develop Commit: 18bbd9b8018d2332c073651dbaa99c07e2f6dba9 Parents: 96fd856 Author: Jason Huynh Authored: Tue Aug 11 14:01:15 2015 -0700 Committer: Jason Huynh Committed: Tue Aug 11 14:01:15 2015 -0700 ---------------------------------------------------------------------- .../index/CopyOnReadIndexDUnitTest.java | 68 ++++++++++++-------- 1 file changed, 41 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/18bbd9b8/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/CopyOnReadIndexDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/CopyOnReadIndexDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/CopyOnReadIndexDUnitTest.java index 11cce7e..61bb55d 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/CopyOnReadIndexDUnitTest.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache/query/internal/index/CopyOnReadIndexDUnitTest.java @@ -24,6 +24,7 @@ import com.gemstone.gemfire.cache.CommitConflictException; import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.client.ClientCache; import com.gemstone.gemfire.cache.client.ClientCacheFactory; +import com.gemstone.gemfire.cache.query.Index; import com.gemstone.gemfire.cache.query.Query; import com.gemstone.gemfire.cache.query.QueryService; import com.gemstone.gemfire.cache.query.QueryTestUtils; @@ -31,7 +32,6 @@ import com.gemstone.gemfire.cache.query.SelectResults; import com.gemstone.gemfire.cache.query.Struct; import com.gemstone.gemfire.cache.query.data.Portfolio; import com.gemstone.gemfire.cache.query.data.Position; -import com.gemstone.gemfire.cache.query.internal.DefaultQueryService; import com.gemstone.gemfire.cache.server.CacheServer; import com.gemstone.gemfire.cache30.CacheSerializableRunnable; import com.gemstone.gemfire.cache30.CacheTestCase; @@ -39,8 +39,8 @@ import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.internal.AvailablePortHelper; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; import com.gemstone.gemfire.internal.cache.PartitionedRegion; -import com.gemstone.gemfire.internal.cache.tier.sockets.CacheServerTestUtil; +import dunit.DistributedTestCase; import dunit.Host; import dunit.SerializableCallable; import dunit.SerializableRunnable; @@ -157,13 +157,14 @@ public class CopyOnReadIndexDUnitTest extends CacheTestCase { //operations we have done on this vm consist of: //numPortfoliosPerVM instances of Portfolio created for put operation //Due to index, we have deserialized all of the entries this vm currently host - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(),((PartitionedRegion)region).getLocalSize() + numPortfoliosPerVM , Portfolio.instanceCount.get()); + Index index = getCache().getQueryService().getIndex(region, "idIndex"); + DistributedTestCase.waitForCriterion(verifyPortfolioCount((int)index.getStatistics().getNumberOfValues() + numPortfoliosPerVM), 5000, 200, true); } else { //operations we have done on this vm consist of: //numPortfoliosPerVM instances of Portfolio created for put operation //We do not have an index, so we have not deserialized any values - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(), numPortfoliosPerVM , Portfolio.instanceCount.get()); + DistributedTestCase.waitForCriterion(verifyPortfolioCount(numPortfoliosPerVM), 5000, 200, true); } return null; } @@ -184,13 +185,14 @@ public class CopyOnReadIndexDUnitTest extends CacheTestCase { //operations we have done on this vm consist of: //numPortfoliosPerVM instances of Portfolio created for put operation //Due to index, we have deserialized all of the entries this vm currently host - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(), ((PartitionedRegion)region).getLocalSize() + numPortfoliosPerVM, Portfolio.instanceCount.get()); + Index index = getCache().getQueryService().getIndex(region, "idIndex"); + DistributedTestCase.waitForCriterion(verifyPortfolioCount((int)index.getStatistics().getNumberOfValues() + numPortfoliosPerVM), 5000, 200, true); } else { //operations we have done on this vm consist of: //numPortfoliosPerVM instances of Portfolio created for put operation //We do not have an index, so we have not deserialized any values - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(), numPortfoliosPerVM, Portfolio.instanceCount.get()); + DistributedTestCase.waitForCriterion(verifyPortfolioCount(numPortfoliosPerVM), 5000, 200, true); } return null; } @@ -219,14 +221,15 @@ public class CopyOnReadIndexDUnitTest extends CacheTestCase { //50 instances of Portfolio created for put operation //Due to index, we have deserialized all of the entries this vm currently host //Since we have deserialized and cached these values, we just need to add the number of results we did a copy of due to copy on read - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(), ((PartitionedRegion)region).getLocalSize() + numPortfoliosPerVM + numExpectedResults, Portfolio.instanceCount.get()); + Index index = getCache().getQueryService().getIndex(region, "idIndex"); + DistributedTestCase.waitForCriterion(verifyPortfolioCount((int)index.getStatistics().getNumberOfValues() + numPortfoliosPerVM + numExpectedResults), 5000, 200, true); } else { //operations we have done on this vm consist of: //50 instances of Portfolio created for put operation //Due to the query we deserialized the number of entries this vm currently hosts //We had to deserialized the results from the other data nodes when we iterated through the results as well as our own - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(),((PartitionedRegion)region).getLocalSize() + numExpectedResults + numPortfoliosPerVM , Portfolio.instanceCount.get()); + DistributedTestCase.waitForCriterion(verifyPortfolioCount((int)((PartitionedRegion)region).getLocalSize() + numExpectedResults + numPortfoliosPerVM), 5000, 200, true); } return null; } @@ -238,11 +241,11 @@ public class CopyOnReadIndexDUnitTest extends CacheTestCase { if (hasIndex) { //After vm0 executed the query, we already had the values deserialized in our cache //So it's the same total as before - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(), ((PartitionedRegion)region).getLocalSize() + numPortfoliosPerVM, Portfolio.instanceCount.get()); + DistributedTestCase.waitForCriterion(verifyPortfolioCount((int)((PartitionedRegion)region).getLocalSize() + numPortfoliosPerVM), 5000, 200, true); } else { //After vm0 executed the query, we had to deserialize the values in our vm - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(), ((PartitionedRegion)region).getLocalSize() + numPortfoliosPerVM, Portfolio.instanceCount.get()); + DistributedTestCase.waitForCriterion(verifyPortfolioCount((int)((PartitionedRegion)region).getLocalSize() + numPortfoliosPerVM), 5000, 200, true); } return null; } @@ -271,7 +274,8 @@ public class CopyOnReadIndexDUnitTest extends CacheTestCase { //50 instances of Portfolio created for put operation //Due to index, we have deserialized all of the entries this vm currently host //This is the second query, because we have deserialized and cached these values, we just need to add the number of results a second time - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(), ((PartitionedRegion)region).getLocalSize() + numExpectedResults + numExpectedResults + numPortfoliosPerVM, Portfolio.instanceCount.get()); + Index index = getCache().getQueryService().getIndex(region, "idIndex"); + DistributedTestCase.waitForCriterion(verifyPortfolioCount((int)index.getStatistics().getNumberOfValues() + numExpectedResults + numExpectedResults + numPortfoliosPerVM), 5000, 200, true); } else { //operations we have done on this vm consist of: @@ -279,7 +283,7 @@ public class CopyOnReadIndexDUnitTest extends CacheTestCase { //Due to index, we have deserialized all of the entries this vm currently host //This is the second query, because we have deserialized and cached these values, we just need to add the number of results a second time //Because we have no index, we have to again deserialize all the values that this vm is hosting - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(),((PartitionedRegion)region).getLocalSize() + ((PartitionedRegion)region).getLocalSize() + numExpectedResults + numExpectedResults + numPortfoliosPerVM, Portfolio.instanceCount.get()); + DistributedTestCase.waitForCriterion(verifyPortfolioCount((int)(((PartitionedRegion)region).getLocalSize() + ((PartitionedRegion)region).getLocalSize() + numExpectedResults + numExpectedResults + numPortfoliosPerVM)), 5000, 200, true); } return null; } @@ -333,7 +337,7 @@ public class CopyOnReadIndexDUnitTest extends CacheTestCase { } //We should have the same number of portfolio objects that we created for the put - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(), numPortfolios , Portfolio.instanceCount.get()); + DistributedTestCase.waitForCriterion(verifyPortfolioCount(numPortfolios), 5000, 200, true); return null; } }); @@ -342,7 +346,7 @@ public class CopyOnReadIndexDUnitTest extends CacheTestCase { public Object call() throws Exception { //At this point, we should only have serialized values in this vm Region region = getCache().getRegion("/portfolios"); - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(), 0, Portfolio.instanceCount.get()); + DistributedTestCase.waitForCriterion(verifyPortfolioCount(0), 0, 200, true); return null; } }); @@ -352,10 +356,10 @@ public class CopyOnReadIndexDUnitTest extends CacheTestCase { //There is an index for vm2, so we should have deserialized values at this point, Region region = getCache().getRegion("/portfolios"); if (hasIndex) { - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(), numPortfolios, Portfolio.instanceCount.get()); + DistributedTestCase.waitForCriterion(verifyPortfolioCount(numPortfolios), 0, 200, true); } else { - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(), 0, Portfolio.instanceCount.get()); + DistributedTestCase.waitForCriterion(verifyPortfolioCount(0), 0, 200, true); } return null; } @@ -397,7 +401,7 @@ public class CopyOnReadIndexDUnitTest extends CacheTestCase { //We have created puts from our previous callable //Now we have copied the results from the query - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(), numExpectedResults + numPortfolios, Portfolio.instanceCount.get()); + DistributedTestCase.waitForCriterion(verifyPortfolioCount(numExpectedResults + numPortfolios), 0, 200, true); return null; } }); @@ -425,8 +429,8 @@ public class CopyOnReadIndexDUnitTest extends CacheTestCase { } //first it must deserialize the portfolios in the replicated region //then we do a copy on read of these deserialized objects for the final result set - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(), numPortfolios + numExpectedResults, Portfolio.instanceCount.get()); - + DistributedTestCase.waitForCriterion(verifyPortfolioCount(numExpectedResults + numPortfolios), 0, 200, true); + results = (SelectResults) query.execute(); assertEquals(numExpectedResults, results.size()); for (Object o: results) { @@ -443,8 +447,7 @@ public class CopyOnReadIndexDUnitTest extends CacheTestCase { //we never created index on vm1 //so in this case, we always have to deserialize the value from the region - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(), numPortfolios * 2 + numExpectedResults * 2, Portfolio.instanceCount.get()); - + DistributedTestCase.waitForCriterion(verifyPortfolioCount(numPortfolios * 2 + numExpectedResults * 2), 0, 200, true); return null; } }); @@ -471,8 +474,7 @@ public class CopyOnReadIndexDUnitTest extends CacheTestCase { } } //with or without index, the values had to have been deserialized at one point - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(), numPortfolios + numExpectedResults, Portfolio.instanceCount.get()); - + DistributedTestCase.waitForCriterion(verifyPortfolioCount(numPortfolios + numExpectedResults), 0, 200, true); results = (SelectResults) query.execute(); assertEquals(numExpectedResults, results.size()); for (Object o: results) { @@ -492,12 +494,12 @@ public class CopyOnReadIndexDUnitTest extends CacheTestCase { //we have an index, so the values are already deserialized //total is now our original deserialization amount : numPortfolios //two query results copied. - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(), numPortfolios + numExpectedResults * 2, Portfolio.instanceCount.get()); + DistributedTestCase.waitForCriterion(verifyPortfolioCount(numPortfolios + numExpectedResults * 2), 0, 200, true); } else { //we never created index on vm1 //so in this case, we always have to deserialize the value from the region - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(), numPortfolios * 2 + numExpectedResults * 2, Portfolio.instanceCount.get()); + DistributedTestCase.waitForCriterion(verifyPortfolioCount(numPortfolios * 2 + numExpectedResults * 2), 0, 200, true); } return null; } @@ -524,7 +526,7 @@ public class CopyOnReadIndexDUnitTest extends CacheTestCase { } //with or without index, the values we put in the region were already deserialized values - assertEquals("Incorrect number of portfolio instances"+ Portfolio.instanceCount.get(),numExpectedResults * 2 + numPortfolios, Portfolio.instanceCount.get()); + DistributedTestCase.waitForCriterion(verifyPortfolioCount(numExpectedResults * 2 + numPortfolios), 0, 200, true); return null; } }); @@ -605,7 +607,19 @@ public class CopyOnReadIndexDUnitTest extends CacheTestCase { p.setProperty(DistributionConfig.LOCATORS_NAME, ""); return p; } - + + private WaitCriterion verifyPortfolioCount(final int expected) { + return new WaitCriterion() { + private int expectedCount = expected; + public boolean done() { + return expectedCount == Portfolio.instanceCount.get(); + } + + public String description() { + return "verifying number of object instances created"; + } + }; + } }