@@ -522,11 +522,26 @@ TEST(ClientTest, testUpdateServiceInfo) {
522522 ServiceInfo info3{" pulsar://localhost:6650" , std::nullopt , std::nullopt };
523523
524524 Client client{info1.serviceUrl , ClientConfiguration ().setAuth (*info1.authentication )};
525+
525526 const auto topicRequiredAuth = " private/auth/testUpdateConnectionInfo-" + std::to_string (time (nullptr ));
526527 Producer producer;
527528 ASSERT_EQ (ResultOk, client.createProducer (topicRequiredAuth, producer));
528- MessageId msgId;
529- ASSERT_EQ (ResultOk, producer.send (MessageBuilder ().setContent (" msg-0" ).build (), msgId));
529+
530+ Reader reader;
531+ ASSERT_EQ (ResultOk, client.createReader (topicRequiredAuth, MessageId::earliest (), {}, reader));
532+
533+ auto sendAndReceive = [&](const std::string &value) {
534+ MessageId msgId;
535+ ASSERT_EQ (ResultOk, producer.send (MessageBuilder ().setContent (value).build (), msgId));
536+ LOG_INFO (" Sent " << value << " to " << msgId);
537+
538+ Message msg;
539+ ASSERT_EQ (ResultOk, reader.readNext (msg, 3000 ));
540+ LOG_INFO (" Read " << msg.getDataAsString () << " from " << msgId);
541+ ASSERT_EQ (value, msg.getDataAsString ());
542+ };
543+
544+ sendAndReceive (" msg-0" );
530545
531546 // Switch to cluster 2 (started by ./build-support/start-mim-test-service-inside-container.sh)
532547 ASSERT_FALSE (PulsarFriend::getConnections (client).empty ());
@@ -537,8 +552,7 @@ TEST(ClientTest, testUpdateServiceInfo) {
537552 ASSERT_EQ (info2.tlsTrustCertsFilePath , client.getServiceInfo ().tlsTrustCertsFilePath );
538553
539554 // Now the same will access the same topic in cluster 2
540- ASSERT_EQ (ResultOk, producer.send (MessageBuilder ().setContent (" msg-1" ).build (), msgId));
541- ASSERT_EQ (ResultOk, producer.close ());
555+ sendAndReceive (" msg-1" );
542556
543557 // Switch back to cluster 1 without any authentication, the previous authentication info configured for
544558 // cluster 2 will be cleared.
@@ -548,8 +562,9 @@ TEST(ClientTest, testUpdateServiceInfo) {
548562 ASSERT_EQ (info3.tlsTrustCertsFilePath , client.getServiceInfo ().tlsTrustCertsFilePath );
549563
550564 const auto topicNoAuth = " testUpdateConnectionInfo-" + std::to_string (time (nullptr ));
565+ producer.close ();
551566 ASSERT_EQ (ResultOk, client.createProducer (topicNoAuth, producer));
552- ASSERT_EQ (ResultOk, producer.send (MessageBuilder ().setContent (" msg-2" ).build (), msgId ));
567+ ASSERT_EQ (ResultOk, producer.send (MessageBuilder ().setContent (" msg-2" ).build ()));
553568
554569 client.close ();
555570
0 commit comments