mhansonp commented on a change in pull request #7442:
URL: https://github.com/apache/geode/pull/7442#discussion_r838992648



##########
File path: 
geode-core/src/integrationTest/java/org/apache/geode/cache/client/internal/QueueManagerJUnitTest.java
##########
@@ -294,6 +298,84 @@ public void 
testAddToConnectionListCallsCloseConnectionOpWithKeepAliveTrue2() {
     assertThat(connection.keepAlive).isTrue();
   }
 
+  @Test
+  public void recoverPrimaryRegistersBeforeSendingReady() {
+    Set<ServerLocation> excludedServers = new HashSet<>();
+    excludedServers.add(new ServerLocation("localhost", 1));
+    excludedServers.add(new ServerLocation("localhost", 2));
+    excludedServers.add(new ServerLocation("localhost", 3));
+    factory.addConnection(0, 0, 1);
+    factory.addConnection(0, 0, 2);
+    factory.addConnection(0, 0, 3);
+
+    LocalRegion testRegion = mock(LocalRegion.class);
+
+    InternalPool pool = new RecoveryDummyPool();
+    ServerRegionProxy serverRegionProxy = new ServerRegionProxy("region", 
pool);
+
+    when(testRegion.getServerProxy()).thenReturn(serverRegionProxy);
+    RegionAttributes regionAttributes = mock(RegionAttributes.class);
+    when(testRegion.getAttributes()).thenReturn(regionAttributes);
+    when(regionAttributes.getDataPolicy()).thenReturn(DataPolicy.DEFAULT);
+
+    createRegisterInterestTracker(pool, testRegion);
+
+    manager = new QueueManagerImpl(pool, endpoints, source, factory, 2,
+        20, logger, ClientProxyMembershipID.getNewProxyMembership(ds));
+    manager.start(background);
+    manager.setSendClientReady();
+    manager.clearQueueConnections();
+    factory.addConnection(0, 0, 4);
+    manager.recoverPrimary(excludedServers);
+
+    
assertThat(opList.get(0)).isInstanceOf(RegisterInterestListOp.RegisterInterestListOpImpl.class);
+    
assertThat(opList.get(1)).isInstanceOf(RegisterInterestListOp.RegisterInterestListOpImpl.class);
+    
assertThat(opList.get(2)).isInstanceOf(RegisterInterestListOp.RegisterInterestListOpImpl.class);
+    
assertThat(opList.get(3)).isInstanceOf(RegisterInterestListOp.RegisterInterestListOpImpl.class);
+    
assertThat(opList.get(4)).isInstanceOf(ReadyForEventsOp.ReadyForEventsOpImpl.class);
+  }
+
+  private void createRegisterInterestTracker(InternalPool localPool,
+      LocalRegion localRegion) {
+    final RegisterInterestTracker registerInterestTracker = 
localPool.getRITracker();
+
+    final ConcurrentHashMap<String, 
RegisterInterestTracker.RegionInterestEntry> keysConcurrentMap =
+        new ConcurrentHashMap<>();
+    when(registerInterestTracker.getRegionToInterestsMap(eq(InterestType.KEY), 
anyBoolean(),
+        anyBoolean())).thenReturn(
+            keysConcurrentMap);
+    RegisterInterestTracker.RegionInterestEntry registerInterestEntry =
+        new RegisterInterestTracker.RegionInterestEntry(
+            localRegion);
+
+    registerInterestEntry.getInterests().put("bob", InterestResultPolicy.NONE);
+    keysConcurrentMap.put("testRegion", registerInterestEntry);
+
+    final ConcurrentHashMap<String, 
RegisterInterestTracker.RegionInterestEntry> regexConcurrentMap =
+        new ConcurrentHashMap<>();
+    
when(registerInterestTracker.getRegionToInterestsMap(eq(InterestType.REGULAR_EXPRESSION),
+        anyBoolean(), anyBoolean())).thenReturn(
+            regexConcurrentMap);
+
+    final ConcurrentHashMap<String, 
RegisterInterestTracker.RegionInterestEntry> filterClassConcurrentMap =
+        new ConcurrentHashMap<>();
+    
when(registerInterestTracker.getRegionToInterestsMap(eq(InterestType.FILTER_CLASS),
+        anyBoolean(), anyBoolean())).thenReturn(
+            filterClassConcurrentMap);
+
+    final ConcurrentHashMap<String, 
RegisterInterestTracker.RegionInterestEntry> cqConcurrentMap =
+        new ConcurrentHashMap<>();
+    when(registerInterestTracker.getRegionToInterestsMap(eq(InterestType.CQ), 
anyBoolean(),
+        anyBoolean())).thenReturn(
+            cqConcurrentMap);
+
+    final ConcurrentHashMap<String, 
RegisterInterestTracker.RegionInterestEntry> oqlQueryConcurrentMap =
+        new ConcurrentHashMap<>();
+    
when(registerInterestTracker.getRegionToInterestsMap(eq(InterestType.OQL_QUERY),
 anyBoolean(),
+        anyBoolean())).thenReturn(
+            oqlQueryConcurrentMap);

Review comment:
       Done. Thanks!

##########
File path: 
geode-core/src/integrationTest/java/org/apache/geode/cache/client/internal/QueueManagerJUnitTest.java
##########
@@ -238,17 +245,14 @@ public void testWaitForPrimary() {
     manager.start(background);
     manager.getAllConnections().getPrimary().destroy();
 
-    Throwable thrown = catchThrowable(() -> {
-      manager.getAllConnections().getPrimary();
-    });
+    Throwable thrown = catchThrowable(() -> 
manager.getAllConnections().getPrimary());
     
assertThat(thrown).isInstanceOf(NoSubscriptionServersAvailableException.class);

Review comment:
       Done.

##########
File path: 
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableRegistrationDUnitTest.java
##########
@@ -345,6 +338,15 @@ public void run2() throws CacheException {
     durableClientVM
         .invoke(() -> DurableRegistrationDUnitTest.registerKey(K2, 
Boolean.FALSE));
 
+
+    // Step 9: Send clientReady message
+    durableClientVM.invoke(new CacheSerializableRunnable("Send clientReady") {
+      @Override
+      public void run2() throws CacheException {
+        CacheServerTestUtil.getCache().readyForEvents();
+      }
+    });

Review comment:
       Done

##########
File path: 
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableRegistrationDUnitTest.java
##########
@@ -284,6 +278,14 @@ public void run2() throws CacheException {
     durableClientVM
         .invoke(() -> DurableRegistrationDUnitTest.registerKey(K4, 
Boolean.TRUE));
 
+    // Send clientReady message
+    durableClientVM.invoke(new CacheSerializableRunnable("Send clientReady") {
+      @Override
+      public void run2() throws CacheException {
+        CacheServerTestUtil.getCache().readyForEvents();
+      }
+    });

Review comment:
       Done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to