315157973 commented on a change in pull request #12367:
URL: https://github.com/apache/pulsar/pull/12367#discussion_r730641422
##########
File path:
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/TopicPoliciesTest.java
##########
@@ -2643,4 +2643,51 @@ public void
testDoNotCreateSystemTopicForHeartbeatNamespace() {
});
}
+ @Test
+ public void testMultipleCreateAndDeleteTopicPolicies() throws Exception {
+ final String topic = testTopic + UUID.randomUUID();
+
+ int n = 0;
+ while (n < 2) {
+ n++;
+ pulsarClient.newProducer().topic(topic).create().close();
+ Awaitility.await().untilAsserted(() -> {
+
Assertions.assertThat(pulsar.getTopicPoliciesService().getTopicPolicies(TopicName.get(topic))).isNull();
+ });
+
+ admin.topics().setMaxConsumersPerSubscription(topic, 1);
+ Awaitility.await().untilAsserted(() -> {
+
Assertions.assertThat(pulsar.getTopicPoliciesService().getTopicPolicies(TopicName.get(topic))).isNotNull();
+ });
+
+ admin.topics().delete(topic);
+ Awaitility.await().untilAsserted(() -> {
+
Assertions.assertThat(pulsar.getTopicPoliciesService().getTopicPolicies(TopicName.get(topic))).isNull();
+ });
+ }
+ }
+
+ @Test
+ public void testLoopCreateAndDeleteTopicPolicies() throws Exception {
+ final String topic = testTopic + UUID.randomUUID();
+
+ int n = 0;
+ while (n < 2) {
+ n++;
+ pulsarClient.newProducer().topic(topic).create().close();
+ Awaitility.await().untilAsserted(() -> {
+
Assertions.assertThat(pulsar.getTopicPoliciesService().getTopicPolicies(TopicName.get(topic))).isNull();
+ });
+
+ admin.topics().setMaxConsumersPerSubscription(topic, 1);
+ Awaitility.await().untilAsserted(() -> {
+
Assertions.assertThat(pulsar.getTopicPoliciesService().getTopicPolicies(TopicName.get(topic))).isNotNull();
+ });
+
+ admin.topics().delete(topic);
+ Awaitility.await().untilAsserted(() -> {
+
Assertions.assertThat(pulsar.getTopicPoliciesService().getTopicPolicies(TopicName.get(topic))).isNull();
+ });
+ }
+ }
Review comment:
looks great, I left some comment.
I compared the code of these two unit tests. It seems that the code is the
same. Why do we need two unit tests with the same code?
--
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]