codelipenghui commented on a change in pull request #14870:
URL: https://github.com/apache/pulsar/pull/14870#discussion_r835346044



##########
File path: 
pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ProducerCloseTest.java
##########
@@ -99,6 +103,25 @@ public void 
testProducerCloseFailsPendingBatchWhenPreviousStateNotReadyCallback(
         }
     }
 
+    @Test(timeOut = 10_000)
+    public void brokerCloseTest() throws Exception {
+        initClient();

Review comment:
       The client will be created before executing the method, we don't need to 
init it again.
   Not sure why all the tests in this class call initClient(), this is a 
useless call and the old client
   will not be closed. We should remove all the `initClient()` calls for this 
method.

##########
File path: 
pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ProducerCloseTest.java
##########
@@ -99,6 +103,25 @@ public void 
testProducerCloseFailsPendingBatchWhenPreviousStateNotReadyCallback(
         }
     }
 
+    @Test(timeOut = 10_000)
+    public void brokerCloseTest() throws Exception {
+        initClient();
+
+        String topic = "broker-close-test-" + 
RandomStringUtils.randomAlphabetic(5);
+        @Cleanup
+        ProducerImpl<byte[]> producer = (ProducerImpl<byte[]>) 
pulsarClient.newProducer()
+                .topic(topic)
+                .create();
+        producer.newMessage().value("test".getBytes()).send();
+
+        Optional<Topic> topicOptional = pulsar.getBrokerService()
+                
.getTopicReference(TopicName.get(topic).getPartitionedTopicName());
+        Assert.assertTrue(topicOptional.isPresent());
+        topicOptional.get().close(true).get();
+        Assert.assertEquals(producer.getState(), 
HandlerState.State.Connecting);

Review comment:
       I think here will introduce a flaky test? the producer might reconnect 
to the broker.




-- 
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]


Reply via email to