jiazhai commented on a change in pull request #6537: [Issue 5903] Support
`compact` all partitions of a partitioned topic
URL: https://github.com/apache/pulsar/pull/6537#discussion_r392640439
##########
File path:
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java
##########
@@ -439,4 +439,33 @@ public void testRevokePartitionedTopic() {
Assert.assertEquals(partitionPermissions.get(role), null);
}
}
+
+ @Test
+ public void testTriggerCompactionTopic() {
+ final String partitionTopicName = "test-part";
+ final String nonPartitionTopicName = "test-non-part";
+
+ // trigger compaction on non-existing topic
+ AsyncResponse response = mock(AsyncResponse.class);
+ persistentTopics.compact(response, testTenant, testNamespace,
"non-existing-topic", true);
+ ArgumentCaptor<RestException> errCaptor =
ArgumentCaptor.forClass(RestException.class);
+ verify(response, timeout(5000).times(1)).resume(errCaptor.capture());
+ Assert.assertEquals(errCaptor.getValue().getResponse().getStatus(),
Response.Status.NOT_FOUND.getStatusCode());
+
+ // create non partitioned topic and compaction on it
+ response = mock(AsyncResponse.class);
+ persistentTopics.createNonPartitionedTopic(testTenant, testNamespace,
nonPartitionTopicName, true);
+ persistentTopics.compact(response, testTenant, testNamespace,
nonPartitionTopicName, true);
+ ArgumentCaptor<Response> responseCaptor =
ArgumentCaptor.forClass(Response.class);
+ verify(response,
timeout(5000).times(1)).resume(responseCaptor.capture());
+ Assert.assertEquals(responseCaptor.getValue().getStatus(),
Response.Status.NO_CONTENT.getStatusCode());
+
+ // create partitioned topic and compaction on it
Review comment:
@murong00 thanks for the contribute, Would you please help add a test that
really called into and execute the compact? Seems this is only the top level
method call, and not called into the methods, and some of the code in
PersistentTopicsBase.java seems not covered.
If there is no ut framework for this, we could add a integration test for it.
----------------------------------------------------------------
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]
With regards,
Apache Git Services