GEODE-364: CI failure in SingleHopStatsDUnitTest.testClientStatsPR

This failure could also happen with the other test in this class:  a
client does put() operations that force the scheduling of a fetch of
PR metadata.  The client asserts that the metadata has been fetched,
but since the fetching is asynchronous it's possible for the client
to complete its put() operations and execute the assertion before the
asynchronous operation has completed.

The fix adds a WaitCriterion for the assertion.


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/13ed25ea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/13ed25ea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/13ed25ea

Branch: refs/heads/feature/GEODE-217
Commit: 13ed25ea01d7785dfcff1b9dde90dbb970caff58
Parents: e4f0a96
Author: Bruce Schuchardt <bschucha...@pivotal.io>
Authored: Fri Jan 8 10:46:31 2016 -0800
Committer: Bruce Schuchardt <bschucha...@pivotal.io>
Committed: Fri Jan 8 10:46:31 2016 -0800

----------------------------------------------------------------------
 .../internal/cache/SingleHopStatsDUnitTest.java      | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/13ed25ea/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/SingleHopStatsDUnitTest.java
----------------------------------------------------------------------
diff --git 
a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/SingleHopStatsDUnitTest.java
 
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/SingleHopStatsDUnitTest.java
index 1ddd891..7467993 100644
--- 
a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/SingleHopStatsDUnitTest.java
+++ 
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/SingleHopStatsDUnitTest.java
@@ -358,7 +358,7 @@ public class SingleHopStatsDUnitTest extends CacheTestCase{
         }
         ClientMetadataService cms = ((GemFireCacheImpl)cache)
             .getClientMetadataService();
-        Map<String, ClientPartitionAdvisor> regionMetaData = cms
+        final Map<String, ClientPartitionAdvisor> regionMetaData = cms
             .getClientPRMetadata_TEST_ONLY();
         assertEquals(0, regionMetaData.size());
 
@@ -367,8 +367,17 @@ public class SingleHopStatsDUnitTest extends CacheTestCase{
           region.create(new Integer(i), "create" + i);
         }
         cms = ((GemFireCacheImpl)cache).getClientMetadataService();
-        regionMetaData = cms.getClientPRMetadata_TEST_ONLY();
-        assertEquals(1, regionMetaData.size());
+        // since PR metadata is fetched in a background executor thread
+        // we need to wait for it to arrive for a bit
+        waitForCriterion(new WaitCriterion(){
+          public boolean done() {
+            return regionMetaData.size() == 1;
+          }
+          public String description() {
+            return "waiting for metadata to arrive: " + regionMetaData;
+          }
+          
+        }, 30000, 500, true);
         assertTrue(regionMetaData.containsKey(region.getFullPath()));
         ClientPartitionAdvisor prMetaData = regionMetaData.get(region
             .getFullPath());

Reply via email to