From 0f6b5a3debc7cbef561213088238a1a26ed43a40 Mon Sep 17 00:00:00 2001 From: zhoubo <877036922@qq.com> Date: Fri, 27 Aug 2021 10:19:54 +0800 Subject: [PATCH] [ISSUE #3290] Test case testProcessRequest_RegisterBrokerLogicalQueue bug fix (#3291) * test case testProcessRequest_RegisterBrokerLogicalQueue bug fix * fix test case MQClientInstanceTest.init error * upgrade mockito to 3.12.4 * change reuseForks to false * rollback MQClientInstanceTest modify --- .../processor/DefaultRequestProcessorTest.java | 15 ++++++++++++--- pom.xml | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/namesrv/src/test/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessorTest.java b/namesrv/src/test/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessorTest.java index ff477a3e..97e61263 100644 --- a/namesrv/src/test/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessorTest.java +++ b/namesrv/src/test/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessorTest.java @@ -29,6 +29,7 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.rocketmq.common.DataVersion; +import org.apache.rocketmq.common.MQVersion; import org.apache.rocketmq.common.MixAll; import org.apache.rocketmq.common.TopicConfig; import org.apache.rocketmq.common.message.MessageQueue; @@ -36,6 +37,7 @@ import org.apache.rocketmq.common.namesrv.NamesrvConfig; import org.apache.rocketmq.common.namesrv.RegisterBrokerResult; import org.apache.rocketmq.common.protocol.RequestCode; import org.apache.rocketmq.common.protocol.ResponseCode; +import org.apache.rocketmq.common.protocol.body.RegisterBrokerBody; import org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper; import org.apache.rocketmq.common.protocol.header.namesrv.DeleteKVConfigRequestHeader; import org.apache.rocketmq.common.protocol.header.namesrv.GetKVConfigRequestHeader; @@ -56,7 +58,6 @@ import org.apache.rocketmq.namesrv.routeinfo.RouteInfoManager; import org.apache.rocketmq.remoting.exception.RemotingCommandException; import org.apache.rocketmq.remoting.netty.NettyServerConfig; import org.apache.rocketmq.remoting.protocol.RemotingCommand; -import org.apache.rocketmq.remoting.protocol.RemotingSerializable; import org.assertj.core.util.Maps; import org.junit.Before; import org.junit.Test; @@ -219,13 +220,17 @@ public class DefaultRequestProcessorTest { request.addExtField("clusterName", cluster); request.addExtField("haServerAddr", "10.10.2.1"); request.addExtField("brokerId", String.valueOf(MixAll.MASTER_ID)); + request.setVersion(MQVersion.CURRENT_VERSION); TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); topicConfigSerializeWrapper.setTopicConfigTable(new ConcurrentHashMap<>(Collections.singletonMap(topic, new TopicConfig(topic)))); topicConfigSerializeWrapper.setLogicalQueuesInfoMap(Maps.newHashMap(topic, new LogicalQueuesInfo(Collections.singletonMap(0, Lists.newArrayList( queueRouteData1 ))))); topicConfigSerializeWrapper.setDataVersion(new DataVersion()); - request.setBody(RemotingSerializable.encode(topicConfigSerializeWrapper)); + RegisterBrokerBody requestBody = new RegisterBrokerBody(); + requestBody.setTopicConfigSerializeWrapper(topicConfigSerializeWrapper); + requestBody.setFilterServerList(Lists.newArrayList()); + request.setBody(requestBody.encode()); ChannelHandlerContext ctx = mock(ChannelHandlerContext.class); when(ctx.channel()).thenReturn(null); @@ -247,6 +252,7 @@ public class DefaultRequestProcessorTest { request.addExtField("clusterName", cluster); request.addExtField("haServerAddr", "10.10.2.1"); request.addExtField("brokerId", String.valueOf(MixAll.MASTER_ID)); + request.setVersion(MQVersion.CURRENT_VERSION); TopicConfigSerializeWrapper topicConfigSerializeWrapper = new TopicConfigSerializeWrapper(); topicConfigSerializeWrapper.setTopicConfigTable(new ConcurrentHashMap<>(Collections.singletonMap(topic, new TopicConfig(topic)))); topicConfigSerializeWrapper.setLogicalQueuesInfoMap(Maps.newHashMap(topic, new LogicalQueuesInfo(ImmutableMap.of( @@ -254,7 +260,10 @@ public class DefaultRequestProcessorTest { 1, Collections.singletonList(queueRouteData3) )))); topicConfigSerializeWrapper.setDataVersion(new DataVersion()); - request.setBody(RemotingSerializable.encode(topicConfigSerializeWrapper)); + RegisterBrokerBody requestBody = new RegisterBrokerBody(); + requestBody.setTopicConfigSerializeWrapper(topicConfigSerializeWrapper); + requestBody.setFilterServerList(Lists.newArrayList()); + request.setBody(requestBody.encode()); ChannelHandlerContext ctx = mock(ChannelHandlerContext.class); when(ctx.channel()).thenReturn(null); diff --git a/pom.xml b/pom.xml index c6e039e5..18621a1f 100644 --- a/pom.xml +++ b/pom.xml @@ -302,7 +302,7 @@ 1 1 - true + false **/IT*.java -- GitLab