lhotari commented on code in PR #25070:
URL: https://github.com/apache/pulsar/pull/25070#discussion_r2661595915
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/TopicListServiceTest.java:
##########
@@ -88,10 +178,37 @@ public void testCommandWatchSuccessResponse() {
List<String> topics =
Collections.singletonList("persistent://tenant/ns/topic1");
String hash = TopicList.calculateHash(topics);
topicListFuture.complete(topics);
- Assert.assertEquals(1, lookupSemaphore.availablePermits());
+ Awaitility.await().untilAsserted(() -> Assert.assertEquals(1,
lookupSemaphore.availablePermits()));
verify(topicResources).registerPersistentTopicListener(
eq(NamespaceName.get("tenant/ns")),
any(TopicListService.TopicListWatcher.class));
- verify(connection.getCommandSender()).sendWatchTopicListSuccess(7, 13,
hash, topics);
+
verify(connection.getCommandSender()).sendWatchTopicListSuccess(eq(7L),
eq(13L), eq(hash), eq(topics), any());
+ }
+
+ @Test
+ public void testCommandWatchSuccessResponseWhenOutOfPermits() throws
ExecutionException, InterruptedException {
+ // acquire all permits
+ AsyncDualMemoryLimiter.AsyncDualMemoryLimiterPermit permit =
+ memoryLimiter.acquire(1_000_000,
AsyncDualMemoryLimiter.LimitType.HEAP_MEMORY,
+ Boolean.FALSE::booleanValue)
+ .get();
+ topicListService.handleWatchTopicList(
+ NamespaceName.get("tenant/ns"),
+ 13,
+ 7,
+ "persistent://tenant/ns/topic\\d",
+ topicsPatternImplementation, null,
+ lookupSemaphore);
+ List<String> topics =
Collections.singletonList("persistent://tenant/ns/topic1");
+ String hash = TopicList.calculateHash(topics);
+ topicListFuture.complete(topics);
+ // wait for acquisition to timeout a few times
+ Thread.sleep(2000);
Review Comment:
In this case Thread.sleep is used to cause a timeout.
--
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]