@@ -245,11 +245,10 @@ TEST_P(ProducerTest, testMaxMessageSize) {
245245 client.close ();
246246}
247247
248- TEST_P (ProducerTest, testChunkingMaxMessageSize) {
248+ TEST (ProducerTest, testChunkingMaxMessageSize) {
249249 Client client (serviceUrl);
250250
251- const auto topic = std::string (" ProducerTest-ChunkingMaxMessageSize-" ) +
252- (GetParam () ? " batch-" : " no-batch-" ) + std::to_string (time (nullptr ));
251+ const auto topic = std::string (" ProducerTest-ChunkingMaxMessageSize-" ) + std::to_string (time (nullptr ));
253252
254253 Consumer consumer;
255254 ASSERT_EQ (ResultOk, client.subscribe (topic, " sub" , consumer));
@@ -297,4 +296,44 @@ TEST(ProducerTest, testExclusiveProducer) {
297296 ASSERT_EQ (ResultProducerBusy, client.createProducer (topicName, producerConfiguration3, producer3));
298297}
299298
299+ TEST_P (ProducerTest, testFlushNoBatch) {
300+ Client client (serviceUrl);
301+
302+ auto partitioned = GetParam ();
303+ const auto topicName = std::string (" testFlushNoBatch" ) +
304+ (partitioned ? " partitioned-" : " -no-partitioned-" ) +
305+ std::to_string (time (nullptr ));
306+
307+ if (partitioned) {
308+ // call admin api to make it partitioned
309+ std::string url = adminUrl + " admin/v2/persistent/public/default/" + topicName + " /partitions" ;
310+ int res = makePutRequest (url, " 5" );
311+ LOG_INFO (" res = " << res);
312+ ASSERT_FALSE (res != 204 && res != 409 );
313+ }
314+
315+ ProducerConfiguration producerConfiguration;
316+ producerConfiguration.setBatchingEnabled (false );
317+
318+ Producer producer;
319+ ASSERT_EQ (ResultOk, client.createProducer (topicName, producerConfiguration, producer));
320+
321+ std::atomic_int needCallBack (100 );
322+ auto cb = [&needCallBack](Result code, const MessageId& msgId) {
323+ ASSERT_EQ (code, ResultOk);
324+ needCallBack.fetch_sub (1 );
325+ };
326+
327+ for (int i = 0 ; i < 100 ; ++i) {
328+ Message msg = MessageBuilder ().setContent (" content" ).build ();
329+ producer.sendAsync (msg, cb);
330+ }
331+
332+ producer.flush ();
333+ ASSERT_EQ (needCallBack.load (), 0 );
334+ producer.close ();
335+
336+ client.close ();
337+ }
338+
300339INSTANTIATE_TEST_CASE_P (Pulsar, ProducerTest, ::testing::Values(true , false ));
0 commit comments