sijie closed pull request #1577: Fixed BatchMessageTest intermittent failures URL: https://github.com/apache/incubator-pulsar/pull/1577
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BatchMessageTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BatchMessageTest.java index 5a60ff3f1..9f9ab3549 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BatchMessageTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BatchMessageTest.java @@ -23,6 +23,8 @@ import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; +import com.google.common.collect.Lists; + import java.util.HashSet; import java.util.List; import java.util.Random; @@ -52,8 +54,6 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import com.google.common.collect.Lists; - public class BatchMessageTest extends BrokerTestBase { @BeforeClass @@ -372,7 +372,6 @@ public void testSimpleBatchProducerConsumer1kMessages() throws Exception { PersistentTopic topic = (PersistentTopic) pulsar.getBrokerService().getTopicReference(topicName).get(); // allow stats to be updated.. - Thread.sleep(5000); LOG.info("[{}] checking backlog stats.."); rolloverPerIntervalStats(); assertEquals(topic.getSubscription(subscriptionName).getNumberOfEntriesInBacklog(), numMsgs / numMsgsInBatch); @@ -387,10 +386,10 @@ public void testSimpleBatchProducerConsumer1kMessages() throws Exception { if (lastunackedMsg != null) { consumer.acknowledgeCumulative(lastunackedMsg); } - Thread.sleep(100); - assertEquals(topic.getSubscription(subscriptionName).getNumberOfEntriesInBacklog(), 0); + consumer.close(); producer.close(); + assertEquals(topic.getSubscription(subscriptionName).getNumberOfEntriesInBacklog(), 0); } // test for ack holes ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services