congbobo184 commented on a change in pull request #13704:
URL: https://github.com/apache/pulsar/pull/13704#discussion_r781928926
##########
File path:
pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/TransactionMetricsTest.java
##########
@@ -339,6 +346,64 @@ public void
testManagedLedgerMetricsWhenPendingAckNotInit() throws Exception{
checkManagedLedgerMetrics(subName2, 32, metric);
}
+ @Test
+ public void testDuplicateMetricTypeDefinitions() throws Exception{
+ pulsarClient =
PulsarClient.builder().serviceUrl(lookupUrl.toString()).enableTransaction(true).build();
+ Producer<byte[]> p1 = pulsarClient
+ .newProducer()
+ .topic("persistent://my-property/use/my-ns/my-topic1")
+ .sendTimeout(0, TimeUnit.SECONDS)
+ .create();
+ Transaction transaction = pulsarClient
+ .newTransaction()
+ .withTransactionTimeout(5, TimeUnit.SECONDS)
+ .build()
+ .get();
+ for (int i = 0; i < 10; i++) {
+ String message = "my-message-" + i;
+ p1.newMessage(transaction)
+ .value(message.getBytes())
+ .send();
+ }
+ ByteArrayOutputStream statsOut = new ByteArrayOutputStream();
+ PrometheusMetricsGenerator.generate(pulsar, false, false, false,
statsOut);
+ String metricsStr = statsOut.toString();
+
+ Map<String, String> typeDefs = new HashMap<>();
+ Map<String, String> metricNames = new HashMap<>();
+ Pattern typePattern =
Pattern.compile("^#\\s+TYPE\\s+(\\w+)\\s+(\\w+)");
+
+ Splitter.on("\n").split(metricsStr).forEach(line -> {
Review comment:
this test are correct? seem not change the code, the test always run
success
--
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]