You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/07/01 03:28:06 UTC

[GitHub] [pulsar] BewareMyPower commented on a diff in pull request #16023: [fix][admin]allowAutoTopicCreation and allowAutoTopicCreationType etc should be dynamically configured

BewareMyPower commented on code in PR #16023:
URL: https://github.com/apache/pulsar/pull/16023#discussion_r911586479


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/InactiveTopicDeleteTest.java:
##########
@@ -596,4 +597,64 @@ public void testHealthTopicInactiveNotClean() throws Exception {
         Assert.assertTrue(V1Partitions.contains(healthCheckTopicV1));
         Assert.assertTrue(V2Partitions.contains(healthCheckTopicV2));
     }
+
+    @Test
+    public void testDynamicConfigurationBrokerDeleteInactiveTopicsEnabled() throws Exception {
+        conf.setBrokerDeleteInactiveTopicsEnabled(true);
+        super.baseSetup();
+        admin.brokers().updateDynamicConfiguration("brokerDeleteInactiveTopicsEnabled", "false");
+        Awaitility.await().untilAsserted(()->{
+            assertFalse(conf.isBrokerDeleteInactiveTopicsEnabled());
+        });
+    }
+
+    @Test
+    public void testDynamicConfigurationBrokerDeleteInactiveTopicsFrequencySeconds() throws Exception {
+        conf.setBrokerDeleteInactiveTopicsFrequencySeconds(30);
+        super.baseSetup();
+        admin.brokers()
+                .updateDynamicConfiguration("brokerDeleteInactiveTopicsFrequencySeconds", "60");
+        Awaitility.await().untilAsserted(()->{
+            assertEquals(conf.getBrokerDeleteInactiveTopicsFrequencySeconds(), 60);
+        });
+    }
+
+    @Test
+    public void testDynamicConfigurationBrokerDeleteInactiveTopicsMaxInactiveDurationSeconds() throws Exception {
+        conf.setBrokerDeleteInactiveTopicsMaxInactiveDurationSeconds(30);
+        super.baseSetup();
+        admin.brokers()
+                .updateDynamicConfiguration("brokerDeleteInactiveTopicsMaxInactiveDurationSeconds", "60");
+        Awaitility.await().untilAsserted(()->{
+            assertEquals(conf.getBrokerDeleteInactiveTopicsMaxInactiveDurationSeconds(), 60);
+        });
+    }
+
+    @Test
+    public void testDynamicConfigurationBrokerDeleteInactiveTopicsMode() throws Exception {
+        conf.setBrokerDeleteInactiveTopicsMode (InactiveTopicDeleteMode.delete_when_no_subscriptions);
+        super.baseSetup();
+        String expect = InactiveTopicDeleteMode.delete_when_subscriptions_caught_up.toString();
+        admin.brokers()
+                .updateDynamicConfiguration("brokerDeleteInactiveTopicsMode",
+                        expect);
+        Awaitility.await().untilAsserted(()->{
+            assertEquals(conf.getBrokerDeleteInactiveTopicsMode().toString(), expect);
+        });
+    }
+
+    @Test
+    public void testBrokerDeleteInactivePartitionedTopicMetadataEnabled() throws Exception {
+        conf.setBrokerDeleteInactivePartitionedTopicMetadataEnabled(false);
+        super.baseSetup();
+        admin.brokers()
+                .updateDynamicConfiguration("brokerDeleteInactivePartitionedTopicMetadataEnabled",
+                        "true");
+        Thread.sleep(2000);
+        Awaitility.await().untilAsserted(()->{
+            assertTrue(conf.isBrokerDeleteInactivePartitionedTopicMetadataEnabled());
+        });
+    }

Review Comment:
   Don't use `Thread.sleep`, use `Awaitility.await().atMost(/* ... */)`.
   
   I noticed some existing tests might also use `Thread.sleep`, but it's not good. For new tests, it's better not to sleep.



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org