315157973 commented on a change in pull request #7802: URL: https://github.com/apache/pulsar/pull/7802#discussion_r469376617
########## File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/MaxUnackedMessagesTest.java ########## @@ -0,0 +1,188 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pulsar.broker.admin; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import com.google.common.collect.Maps; +import org.apache.pulsar.client.api.Consumer; +import org.apache.pulsar.client.api.ConsumerBuilder; +import org.apache.pulsar.client.api.Message; +import org.apache.pulsar.client.api.MessageId; +import org.apache.pulsar.client.api.Producer; +import org.apache.pulsar.client.api.ProducerConsumerBase; +import org.apache.pulsar.client.api.PulsarClientException; +import org.apache.pulsar.client.api.SubscriptionType; +import org.testng.Assert; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import org.testng.collections.Lists; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.testng.Assert.fail; + +public class MaxUnackedMessagesTest extends ProducerConsumerBase { + private final String testTenant = "public"; + private final String testNamespace = "default"; + private final String myNamespace = testTenant + "/" + testNamespace; + private final String testTopic = "persistent://" + myNamespace + "/max-unacked-"; + + @BeforeMethod + @Override + protected void setup() throws Exception { + this.conf.setSystemTopicEnabled(true); + this.conf.setTopicLevelPoliciesEnabled(true); + super.internalSetup(); + super.producerBaseSetup(); + } + + @AfterMethod + @Override + protected void cleanup() throws Exception { + super.internalCleanup(); + } + + @Test(timeOut = 20000) + public void testMaxUnackedMessagesOnSubscriptionApi() throws Exception { + final String topicName = testTopic + UUID.randomUUID().toString(); + admin.topics().createPartitionedTopic(topicName, 3); + Integer max = admin.topics().getMaxUnackedMessagesOnSubscription(topicName); Review comment: This is a good suggestion! But the fixed seconds of sleep may not guarantee the success of initialization, and if there are too many unit tests like this, it will slow down the CI process. So I try to loop to determine whether the initialization is successful. ---------------------------------------------------------------- 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]
