You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by sa...@apache.org on 2021/07/20 14:12:55 UTC

[geode] branch develop updated: GEODE-9070: Improve ClientServerSessionCacheDUnitTest and add additional logging (#6567)

This is an automated email from the ASF dual-hosted git repository.

sabbey37 pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 400dee1  GEODE-9070: Improve ClientServerSessionCacheDUnitTest and add additional logging (#6567)
400dee1 is described below

commit 400dee12fa2d35d59adb81655bf811898d311d6c
Author: Sarah <sa...@pivotal.io>
AuthorDate: Tue Jul 20 10:11:51 2021 -0400

    GEODE-9070: Improve ClientServerSessionCacheDUnitTest and add additional logging (#6567)
---
 .../util/ClientServerSessionCacheDUnitTest.java    | 80 +++++++++++-----------
 .../distributed/internal/DistributionImpl.java     |  6 +-
 2 files changed, 46 insertions(+), 40 deletions(-)

diff --git a/extensions/geode-modules/src/distributedTest/java/org/apache/geode/modules/util/ClientServerSessionCacheDUnitTest.java b/extensions/geode-modules/src/distributedTest/java/org/apache/geode/modules/util/ClientServerSessionCacheDUnitTest.java
index 87bd506..9b06cc3 100644
--- a/extensions/geode-modules/src/distributedTest/java/org/apache/geode/modules/util/ClientServerSessionCacheDUnitTest.java
+++ b/extensions/geode-modules/src/distributedTest/java/org/apache/geode/modules/util/ClientServerSessionCacheDUnitTest.java
@@ -49,7 +49,6 @@ import org.apache.geode.internal.cache.execute.metrics.FunctionStats;
 import org.apache.geode.internal.cache.execute.metrics.FunctionStatsManager;
 import org.apache.geode.modules.session.catalina.ClientServerSessionCache;
 import org.apache.geode.modules.session.catalina.SessionManager;
-import org.apache.geode.test.dunit.DistributedTestUtils;
 import org.apache.geode.test.dunit.VM;
 import org.apache.geode.test.dunit.rules.CacheRule;
 import org.apache.geode.test.dunit.rules.ClientCacheRule;
@@ -57,9 +56,9 @@ import org.apache.geode.test.dunit.rules.DistributedRule;
 
 public class ClientServerSessionCacheDUnitTest implements Serializable {
   private static final String SESSION_REGION_NAME = RegionHelper.NAME + "_sessions";
-  private CacheRule cacheRule = new CacheRule();
-  private DistributedRule distributedRule = new DistributedRule();
-  private ClientCacheRule clientCacheRule = new ClientCacheRule();
+  private final CacheRule cacheRule = new CacheRule();
+  private final DistributedRule distributedRule = new DistributedRule();
+  private final ClientCacheRule clientCacheRule = new ClientCacheRule();
 
   @Rule
   public transient RuleChain ruleChain = RuleChain.outerRule(distributedRule)
@@ -78,12 +77,12 @@ public class ClientServerSessionCacheDUnitTest implements Serializable {
 
     client.invoke(this::startClientSessionCache);
 
-    server0.invoke(this::validateServer);
-    server1.invoke(this::validateServer);
+    server0.invoke(() -> await().untilAsserted(this::validateServer));
+    server1.invoke(() -> await().untilAsserted(this::validateServer));
   }
 
   @Test
-  public void addServerToExistingClusterCreatesSessionRegion() {
+  public void addServerToExistingClusterCopiesSessionRegion() {
     final VM server0 = VM.getVM(0);
     final VM server1 = VM.getVM(1);
     final VM client = VM.getVM(2);
@@ -92,7 +91,7 @@ public class ClientServerSessionCacheDUnitTest implements Serializable {
 
     client.invoke(this::startClientSessionCache);
 
-    server0.invoke(this::validateServer);
+    server0.invoke(() -> await().untilAsserted(this::validateServer));
 
     server1.invoke(this::startCacheServer);
 
@@ -101,60 +100,62 @@ public class ClientServerSessionCacheDUnitTest implements Serializable {
   }
 
   @Test
-  public void startingAClientWithoutServersFails() {
-    final VM client = VM.getVM(2);
-
-    assertThatThrownBy(() -> client.invoke(this::startClientSessionCache))
-        .hasCauseInstanceOf(NoAvailableServersException.class);
-  }
-
-  @Test
-  public void canPreCreateSessionRegionBeforeStartingClient() {
+  public void addServerToExistingClusterDoesNotCopyPreCreatedSessionRegion() {
     final VM server0 = VM.getVM(0);
     final VM server1 = VM.getVM(1);
     final VM client = VM.getVM(2);
 
     server0.invoke(this::startCacheServer);
-    server1.invoke(this::startCacheServer);
-
     server0.invoke(this::createSessionRegion);
-    server1.invoke(this::createSessionRegion);
+    server0.invoke(() -> await().untilAsserted(this::validateSessionRegion));
 
     client.invoke(this::startClientSessionCache);
+    server1.invoke(this::startCacheServer);
+
+    server0.invoke(() -> await().untilAsserted(this::validateServer));
+    server1.invoke(() -> await().untilAsserted(this::validateBootstrapped));
+
+    // server1 should not have created the session region
+    // If the user precreated the region, they must manually
+    // create it on all servers
+    server1.invoke(() -> {
+      Region<Object, Object> region = cacheRule.getCache().getRegion(SESSION_REGION_NAME);
+      assertThat(region).isNull();
+    });
 
-    server0.invoke(this::validateServer);
-    server1.invoke(this::validateServer);
   }
 
   @Test
-  public void preCreatedRegionIsNotCopiedToNewlyStartedServers() {
+  public void startingAClientWithoutServersFails() {
+    final VM client = VM.getVM(2);
+
+    assertThatThrownBy(() -> client.invoke(this::startClientSessionCache))
+        .hasCauseInstanceOf(NoAvailableServersException.class);
+  }
+
+  @Test
+  public void canPreCreateSessionRegionBeforeStartingClient() {
     final VM server0 = VM.getVM(0);
     final VM server1 = VM.getVM(1);
     final VM client = VM.getVM(2);
 
     server0.invoke(this::startCacheServer);
-
+    server1.invoke(this::startCacheServer);
 
     server0.invoke(this::createSessionRegion);
+    server1.invoke(this::createSessionRegion);
 
+    server0.invoke(() -> await().untilAsserted(this::validateSessionRegion));
+    server1.invoke(() -> await().untilAsserted(this::validateSessionRegion));
 
     client.invoke(this::startClientSessionCache);
-    server1.invoke(this::startCacheServer);
-
-    server1.invoke(() -> await().untilAsserted(this::validateBootstrapped));
-
-    // server1 should not have created the session region
-    // If the user precreated the region, they must manually
-    // create it on all servers
-    server1.invoke(() -> {
-      Region<Object, Object> region = cacheRule.getCache().getRegion(SESSION_REGION_NAME);
-      assertThat(region).isNull();
-    });
 
+    server0.invoke(() -> await().untilAsserted(this::validateServer));
+    server1.invoke(() -> await().untilAsserted(this::validateServer));
   }
 
   @Test
-  public void cantPreCreateMismatchedSessionRegionBeforeStartingClient() {
+  public void cannotPreCreateMismatchedSessionRegionBeforeStartingClient() {
     final VM server0 = VM.getVM(0);
     final VM server1 = VM.getVM(1);
     final VM client = VM.getVM(2);
@@ -189,7 +190,7 @@ public class ClientServerSessionCacheDUnitTest implements Serializable {
           .thenReturn(RegionShortcut.PARTITION_REDUNDANT.toString());
 
       final ClientCacheFactory clientCacheFactory = new ClientCacheFactory();
-      clientCacheFactory.addPoolLocator("localhost", DistributedTestUtils.getLocatorPort());
+      clientCacheFactory.addPoolLocator("localhost", DistributedRule.getLocatorPort());
       clientCacheFactory.setPoolSubscriptionEnabled(true);
       clientCacheRule.createClientCache(clientCacheFactory);
 
@@ -233,7 +234,7 @@ public class ClientServerSessionCacheDUnitTest implements Serializable {
     final RegionAttributes<Object, Object> expectedAttributes =
         cache.getRegionAttributes(RegionShortcut.PARTITION_REDUNDANT.toString());
 
-    final RegionAttributes attributes = region.getAttributes();
+    final RegionAttributes<String, HttpSession> attributes = region.getAttributes();
     assertThat(attributes.getScope()).isEqualTo(expectedAttributes.getScope());
     assertThat(attributes.getDataPolicy()).isEqualTo(expectedAttributes.getDataPolicy());
     assertThat(attributes.getPartitionAttributes())
@@ -294,7 +295,7 @@ public class ClientServerSessionCacheDUnitTest implements Serializable {
         .thenReturn(RegionShortcut.PARTITION_REDUNDANT.toString());
 
     final ClientCacheFactory clientCacheFactory = new ClientCacheFactory();
-    clientCacheFactory.addPoolLocator("localhost", DistributedTestUtils.getLocatorPort());
+    clientCacheFactory.addPoolLocator("localhost", DistributedRule.getLocatorPort());
     clientCacheFactory.setPoolSubscriptionEnabled(true);
     clientCacheRule.createClientCache(clientCacheFactory);
 
@@ -307,5 +308,6 @@ public class ClientServerSessionCacheDUnitTest implements Serializable {
     final CacheServer cacheServer = cache.addCacheServer();
     cacheServer.setPort(0);
     cacheServer.start();
+    await().until(cacheServer::isRunning);
   }
 }
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionImpl.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionImpl.java
index 9c560fd..9b945a3 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionImpl.java
@@ -387,6 +387,11 @@ public class DistributionImpl implements Distribution {
         Throwable th = it_causes.next();
 
         if (!membership.hasMember(member) || (th instanceof ShunnedMemberException)) {
+          if (logger.isDebugEnabled()) {
+            logger
+                .debug(String.format("Failed to send message <%s> to member <%s> no longer in view",
+                    content.getShortClassName(), member), th);
+          }
           continue;
         }
         logger
@@ -395,7 +400,6 @@ public class DistributionImpl implements Distribution {
                 // view object. Is it ok to log membershipManager.getView here?
                 new Object[] {content, member, membership.getView()}),
                 th);
-        // Assert.assertTrue(false, "messaging contract failure");
       }
       return new HashSet<>(members);
     } // catch ConnectionExceptions