You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ma...@apache.org on 2022/08/25 14:11:27 UTC
[iotdb] branch IOTDB-3455 updated: adad test
This is an automated email from the ASF dual-hosted git repository.
marklau99 pushed a commit to branch IOTDB-3455
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/IOTDB-3455 by this push:
new 309a10376d adad test
309a10376d is described below
commit 309a10376df69950d751b20171212de4f51a5687
Author: Liu Xuxin <li...@outlook.com>
AuthorDate: Thu Aug 25 22:11:19 2022 +0800
adad test
---
.../LocalConfigNodeMultiDataRegionTest.java | 98 ++++++++++++++++++++++
1 file changed, 98 insertions(+)
diff --git a/server/src/test/java/org/apache/iotdb/db/localconfignode/LocalConfigNodeMultiDataRegionTest.java b/server/src/test/java/org/apache/iotdb/db/localconfignode/LocalConfigNodeMultiDataRegionTest.java
new file mode 100644
index 0000000000..7fa637ca9b
--- /dev/null
+++ b/server/src/test/java/org/apache/iotdb/db/localconfignode/LocalConfigNodeMultiDataRegionTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.db.localconfignode;
+
+import org.apache.iotdb.commons.consensus.DataRegionId;
+import org.apache.iotdb.commons.exception.IllegalPathException;
+import org.apache.iotdb.commons.path.PartialPath;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.service.IoTDB;
+import org.apache.iotdb.db.utils.EnvironmentUtils;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.List;
+
+public class LocalConfigNodeMultiDataRegionTest {
+ int originDataRegionNum;
+ boolean isMppMode = false;
+ boolean isClusterMode = false;
+
+ @Before
+ public void setUp() throws IllegalPathException {
+ originDataRegionNum = IoTDBDescriptor.getInstance().getConfig().getDataRegionNum();
+ isMppMode = IoTDBDescriptor.getInstance().getConfig().isMppMode();
+ isClusterMode = IoTDBDescriptor.getInstance().getConfig().isClusterMode();
+ IoTDBDescriptor.getInstance().getConfig().setMppMode(true);
+ IoTDBDescriptor.getInstance().getConfig().setClusterMode(false);
+ IoTDB.configManager.init();
+ EnvironmentUtils.envSetUp();
+ LocalDataPartitionInfo.getInstance().init(Collections.EMPTY_MAP);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ IoTDBDescriptor.getInstance().getConfig().setDataRegionNum(originDataRegionNum);
+ EnvironmentUtils.cleanEnv();
+ IoTDBDescriptor.getInstance().getConfig().setMppMode(isMppMode);
+ IoTDBDescriptor.getInstance().getConfig().setClusterMode(isClusterMode);
+ }
+
+ @Test
+ public void createMultiDataRegionTest() throws Exception {
+ IoTDBDescriptor.getInstance().getConfig().setDataRegionNum(3);
+ IoTDB.schemaProcessor.setStorageGroup(new PartialPath("root.test"));
+ LocalConfigNode configNode = LocalConfigNode.getInstance();
+ LocalDataPartitionInfo info = LocalDataPartitionInfo.getInstance();
+ info.registerStorageGroup(new PartialPath("root.test"));
+ configNode.getBelongedDataRegionIdWithAutoCreate(new PartialPath("root.test.d1"));
+ configNode.getBelongedDataRegionIdWithAutoCreate(new PartialPath("root.test.d2"));
+ configNode.getBelongedDataRegionIdWithAutoCreate(new PartialPath("root.test.d3"));
+ List<DataRegionId> regionIds =
+ info.getDataRegionIdsByStorageGroup(new PartialPath("root.test"));
+ Assert.assertEquals(3, regionIds.size());
+ }
+
+ @Test
+ public void recoverMultiDataRegionTest() throws Exception {
+ IoTDBDescriptor.getInstance().getConfig().setDataRegionNum(3);
+ IoTDB.schemaProcessor.setStorageGroup(new PartialPath("root.test"));
+ LocalConfigNode configNode = LocalConfigNode.getInstance();
+ LocalDataPartitionInfo info = LocalDataPartitionInfo.getInstance();
+ info.registerStorageGroup(new PartialPath("root.test"));
+ configNode.getBelongedDataRegionIdWithAutoCreate(new PartialPath("root.test.d1"));
+ configNode.getBelongedDataRegionIdWithAutoCreate(new PartialPath("root.test.d2"));
+ configNode.getBelongedDataRegionIdWithAutoCreate(new PartialPath("root.test.d3"));
+ LocalConfigNode.getInstance().clear();
+ LocalConfigNode.getInstance().init();
+ info = LocalDataPartitionInfo.getInstance();
+ info.registerStorageGroup(new PartialPath("root.test"));
+ configNode.getBelongedDataRegionIdWithAutoCreate(new PartialPath("root.test.d1"));
+ configNode.getBelongedDataRegionIdWithAutoCreate(new PartialPath("root.test.d2"));
+ configNode.getBelongedDataRegionIdWithAutoCreate(new PartialPath("root.test.d3"));
+ List<DataRegionId> regionIds =
+ info.getDataRegionIdsByStorageGroup(new PartialPath("root.test"));
+ Assert.assertEquals(3, regionIds.size());
+ }
+}