sijie commented on a change in pull request #8871:
URL: https://github.com/apache/pulsar/pull/8871#discussion_r539031499
##########
File path:
pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/PrometheusMetricsTest.java
##########
@@ -185,6 +192,95 @@ public void testPerTopicStats() throws Exception {
c2.close();
}
+ @Test
+ public void testPerTopicExpiredStat() throws Exception {
+ String ns = "prop/ns-abc1";
+ admin.namespaces().createNamespace(ns);
+ String topic1 = "persistent://" + ns + "/testPerTopicExpiredStat1";
+ String topic2 = "persistent://" + ns + "/testPerTopicExpiredStat2";
+ List<String> topicList = Arrays.asList(topic2,topic1);
+ Producer<byte[]> p1 =
pulsarClient.newProducer().topic(topic1).create();
+ Producer<byte[]> p2 =
pulsarClient.newProducer().topic(topic2).create();
+ admin.namespaces().setNamespaceMessageTTL(ns,1);
+ final String subName = "test";
+ for (String topic : topicList) {
+ pulsarClient.newConsumer()
+ .topic(topic)
+ .subscriptionName(subName)
+ .subscribe().close();
+ }
+
+ final int messages = 10;
+
+ for (int i = 0; i < messages; i++) {
+ String message = "my-message-" + i;
+ p1.send(message.getBytes());
+ p2.send(message.getBytes());
+ }
+
+ p1.close();
+ p2.close();
+ // make sure message is expired
+ Thread.sleep(2000);
Review comment:
Can we find a different way to trigger message expiry task?
It is not a good idea to call `Thread.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.
For queries about this service, please contact Infrastructure at:
[email protected]