You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2022/04/07 17:21:59 UTC

[GitHub] [geode] kirklund commented on a diff in pull request #7556: GEODE-10097: Avoid Thread.sleep for re-auth in MessageDispatcher

kirklund commented on code in PR #7556:
URL: https://github.com/apache/geode/pull/7556#discussion_r845393205


##########
geode-core/src/test/java/org/apache/geode/internal/cache/tier/sockets/MessageDispatcherTest.java:
##########
@@ -173,6 +174,32 @@ public void oldClientWillNotGetClientReAuthenticateMessage() throws Exception {
     verify(dispatcher, never()).dispatchResidualMessages();
   }
 
+
+  @Test
+  public void oldClientWillContinueToDeliverMessageIfNotified() throws Exception {
+    doReturn(false, false, true).when(dispatcher).isStopped();
+    // make sure wait time is short
+    doReturn(10000L).when(dispatcher).getSystemProperty(eq(RE_AUTHENTICATE_WAIT_TIME), anyLong());
+    doThrow(AuthenticationExpiredException.class).when(dispatcher).dispatchMessage(any());
+    when(messageQueue.peek()).thenReturn(message);
+    when(proxy.getVersion()).thenReturn(KnownVersion.GEODE_1_14_0);
+
+    Thread dispatcherThread = new Thread(() -> dispatcher.runDispatcher());
+    Thread notifyThread = new Thread(() -> dispatcher.notifyReAuthentication());
+
+    dispatcherThread.start();
+    await().until(() -> dispatcher.isWaitingForReAuthentication());
+    notifyThread.start();
+
+    dispatcherThread.join();
+    notifyThread.join();

Review Comment:
   Take a look at the `ExecutorServiceRule`. It can simplify a lot of this sort of testing and will kill and dump hung threads at the end of the test to make debugging easier if there is a failure of some sort.



-- 
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: notifications-unsubscribe@geode.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org