This is an automated email from the ASF dual-hosted git repository.
jt2594838 pushed a commit to branch rc/2.0.12
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/rc/2.0.12 by this push:
new da407eecef3 remove unnecessary test
da407eecef3 is described below
commit da407eecef346d2a5aae0f9ef83888d199b41c9b
Author: Tian Jiang <[email protected]>
AuthorDate: Tue Oct 20 22:04:04 2026 +0800
remove unnecessary test
---
.../manager/node/NodeManagerRegistrationTest.java | 175 ---------------------
.../iotdb/confignode/persistence/NodeInfoTest.java | 111 -------------
2 files changed, 286 deletions(-)
diff --git
a/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/node/NodeManagerRegistrationTest.java
b/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/node/NodeManagerRegistrationTest.java
deleted file mode 100644
index 606c57a0bfd..00000000000
---
a/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/node/NodeManagerRegistrationTest.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.confignode.manager.node;
-
-import org.apache.iotdb.common.rpc.thrift.TDataNodeConfiguration;
-import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
-import org.apache.iotdb.common.rpc.thrift.TEndPoint;
-import org.apache.iotdb.common.rpc.thrift.TSStatus;
-import org.apache.iotdb.commons.cluster.NodeType;
-import org.apache.iotdb.confignode.consensus.request.ConfigPhysicalPlan;
-import
org.apache.iotdb.confignode.consensus.request.write.confignode.UpdateVersionInfoPlan;
-import
org.apache.iotdb.confignode.consensus.request.write.datanode.RegisterDataNodePlan;
-import
org.apache.iotdb.confignode.consensus.request.write.datanode.RemoveDataNodePlan;
-import
org.apache.iotdb.confignode.consensus.response.datanode.DataNodeRegisterResp;
-import org.apache.iotdb.confignode.i18n.ConfigNodeMessages;
-import org.apache.iotdb.confignode.manager.ClusterManager;
-import org.apache.iotdb.confignode.manager.IManager;
-import org.apache.iotdb.confignode.manager.consensus.ConsensusManager;
-import org.apache.iotdb.confignode.manager.load.LoadManager;
-import org.apache.iotdb.confignode.manager.load.cache.LoadCache;
-import org.apache.iotdb.confignode.manager.schema.ClusterSchemaManager;
-import org.apache.iotdb.confignode.persistence.node.NodeInfo;
-import org.apache.iotdb.confignode.rpc.thrift.TDataNodeRegisterReq;
-import org.apache.iotdb.confignode.rpc.thrift.TDataNodeRestartReq;
-import org.apache.iotdb.confignode.rpc.thrift.TDataNodeRestartResp;
-import org.apache.iotdb.confignode.rpc.thrift.TNodeVersionInfo;
-import org.apache.iotdb.consensus.exception.ConsensusException;
-import org.apache.iotdb.rpc.TSStatusCode;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mockito;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.ArgumentMatchers.anyLong;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class NodeManagerRegistrationTest {
-
- private IManager configManager;
- private ConsensusManager consensusManager;
- private LoadManager loadManager;
- private LoadCache loadCache;
- private ClusterSchemaManager clusterSchemaManager;
- private ClusterManager clusterManager;
- private NodeInfo nodeInfo;
- private NodeManager nodeManager;
-
- @Before
- public void setUp() {
- configManager = Mockito.mock(IManager.class);
- consensusManager = Mockito.mock(ConsensusManager.class);
- loadManager = Mockito.mock(LoadManager.class);
- loadCache = Mockito.mock(LoadCache.class);
- clusterSchemaManager = Mockito.mock(ClusterSchemaManager.class);
- clusterManager = Mockito.mock(ClusterManager.class);
- nodeInfo = new NodeInfo();
- nodeManager = new NodeManager(configManager, nodeInfo);
-
- when(configManager.getConsensusManager()).thenReturn(consensusManager);
- when(configManager.getLoadManager()).thenReturn(loadManager);
- when(loadManager.getLoadCache()).thenReturn(loadCache);
-
when(configManager.getClusterSchemaManager()).thenReturn(clusterSchemaManager);
- when(configManager.getClusterManager()).thenReturn(clusterManager);
- }
-
- @Test
- public void testRegisterDataNodeStopsWhenRegisterWriteFails() throws
ConsensusException {
- TSStatus failureStatus =
- new
TSStatus(TSStatusCode.REDIRECTION_RECOMMEND.getStatusCode()).setMessage("redirect");
- when(consensusManager.write(any())).thenReturn(failureStatus);
-
- DataNodeRegisterResp resp =
- (DataNodeRegisterResp)
nodeManager.registerDataNode(generateDataNodeRegisterReq(1));
-
- Assert.assertEquals(failureStatus, resp.getStatus());
- verify(loadCache, never()).createNodeHeartbeatCache(eq(NodeType.DataNode),
anyInt());
- verify(clusterSchemaManager, never()).adjustMaxRegionGroupNum();
- }
-
- @Test
- public void testRegisterDataNodeRollsBackWhenVersionWriteFails() throws
ConsensusException {
- TSStatus successStatus = new
TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode());
- TSStatus failureStatus =
- new TSStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode())
- .setMessage("update failed");
- when(consensusManager.write(any())).thenReturn(successStatus,
failureStatus, successStatus);
-
- DataNodeRegisterResp resp =
- (DataNodeRegisterResp)
nodeManager.registerDataNode(generateDataNodeRegisterReq(1));
-
- Assert.assertEquals(
- TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode(),
resp.getStatus().getCode());
- Assert.assertEquals(
- String.format(
- ConfigNodeMessages
-
.MESSAGE_FAILED_TO_PERSIST_VERSION_INFO_FOR_DATANODE_ARG_ARG_THE_REGISTRATION_HAS_BEEN_ROLLED_BACK_PLEASE_RETRY_THE_REGISTRATION_5DDB311F,
- 0,
- failureStatus.getMessage()),
- resp.getStatus().getMessage());
- verify(loadCache, never()).createNodeHeartbeatCache(eq(NodeType.DataNode),
anyInt());
- verify(clusterSchemaManager, never()).adjustMaxRegionGroupNum();
-
- ArgumentCaptor<ConfigPhysicalPlan> planCaptor =
- ArgumentCaptor.forClass(ConfigPhysicalPlan.class);
- verify(consensusManager, Mockito.times(3)).write(planCaptor.capture());
- Assert.assertTrue(planCaptor.getAllValues().get(0) instanceof
RegisterDataNodePlan);
- Assert.assertTrue(planCaptor.getAllValues().get(1) instanceof
UpdateVersionInfoPlan);
- Assert.assertTrue(planCaptor.getAllValues().get(2) instanceof
RemoveDataNodePlan);
- }
-
- @Test
- public void testRestartDataNodeReturnsFailureWhenUpdateWriteFails() throws
ConsensusException {
- final TDataNodeConfiguration registeredConfig =
generateDataNodeConfiguration(1, "127.0.0.1");
- nodeInfo.registerDataNode(new RegisterDataNodePlan(registeredConfig));
-
when(clusterManager.getClusterIdWithRetry(anyLong())).thenReturn("cluster");
-
- TSStatus failureStatus =
- new TSStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode())
- .setMessage("update failed");
- when(consensusManager.write(any())).thenReturn(failureStatus);
-
- final TDataNodeRestartReq req = new TDataNodeRestartReq();
- req.setDataNodeConfiguration(generateDataNodeConfiguration(1,
"127.0.0.2"));
- req.setVersionInfo(new TNodeVersionInfo("version", "build"));
-
- final TDataNodeRestartResp resp =
nodeManager.updateDataNodeIfNecessary(req);
-
- Assert.assertEquals(failureStatus, resp.getStatus());
- }
-
- private TDataNodeRegisterReq generateDataNodeRegisterReq(int dataNodeId) {
- final TDataNodeRegisterReq req = new TDataNodeRegisterReq();
- req.setDataNodeConfiguration(generateDataNodeConfiguration(dataNodeId,
"127.0.0.1"));
- req.setVersionInfo(new TNodeVersionInfo("version", "build"));
- return req;
- }
-
- private TDataNodeConfiguration generateDataNodeConfiguration(int dataNodeId,
String ip) {
- final TDataNodeLocation dataNodeLocation = new TDataNodeLocation();
- dataNodeLocation.setDataNodeId(dataNodeId);
- dataNodeLocation.setClientRpcEndPoint(new TEndPoint(ip, 6667 +
dataNodeId));
- dataNodeLocation.setInternalEndPoint(new TEndPoint(ip, 10730 +
dataNodeId));
- dataNodeLocation.setMPPDataExchangeEndPoint(new TEndPoint(ip, 10740 +
dataNodeId));
- dataNodeLocation.setDataRegionConsensusEndPoint(new TEndPoint(ip, 10760 +
dataNodeId));
- dataNodeLocation.setSchemaRegionConsensusEndPoint(new TEndPoint(ip, 10750
+ dataNodeId));
-
- final TDataNodeConfiguration dataNodeConfiguration = new
TDataNodeConfiguration();
- dataNodeConfiguration.setLocation(dataNodeLocation);
- return dataNodeConfiguration;
- }
-}
diff --git
a/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/persistence/NodeInfoTest.java
b/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/persistence/NodeInfoTest.java
deleted file mode 100644
index e3ced5b0694..00000000000
---
a/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/persistence/NodeInfoTest.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.iotdb.confignode.persistence;
-
-import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
-import org.apache.iotdb.common.rpc.thrift.TDataNodeConfiguration;
-import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
-import org.apache.iotdb.common.rpc.thrift.TEndPoint;
-import org.apache.iotdb.common.rpc.thrift.TNodeResource;
-import org.apache.iotdb.commons.exception.StartupException;
-import
org.apache.iotdb.confignode.consensus.request.write.confignode.ApplyConfigNodePlan;
-import
org.apache.iotdb.confignode.consensus.request.write.datanode.RegisterDataNodePlan;
-import org.apache.iotdb.confignode.persistence.node.NodeInfo;
-
-import org.apache.thrift.TException;
-import org.apache.tsfile.external.commons.io.FileUtils;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.File;
-import java.io.IOException;
-
-import static org.apache.iotdb.db.utils.constant.TestConstant.BASE_OUTPUT_PATH;
-
-public class NodeInfoTest {
-
- private static NodeInfo nodeInfo;
- private static final File snapshotDir = new File(BASE_OUTPUT_PATH,
"snapshot");
-
- @BeforeClass
- public static void setup() throws StartupException {
- nodeInfo = new NodeInfo();
- if (!snapshotDir.exists()) {
- snapshotDir.mkdirs();
- }
- }
-
- @AfterClass
- public static void cleanup() throws IOException {
- nodeInfo.clear();
- if (snapshotDir.exists()) {
- FileUtils.deleteDirectory(snapshotDir);
- }
- }
-
- @Test
- public void testSnapshot() throws TException, IOException {
- registerConfigNodes();
- registerDataNodes();
- Assert.assertTrue(nodeInfo.processTakeSnapshot(snapshotDir));
-
- NodeInfo nodeInfo1 = new NodeInfo();
- nodeInfo1.processLoadSnapshot(snapshotDir);
- Assert.assertEquals(nodeInfo, nodeInfo1);
- }
-
- private void registerConfigNodes() {
- for (int i = 0; i < 3; i++) {
- ApplyConfigNodePlan applyConfigNodePlan =
- new ApplyConfigNodePlan(
- new TConfigNodeLocation(
- 10000 + i,
- new TEndPoint("127.0.0.1", 22200 + i),
- new TEndPoint("127.0.0.1", 22300 + i)));
- nodeInfo.applyConfigNode(applyConfigNodePlan);
- }
- }
-
- private void registerDataNodes() {
- for (int i = 3; i < 6; i++) {
- RegisterDataNodePlan registerDataNodePlan =
- new RegisterDataNodePlan(generateTDataNodeConfiguration(i));
- nodeInfo.registerDataNode(registerDataNodePlan);
- }
- }
-
- private TDataNodeConfiguration generateTDataNodeConfiguration(int flag) {
- TDataNodeLocation location = generateTDataNodeLocation(flag);
- TNodeResource resource = new TNodeResource(16, 34359738368L);
- return new TDataNodeConfiguration(location, resource);
- }
-
- private TDataNodeLocation generateTDataNodeLocation(int flag) {
- return new TDataNodeLocation(
- 10000 + flag,
- new TEndPoint("127.0.0.1", 6600 + flag),
- new TEndPoint("127.0.0.1", 7700 + flag),
- new TEndPoint("127.0.0.1", 8800 + flag),
- new TEndPoint("127.0.0.1", 9900 + flag),
- new TEndPoint("127.0.0.1", 11000 + flag));
- }
-}