poorbarcode commented on code in PR #16540:
URL: https://github.com/apache/pulsar/pull/16540#discussion_r940518329
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceTest.java:
##########
@@ -979,7 +981,32 @@ public void testLookupThrottlingForClientByClient() throws
Exception {
EventLoopGroup eventLoop = EventLoopUtil.newEventLoopGroup(20, false,
new DefaultThreadFactory("test-pool",
Thread.currentThread().isDaemon()));
long reqId = 0xdeadbeef;
- try (ConnectionPool pool = new ConnectionPool(conf, eventLoop)) {
+
+ Semaphore clientCnxSemaphore = new Semaphore(1);
+ AtomicInteger count = new AtomicInteger(2);
+ try (ConnectionPool pool = new ConnectionPool(conf, eventLoop, () ->
new ClientCnx(conf, eventLoop) {
+ @Override
+ protected void handleLookupResponse(CommandLookupTopicResponse
lookupResult) {
+ try {
+ clientCnxSemaphore.acquire();
Review Comment:
If the client handled the first request quickly enough, there would never be
three concurrent requests.
I think we just need to block the client so that the client doesn't process
the response quickly. Maybe CountDownLatch is a better fit, just lick this:
```java
// request 1 :
countDownLatch.await()
// request 2 :
countDownLatch.await()
// request 3 :
countDownLatch.await()
// After countDown is executed, we have built three concurrent requests
countDownLacth.countDown()
```
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceTest.java:
##########
@@ -979,7 +981,32 @@ public void testLookupThrottlingForClientByClient() throws
Exception {
EventLoopGroup eventLoop = EventLoopUtil.newEventLoopGroup(20, false,
new DefaultThreadFactory("test-pool",
Thread.currentThread().isDaemon()));
long reqId = 0xdeadbeef;
- try (ConnectionPool pool = new ConnectionPool(conf, eventLoop)) {
+
+ Semaphore clientCnxSemaphore = new Semaphore(1);
+ AtomicInteger count = new AtomicInteger(2);
Review Comment:
Why do we need this `count` ?
--
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]