eolivelli commented on code in PR #17856:
URL: https://github.com/apache/pulsar/pull/17856#discussion_r993056265
##########
pulsar-client/src/test/java/org/apache/pulsar/client/impl/ClientCnxTest.java:
##########
@@ -80,6 +82,72 @@ public void testClientCnxTimeout() throws Exception {
eventLoop.shutdownGracefully();
}
+ @Test
+ public void testPendingLookupRequestSemaphore() throws Exception {
+ EventLoopGroup eventLoop = EventLoopUtil.newEventLoopGroup(1, false,
new DefaultThreadFactory("testClientCnxTimeout"));
+ ClientConfigurationData conf = new ClientConfigurationData();
+ conf.setOperationTimeoutMs(10_000);
+ conf.setKeepAliveIntervalSeconds(0);
+ ClientCnx cnx = new ClientCnx(conf, eventLoop);
+
+ ChannelHandlerContext ctx = mock(ChannelHandlerContext.class);
+ Channel channel = mock(Channel.class);
+ when(ctx.channel()).thenReturn(channel);
+ ChannelFuture listenerFuture = mock(ChannelFuture.class);
+ when(listenerFuture.addListener(any())).thenReturn(listenerFuture);
+ when(ctx.writeAndFlush(any())).thenReturn(listenerFuture);
+ cnx.channelActive(ctx);
+ CountDownLatch countDownLatch1 = new CountDownLatch(1);
+ CountDownLatch countDownLatch2 = new CountDownLatch(1);
+ new Thread(() -> {
+ try {
+ Thread.sleep(5_000);
+ CompletableFuture<BinaryProtoLookupService.LookupDataResult>
future =
+ cnx.newLookup(null, 123);
+ countDownLatch1.countDown();
+ future.get();
+ } catch (Exception e) {
+ // ignore exception
Review Comment:
if we expect this exception we must add a assertion about it
otherwise we could fall into here for other reasons
##########
pulsar-client/src/test/java/org/apache/pulsar/client/impl/ClientCnxTest.java:
##########
@@ -80,6 +82,72 @@ public void testClientCnxTimeout() throws Exception {
eventLoop.shutdownGracefully();
}
+ @Test
+ public void testPendingLookupRequestSemaphore() throws Exception {
+ EventLoopGroup eventLoop = EventLoopUtil.newEventLoopGroup(1, false,
new DefaultThreadFactory("testClientCnxTimeout"));
+ ClientConfigurationData conf = new ClientConfigurationData();
+ conf.setOperationTimeoutMs(10_000);
+ conf.setKeepAliveIntervalSeconds(0);
+ ClientCnx cnx = new ClientCnx(conf, eventLoop);
+
+ ChannelHandlerContext ctx = mock(ChannelHandlerContext.class);
+ Channel channel = mock(Channel.class);
+ when(ctx.channel()).thenReturn(channel);
+ ChannelFuture listenerFuture = mock(ChannelFuture.class);
+ when(listenerFuture.addListener(any())).thenReturn(listenerFuture);
+ when(ctx.writeAndFlush(any())).thenReturn(listenerFuture);
+ cnx.channelActive(ctx);
+ CountDownLatch countDownLatch1 = new CountDownLatch(1);
+ CountDownLatch countDownLatch2 = new CountDownLatch(1);
+ new Thread(() -> {
+ try {
+ Thread.sleep(5_000);
Review Comment:
can we use a smaller number ? in order to not make the test take too much
time ?
--
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]