codelipenghui commented on a change in pull request #11509:
URL: https://github.com/apache/pulsar/pull/11509#discussion_r681359793
##########
File path:
pulsar-client-admin-api/src/main/java/org/apache/pulsar/common/policies/data/impl/BacklogQuotaImpl.java
##########
@@ -37,7 +38,7 @@ public static BacklogQuotaImplBuilder builder() {
}
public static class BacklogQuotaImplBuilder implements
BacklogQuota.Builder {
- private long limitSize;
+ private long limitSize = -1 * 1024 * 1024 * 1024;
Review comment:
Why we need `-1 * 1024 * 1024 * 1024` not `-1`?
##########
File path:
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicPoliciesTest.java
##########
@@ -226,8 +282,56 @@ public void testCheckBacklogQuota() throws Exception {
admin.topics().deletePartitionedTopic(testTopic, true);
}
- @Test(timeOut = 20000)
- public void testGetBacklogQuotaApplied() throws Exception {
+ @Test
+ public void testCheckTimeBasedBacklogQuota() throws Exception {
+ RetentionPolicies retentionPolicies = new RetentionPolicies(10, 10);
+ String namespace = TopicName.get(testTopic).getNamespace();
+ admin.namespaces().setRetention(namespace, retentionPolicies);
+
+ Awaitility.await()
+ .untilAsserted(() ->
Assert.assertEquals(admin.namespaces().getRetention(namespace),
retentionPolicies));
+
+ BacklogQuota backlogQuota = BacklogQuota.builder()
+ .limitTime(10 * 60)
+
.retentionPolicy(BacklogQuota.RetentionPolicy.consumer_backlog_eviction)
+ .build();
+ log.info("Backlog quota: {} will set to the topic: {}", backlogQuota,
testTopic);
+ try {
+ admin.topics().setBacklogQuota(testTopic, backlogQuota,
BacklogQuota.BacklogQuotaType.message_age);
+ Assert.fail();
+ } catch (PulsarAdminException e) {
+ Assert.assertEquals(e.getStatusCode(), 412);
+ }
+
+ backlogQuota = BacklogQuota.builder()
+ .limitTime(10 * 60 + 1)
+
.retentionPolicy(BacklogQuota.RetentionPolicy.consumer_backlog_eviction)
+ .build();
+ log.info("Backlog quota: {} will set to the topic: {}", backlogQuota,
testTopic);
+ try {
+ admin.topics().setBacklogQuota(testTopic, backlogQuota,
BacklogQuota.BacklogQuotaType.message_age);
+ Assert.fail();
+ } catch (PulsarAdminException e) {
+ Assert.assertEquals(e.getStatusCode(), 412);
+ }
+
+ backlogQuota = BacklogQuota.builder()
+ .limitTime(10 * 60 - 1)
+
.retentionPolicy(BacklogQuota.RetentionPolicy.consumer_backlog_eviction)
+ .build();
+ log.info("Backlog quota: {} will set to the topic: {}", backlogQuota,
testTopic);
+ admin.topics().setBacklogQuota(testTopic, backlogQuota,
BacklogQuota.BacklogQuotaType.message_age);
+
+ BacklogQuota finalBacklogQuota = backlogQuota;
+ Awaitility.await()
+ .untilAsserted(() ->
Assert.assertEquals(admin.topics().getBacklogQuotaMap(testTopic)
+ .get(BacklogQuota.BacklogQuotaType.message_age),
finalBacklogQuota));
+
+ admin.topics().deletePartitionedTopic(testTopic, true);
+ }
+
+ @Test//(timeOut = 20000)
Review comment:
```suggestion
@Test(timeOut = 20000)
```
--
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]