geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jche...@apache.org
Subject incubator-geode git commit: GEODE-493 CI failure: PartitionedRegionSingleHopDUnitTest.test_MetadataContents GEODE-699 PartitionedRegionSingleHopDUnitTest.test_MetadataServiceCallAccuracy
Date Sat, 14 May 2016 23:02:18 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop 08ef0c1ee -> 92805bbb9


GEODE-493 CI failure:
PartitionedRegionSingleHopDUnitTest.test_MetadataContents
GEODE-699
PartitionedRegionSingleHopDUnitTest.test_MetadataServiceCallAccuracy

Add a counter fetchTaskCount in ClientMetadataService to count the
number fetch task threads. Make sure the counter is increased before a
fetch task thread is scheduled. And decrease the counter when a thread
is done.

In the test, use Awaitility to make all fetch tasks threads are
completed, i.e. fetchTaskCount == 0, before the next step.


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

Branch: refs/heads/develop
Commit: 92805bbb97fb1bc62db906f61f89ba71ec66f2da
Parents: 08ef0c1
Author: Jianxia Chen <jchen@pivotal.io>
Authored: Sat May 14 15:59:32 2016 -0700
Committer: Jianxia Chen <jchen@pivotal.io>
Committed: Sat May 14 15:59:32 2016 -0700

----------------------------------------------------------------------
 .../client/internal/ClientMetadataService.java  | 31 ++++++++++++++++++--
 .../PartitionedRegionSingleHopDUnitTest.java    |  8 +++--
 2 files changed, 34 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92805bbb/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ClientMetadataService.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ClientMetadataService.java
b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ClientMetadataService.java
index ed26708..60318b0 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ClientMetadataService.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ClientMetadataService.java
@@ -72,7 +72,13 @@ public final class ClientMetadataService {
   /** random number generator used in pruning */
   private final Random rand = new Random();
   
-  private volatile boolean isMetadataStable = true; 
+  private volatile boolean isMetadataStable = true;
+
+  private boolean isMetadataRefreshed_TEST_ONLY = false;
+  
+  private int fetchTaskCount = 0;
+  
+  private final Object fetchTaskCountLock = new Object();
   
   public ClientMetadataService(Cache cache) {
     this.cache = cache;
@@ -528,6 +534,9 @@ public final class ClientMetadataService {
       }
     }
     else {
+      synchronized (fetchTaskCountLock){
+        fetchTaskCount++;
+      }
       Runnable fetchTask = new Runnable() {
         @SuppressWarnings("synthetic-access")
         public void run() {
@@ -544,6 +553,11 @@ public final class ClientMetadataService {
               logger.debug("An exception occurred while fetching metadata", e);
             }
           }
+          finally {
+            synchronized (fetchTaskCountLock){
+              fetchTaskCount--;
+            }
+          }
         }
       };
       SingleHopClientExecutor.submitTask(fetchTask);
@@ -630,6 +644,9 @@ public final class ClientMetadataService {
         }
       }
     } else {
+      synchronized (fetchTaskCountLock){
+        fetchTaskCount++;
+      }
       Runnable fetchTask = new Runnable() {
         @SuppressWarnings("synthetic-access")
         public void run() {
@@ -644,6 +661,11 @@ public final class ClientMetadataService {
               logger.debug("An exception occurred while fetching metadata", e);
             }
           }
+          finally {
+            synchronized (fetchTaskCountLock){
+              fetchTaskCount--;
+            }
+          }
         }
       };
       SingleHopClientExecutor.submitTask(fetchTask);
@@ -841,6 +863,9 @@ public final class ClientMetadataService {
     this.isMetadataStable = isMetadataStable;
   }
 
-  private boolean isMetadataRefreshed_TEST_ONLY = false;
-
+  public int getFetchTaskCount() {
+    synchronized(fetchTaskCountLock) {
+      return fetchTaskCount;
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/92805bbb/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionSingleHopDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionSingleHopDUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionSingleHopDUnitTest.java
index f79d6c6..65cc7eb 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionSingleHopDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionSingleHopDUnitTest.java
@@ -342,7 +342,6 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase
{
   // Put data, get data and make the metadata stable.
   // Now verify that metadata has all 8 buckets info.
   // Now update and ensure the fetch service is never called.
-  @Category(FlakyTest.class) // GEODE-493: random ports, waitForCriterions
   public void test_MetadataContents() {
     Integer port0 = (Integer)member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer(
1, 4 ));
     Integer port1 = (Integer)member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer(
1, 4 ));
@@ -368,7 +367,6 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase
{
   // once,
   // fetchservice has to be triggered.
   // Now put again from c2.There should be no hop at all.
-  @Category(FlakyTest.class) // GEODE-699: random ports, async actions, time sensitive
   public void test_MetadataServiceCallAccuracy() {
     Integer port0 = (Integer)member0.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer(
1, 4 ));
     Integer port1 = (Integer)member1.invoke(() -> PartitionedRegionSingleHopDUnitTest.createServer(
1, 4 ));
@@ -391,6 +389,9 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase
{
 
     Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> cms.isRefreshMetadataTestOnly()
== true);
 
+    //make sure all fetch tasks are completed
+    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> cms.getFetchTaskCount() ==
0);
+
     cms.satisfyRefreshMetadata_TEST_ONLY(false);
     region.put(new Integer(0), "create0");
     region.put(new Integer(1), "create1");
@@ -1973,6 +1974,9 @@ public class PartitionedRegionSingleHopDUnitTest extends CacheTestCase
{
 
   private void verifyMetadata() {
     ClientMetadataService cms = ((GemFireCacheImpl)cache).getClientMetadataService();
+    //make sure all fetch tasks are completed
+    Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> cms.getFetchTaskCount() ==
0);
+
     final Map<String, ClientPartitionAdvisor> regionMetaData = cms
         .getClientPRMetadata_TEST_ONLY();
     Awaitility.waitAtMost(60, TimeUnit.SECONDS).until(() -> (regionMetaData.size() ==
4));


Mime
View raw message