You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ca...@apache.org on 2022/11/29 12:24:44 UTC

[iotdb] branch beyyes/doc created (now 6ecf315a0c)

This is an automated email from the ASF dual-hosted git repository.

caogaofei pushed a change to branch beyyes/doc
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 6ecf315a0c add schemaregion test for IoTDBCustomRegionGroupExtensionIT

This branch includes the following new commits:

     new 6ecf315a0c add schemaregion test for IoTDBCustomRegionGroupExtensionIT

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/01: add schemaregion test for IoTDBCustomRegionGroupExtensionIT

Posted by ca...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

caogaofei pushed a commit to branch beyyes/doc
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 6ecf315a0c6c0583a442230bb67aa6fcc43b3880
Author: Beyyes <cg...@foxmail.com>
AuthorDate: Tue Nov 29 20:21:46 2022 +0800

    add schemaregion test for IoTDBCustomRegionGroupExtensionIT
---
 .../IoTDBCustomRegionGroupExtensionIT.java         | 37 ++++++++++++++++++----
 1 file changed, 31 insertions(+), 6 deletions(-)

diff --git a/integration-test/src/test/java/org/apache/iotdb/confignode/it/partition/IoTDBCustomRegionGroupExtensionIT.java b/integration-test/src/test/java/org/apache/iotdb/confignode/it/partition/IoTDBCustomRegionGroupExtensionIT.java
index 6f316a8a5b..66ea5ded54 100644
--- a/integration-test/src/test/java/org/apache/iotdb/confignode/it/partition/IoTDBCustomRegionGroupExtensionIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/confignode/it/partition/IoTDBCustomRegionGroupExtensionIT.java
@@ -18,12 +18,16 @@
  */
 package org.apache.iotdb.confignode.it.partition;
 
+import org.apache.iotdb.common.rpc.thrift.TConsensusGroupType;
 import org.apache.iotdb.common.rpc.thrift.TSStatus;
 import org.apache.iotdb.common.rpc.thrift.TSeriesPartitionSlot;
 import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
+import org.apache.iotdb.commons.exception.IllegalPathException;
 import org.apache.iotdb.confignode.it.utils.ConfigNodeTestUtils;
 import org.apache.iotdb.confignode.rpc.thrift.TDataPartitionReq;
 import org.apache.iotdb.confignode.rpc.thrift.TDataPartitionTableResp;
+import org.apache.iotdb.confignode.rpc.thrift.TSchemaPartitionReq;
+import org.apache.iotdb.confignode.rpc.thrift.TSchemaPartitionTableResp;
 import org.apache.iotdb.confignode.rpc.thrift.TSetStorageGroupReq;
 import org.apache.iotdb.confignode.rpc.thrift.TShowRegionReq;
 import org.apache.iotdb.confignode.rpc.thrift.TShowRegionResp;
@@ -46,9 +50,12 @@ import org.junit.experimental.categories.Category;
 import org.junit.runner.RunWith;
 
 import java.io.IOException;
+import java.nio.ByteBuffer;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import static org.apache.iotdb.confignode.it.utils.ConfigNodeTestUtils.generatePatternTreeBuffer;
+
 @RunWith(IoTDBTestRunner.class)
 @Category({ClusterIT.class})
 public class IoTDBCustomRegionGroupExtensionIT {
@@ -67,7 +74,7 @@ public class IoTDBCustomRegionGroupExtensionIT {
   private static int originalSchemaRegionGroupPerDatabase;
   private static final int testSchemaRegionGroupPerDatabase = 2;
   private static int originalDataRegionGroupPerDatabase;
-  private static final int testDataRegionGroupPerDatabase = 2;
+  private static final int testDataRegionGroupPerDatabase = 3;
 
   private static int originalSchemaReplicationFactor;
   private static int originalDataReplicationFactor;
@@ -125,7 +132,7 @@ public class IoTDBCustomRegionGroupExtensionIT {
 
   @Test
   public void testCustomDataRegionGroupExtensionPolicy()
-      throws IOException, InterruptedException, TException {
+      throws IOException, InterruptedException, TException, IllegalPathException {
     try (SyncConfigNodeIServiceClient client =
         (SyncConfigNodeIServiceClient) EnvFactory.getEnv().getLeaderConfigNodeConnection()) {
 
@@ -147,21 +154,39 @@ public class IoTDBCustomRegionGroupExtensionIT {
             TSStatusCode.SUCCESS_STATUS.getStatusCode(),
             dataPartitionTableResp.getStatus().getCode());
 
+        ByteBuffer patternTree = generatePatternTreeBuffer(new String[] {curSg + ".d1.s1"});
+        TSchemaPartitionReq schemaPartitionReq = new TSchemaPartitionReq(patternTree);
+        TSchemaPartitionTableResp schemaPartitionTableResp =
+            client.getOrCreateSchemaPartitionTable(schemaPartitionReq);
+        Assert.assertEquals(
+            TSStatusCode.SUCCESS_STATUS.getStatusCode(),
+            schemaPartitionTableResp.getStatus().getCode());
+
         /* Check the number of DataRegionGroups */
         TShowRegionResp showRegionReq = client.showRegion(new TShowRegionReq());
         Assert.assertEquals(
             TSStatusCode.SUCCESS_STATUS.getStatusCode(), showRegionReq.getStatus().getCode());
-        AtomicInteger regionCount = new AtomicInteger(0);
+        AtomicInteger dataRegionCount = new AtomicInteger(0);
+        AtomicInteger schemaRegionCount = new AtomicInteger(0);
         showRegionReq
             .getRegionInfoList()
             .forEach(
                 regionInfo -> {
-                  if (regionInfo.getStorageGroup().equals(curSg)) {
-                    regionCount.getAndIncrement();
+                  if (regionInfo.getStorageGroup().equals(curSg)
+                      && TConsensusGroupType.DataRegion.equals(
+                          regionInfo.getConsensusGroupId().getType())) {
+                    dataRegionCount.getAndIncrement();
+                  }
+                  if (regionInfo.getStorageGroup().equals(curSg)
+                      && TConsensusGroupType.SchemaRegion.equals(
+                          regionInfo.getConsensusGroupId().getType())) {
+                    schemaRegionCount.getAndIncrement();
                   }
                 });
         Assert.assertEquals(
-            testDataRegionGroupPerDatabase * testReplicationFactor, regionCount.get());
+            testDataRegionGroupPerDatabase * testReplicationFactor, dataRegionCount.get());
+        Assert.assertEquals(
+            testSchemaRegionGroupPerDatabase * testReplicationFactor, schemaRegionCount.get());
       }
     }
   }