lhotari commented on a change in pull request #10206:
URL: https://github.com/apache/pulsar/pull/10206#discussion_r614038837



##########
File path: 
pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/buffer/TransactionBufferClientTest.java
##########
@@ -161,8 +175,40 @@ public void testAbortOnSubscription() throws 
ExecutionException, InterruptedExce
             futures.add(tbClient.abortTxnOnSubscription(topic, "test", 1L, i, 
-1L));
         }
         for (int i = 0; i < futures.size(); i++) {
-            Assert.assertEquals(futures.get(i).get().getMostSigBits(), 1L);
-            Assert.assertEquals(futures.get(i).get().getLeastSigBits(), i);
+            assertEquals(futures.get(i).get().getMostSigBits(), 1L);
+            assertEquals(futures.get(i).get().getLeastSigBits(), i);
+        }
+    }
+
+    @Test
+    public void testTransactionBufferClientTimeout() throws Exception {
+        ConnectionPool connectionPool = mock(ConnectionPool.class);
+        NamespaceService namespaceService = mock(NamespaceService.class);
+        HashedWheelTimer hashedWheelTimer = new HashedWheelTimer();
+        doReturn(new 
CompletableFuture<>()).when(namespaceService).getBundleAsync(anyObject());
+        TransactionBufferHandlerImpl transactionBufferHandler = new 
TransactionBufferHandlerImpl(connectionPool,
+                namespaceService, hashedWheelTimer);
+        CompletableFuture<TxnID> completableFuture =
+                transactionBufferHandler.endTxnOnTopic("test", 1, 1, 
TxnAction.ABORT, 1);
+
+        Field field = 
TransactionBufferHandlerImpl.class.getDeclaredField("pendingRequests");
+        field.setAccessible(true);
+        ConcurrentSkipListMap<Long, Object> pendingRequests =
+                (ConcurrentSkipListMap<Long, Object>) 
field.get(transactionBufferHandler);
+
+        assertEquals(pendingRequests.size(), 1);
+
+        Awaitility.await().atLeast(2, TimeUnit.SECONDS).atMost(6, 
TimeUnit.SECONDS).until(() -> {

Review comment:
       the `.atMost` part can be omitted since 10 seconds is the Awaitility 
default. It's better to rely on the default "atMost" value unless there's a 
specific reason to set it to a lower value.




-- 
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.

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


Reply via email to