提交 ad993e30 编写于 作者: D dongeforever

Use 3 brokers for IT test

上级 1ca218f1
...@@ -205,15 +205,13 @@ public class TopicQueueMappingUtils { ...@@ -205,15 +205,13 @@ public class TopicQueueMappingUtils {
LogicQueueMappingItem newItem = newItems.get(inew); LogicQueueMappingItem newItem = newItems.get(inew);
LogicQueueMappingItem oldItem = oldItems.get(iold); LogicQueueMappingItem oldItem = oldItems.get(iold);
if (newItem.getGen() < oldItem.getGen()) { if (newItem.getGen() < oldItem.getGen()) {
//the old one may have been deleted //the earliest item may have been deleted concurrently
inew++; inew++;
} else if (oldItem.getGen() < newItem.getGen()){ } else if (oldItem.getGen() < newItem.getGen()){
//the new one may be the "delete one from " //in the following cases, the new item-list has less items than old item-list
if (isCLean) { //1. the queue is mapped back to a broker which hold the logic queue before
iold++; //2. The earliest item is deleted by TopicQueueMappingCleanService
} else { iold++;
throw new RuntimeException("The new item-list has less items than old item-list");
}
} else { } else {
assert oldItem.getBname().equals(newItem.getBname()); assert oldItem.getBname().equals(newItem.getBname());
assert oldItem.getQueueId() == newItem.getQueueId(); assert oldItem.getQueueId() == newItem.getQueueId();
......
...@@ -56,6 +56,8 @@ public class BaseConf { ...@@ -56,6 +56,8 @@ public class BaseConf {
public final static String nsAddr; public final static String nsAddr;
protected final static String broker1Name; protected final static String broker1Name;
protected final static String broker2Name; protected final static String broker2Name;
//the logic queue test need at least three brokers
protected final static String broker3Name;
protected final static String clusterName; protected final static String clusterName;
protected final static int brokerNum; protected final static int brokerNum;
protected final static int waitTime = 5; protected final static int waitTime = 5;
...@@ -64,6 +66,7 @@ public class BaseConf { ...@@ -64,6 +66,7 @@ public class BaseConf {
protected final static NamesrvController namesrvController; protected final static NamesrvController namesrvController;
protected final static BrokerController brokerController1; protected final static BrokerController brokerController1;
protected final static BrokerController brokerController2; protected final static BrokerController brokerController2;
protected final static BrokerController brokerController3;
protected final static List<BrokerController> brokerControllerList; protected final static List<BrokerController> brokerControllerList;
protected final static Map<String, BrokerController> brokerControllerMap; protected final static Map<String, BrokerController> brokerControllerMap;
protected final static List<Object> mqClients = new ArrayList<Object>(); protected final static List<Object> mqClients = new ArrayList<Object>();
...@@ -76,11 +79,13 @@ public class BaseConf { ...@@ -76,11 +79,13 @@ public class BaseConf {
nsAddr = "127.0.0.1:" + namesrvController.getNettyServerConfig().getListenPort(); nsAddr = "127.0.0.1:" + namesrvController.getNettyServerConfig().getListenPort();
brokerController1 = IntegrationTestBase.createAndStartBroker(nsAddr); brokerController1 = IntegrationTestBase.createAndStartBroker(nsAddr);
brokerController2 = IntegrationTestBase.createAndStartBroker(nsAddr); brokerController2 = IntegrationTestBase.createAndStartBroker(nsAddr);
brokerController3 = IntegrationTestBase.createAndStartBroker(nsAddr);
clusterName = brokerController1.getBrokerConfig().getBrokerClusterName(); clusterName = brokerController1.getBrokerConfig().getBrokerClusterName();
broker1Name = brokerController1.getBrokerConfig().getBrokerName(); broker1Name = brokerController1.getBrokerConfig().getBrokerName();
broker2Name = brokerController2.getBrokerConfig().getBrokerName(); broker2Name = brokerController2.getBrokerConfig().getBrokerName();
brokerNum = 2; broker3Name = brokerController3.getBrokerConfig().getBrokerName();
brokerControllerList = ImmutableList.of(brokerController1, brokerController2); brokerNum = 3;
brokerControllerList = ImmutableList.of(brokerController1, brokerController2, brokerController3);
brokerControllerMap = brokerControllerList.stream().collect(Collectors.toMap(input -> input.getBrokerConfig().getBrokerName(), Function.identity())); brokerControllerMap = brokerControllerList.stream().collect(Collectors.toMap(input -> input.getBrokerConfig().getBrokerName(), Function.identity()));
} }
...@@ -214,6 +219,7 @@ public class BaseConf { ...@@ -214,6 +219,7 @@ public class BaseConf {
Set<String> brokers = new HashSet<>(); Set<String> brokers = new HashSet<>();
brokers.add(broker1Name); brokers.add(broker1Name);
brokers.add(broker2Name); brokers.add(broker2Name);
brokers.add(broker3Name);
return brokers; return brokers;
} }
......
...@@ -60,7 +60,7 @@ public class StaticTopicIT extends BaseConf { ...@@ -60,7 +60,7 @@ public class StaticTopicIT extends BaseConf {
targetBrokers.add(broker1Name); targetBrokers.add(broker1Name);
MQAdminTestUtils.createStaticTopic(topic, queueNum, targetBrokers, defaultMQAdminExt); MQAdminTestUtils.createStaticTopic(topic, queueNum, targetBrokers, defaultMQAdminExt);
Map<String, TopicConfigAndQueueMapping> remoteBrokerConfigMap = MQAdminUtils.examineTopicConfigAll(topic, defaultMQAdminExt); Map<String, TopicConfigAndQueueMapping> remoteBrokerConfigMap = MQAdminUtils.examineTopicConfigAll(topic, defaultMQAdminExt);
Assert.assertEquals(2, remoteBrokerConfigMap.size()); Assert.assertEquals(brokerNum, remoteBrokerConfigMap.size());
TopicQueueMappingUtils.checkNameEpochNumConsistence(topic, remoteBrokerConfigMap); TopicQueueMappingUtils.checkNameEpochNumConsistence(topic, remoteBrokerConfigMap);
Map<Integer, TopicQueueMappingOne> globalIdMap = TopicQueueMappingUtils.checkAndBuildMappingItems(new ArrayList<>(getMappingDetailFromConfig(remoteBrokerConfigMap.values())), false, true); Map<Integer, TopicQueueMappingOne> globalIdMap = TopicQueueMappingUtils.checkAndBuildMappingItems(new ArrayList<>(getMappingDetailFromConfig(remoteBrokerConfigMap.values())), false, true);
Assert.assertEquals(queueNum, globalIdMap.size()); Assert.assertEquals(queueNum, globalIdMap.size());
...@@ -75,7 +75,7 @@ public class StaticTopicIT extends BaseConf { ...@@ -75,7 +75,7 @@ public class StaticTopicIT extends BaseConf {
targetBrokers.add(broker2Name); targetBrokers.add(broker2Name);
MQAdminTestUtils.remappingStaticTopic(topic, targetBrokers, defaultMQAdminExt); MQAdminTestUtils.remappingStaticTopic(topic, targetBrokers, defaultMQAdminExt);
Map<String, TopicConfigAndQueueMapping> remoteBrokerConfigMap = MQAdminUtils.examineTopicConfigAll(topic, defaultMQAdminExt); Map<String, TopicConfigAndQueueMapping> remoteBrokerConfigMap = MQAdminUtils.examineTopicConfigAll(topic, defaultMQAdminExt);
Assert.assertEquals(2, remoteBrokerConfigMap.size()); Assert.assertEquals(brokerNum, remoteBrokerConfigMap.size());
TopicQueueMappingUtils.checkNameEpochNumConsistence(topic, remoteBrokerConfigMap); TopicQueueMappingUtils.checkNameEpochNumConsistence(topic, remoteBrokerConfigMap);
Map<Integer, TopicQueueMappingOne> globalIdMap = TopicQueueMappingUtils.checkAndBuildMappingItems(new ArrayList<>(getMappingDetailFromConfig(remoteBrokerConfigMap.values())), false, true); Map<Integer, TopicQueueMappingOne> globalIdMap = TopicQueueMappingUtils.checkAndBuildMappingItems(new ArrayList<>(getMappingDetailFromConfig(remoteBrokerConfigMap.values())), false, true);
Assert.assertEquals(queueNum, globalIdMap.size()); Assert.assertEquals(queueNum, globalIdMap.size());
...@@ -97,7 +97,7 @@ public class StaticTopicIT extends BaseConf { ...@@ -97,7 +97,7 @@ public class StaticTopicIT extends BaseConf {
//check the static topic config //check the static topic config
{ {
Map<String, TopicConfigAndQueueMapping> remoteBrokerConfigMap = MQAdminUtils.examineTopicConfigAll(topic, defaultMQAdminExt); Map<String, TopicConfigAndQueueMapping> remoteBrokerConfigMap = MQAdminUtils.examineTopicConfigAll(topic, defaultMQAdminExt);
Assert.assertEquals(2, remoteBrokerConfigMap.size()); Assert.assertEquals(brokerNum, remoteBrokerConfigMap.size());
for (Map.Entry<String, TopicConfigAndQueueMapping> entry: remoteBrokerConfigMap.entrySet()) { for (Map.Entry<String, TopicConfigAndQueueMapping> entry: remoteBrokerConfigMap.entrySet()) {
String broker = entry.getKey(); String broker = entry.getKey();
TopicConfigAndQueueMapping configMapping = entry.getValue(); TopicConfigAndQueueMapping configMapping = entry.getValue();
...@@ -356,6 +356,8 @@ public class StaticTopicIT extends BaseConf { ...@@ -356,6 +356,8 @@ public class StaticTopicIT extends BaseConf {
} }
} }
@Test @Test
public void testRemappingWithNegativeLogicOffset() throws Exception { public void testRemappingWithNegativeLogicOffset() throws Exception {
String topic = "static" + MQRandomUtils.getRandomTopic(); String topic = "static" + MQRandomUtils.getRandomTopic();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册