maixiaohai commented on a change in pull request #2167:
URL: https://github.com/apache/rocketmq/pull/2167#discussion_r502533066
##########
File path:
client/src/test/java/org/apache/rocketmq/client/impl/factory/MQClientInstanceTest.java
##########
@@ -74,6 +87,34 @@ public void testTopicRouteData2TopicPublishInfo() {
assertThat(topicPublishInfo.getMessageQueueList().size()).isEqualTo(4);
}
+ @Test
+ public void testFindBrokerAddressInSubscribe() {
+ // dledger normal case
+ String brokerName = "BrokerA";
+ HashMap<Long, String> addrMap = new HashMap<Long, String>();
+ addrMap.put(0L, "127.0.0.1:10911");
+ addrMap.put(1L, "127.0.0.1:10912");
+ addrMap.put(2L, "127.0.0.1:10913");
+ brokerAddrTable.put(brokerName, addrMap);
+ long brokerId = 1;
+ FindBrokerResult brokerResult =
mqClientInstance.findBrokerAddressInSubscribe(brokerName, brokerId, false);
+ assertThat(brokerResult).isNotNull();
+ assertThat(brokerResult.getBrokerAddr()).isEqualTo("127.0.0.1:10912");
+ assertThat(brokerResult.isSlave()).isTrue();
+
+ // dledger case, when node n0 was voted as the leader
+ brokerName = "BrokerB";
+ HashMap<Long, String> addrMapNew = new HashMap<Long, String>();
+ addrMapNew.put(0L, "127.0.0.1:10911");
+ addrMapNew.put(2L, "127.0.0.1:10912");
Review comment:
(0,1,2) is the normal case, which is added to check my code and also for
the future changes from others. IMO, it can improve the coverage of UT.
(0,2,3) is the "bugfix" case, which is added to check if my code fix the bug.
----------------------------------------------------------------
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]