jt2594838 commented on code in PR #18821:
URL: https://github.com/apache/iotdb/pull/18821#discussion_r4237556968


##########
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/executor/RegionWriteExecutorTest.java:
##########
@@ -22,32 +22,248 @@
 import org.apache.iotdb.common.rpc.thrift.TSStatus;
 import org.apache.iotdb.commons.consensus.ConsensusGroupId;
 import org.apache.iotdb.commons.consensus.DataRegionId;
+import org.apache.iotdb.commons.consensus.SchemaRegionId;
 import org.apache.iotdb.commons.exception.IllegalPathException;
+import org.apache.iotdb.commons.path.MeasurementPath;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.commons.queryengine.plan.planner.plan.node.PlanNodeId;
+import 
org.apache.iotdb.commons.schema.view.viewExpression.leaf.TimeSeriesViewOperand;
+import org.apache.iotdb.consensus.ConsensusFactory;
 import org.apache.iotdb.consensus.IConsensus;
 import org.apache.iotdb.consensus.exception.ConsensusException;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.protocol.thrift.impl.DataNodeRegionManager;
+import org.apache.iotdb.db.queryengine.plan.planner.plan.node.WritePlanNode;
+import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.AlterTimeSeriesNode;
+import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.InternalCreateMultiTimeSeriesNode;
+import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.InternalCreateTimeSeriesNode;
+import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.MeasurementGroup;
+import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.view.CreateLogicalViewNode;
+import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.pipe.PipeEnrichedWritePlanNode;
 import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.write.InsertRowNode;
+import 
org.apache.iotdb.db.queryengine.plan.relational.planner.node.schema.CreateOrUpdateTableDeviceNode;
+import 
org.apache.iotdb.db.queryengine.plan.statement.metadata.AlterTimeSeriesStatement.AlterType;
 import org.apache.iotdb.db.schemaengine.SchemaEngine;
+import org.apache.iotdb.db.schemaengine.schemaregion.ISchemaRegion;
 import org.apache.iotdb.db.schemaengine.template.ClusterTemplateManager;
 import org.apache.iotdb.db.trigger.executor.TriggerFireResult;
 import org.apache.iotdb.db.trigger.executor.TriggerFireVisitor;
 import org.apache.iotdb.rpc.TSStatusCode;
 import org.apache.iotdb.trigger.api.enums.TriggerEvent;
 
 import org.apache.tsfile.enums.TSDataType;
+import org.apache.tsfile.file.metadata.enums.CompressionType;
+import org.apache.tsfile.file.metadata.enums.TSEncoding;
+import org.apache.tsfile.utils.Pair;
 import org.junit.Test;
 import org.mockito.Mockito;
 
+import java.util.Collections;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 public class RegionWriteExecutorTest {
 
+  @Test
+  public void testAlterTimeSeriesRegionAvailability() throws Exception {
+    // Alter validation fetches the measurement before consensus; a missing 
region must be
+    // retryable.
+    checkSchemaWriteWithRegionAvailability(
+        new AlterTimeSeriesNode(
+            new PlanNodeId("alter"),
+            new MeasurementPath("root.sg.d.s"),
+            AlterType.ADD_TAGS,
+            Collections.singletonMap("tag", "value"),
+            null,
+            null,
+            null,
+            false));
+  }
+
+  @Test
+  public void testCreateLogicalViewRegionAvailability() throws Exception {
+    // Ratis checks target existence locally. SimpleConsensus must retain its 
direct write path.
+    checkSchemaWriteWithRegionAvailability(
+        new CreateLogicalViewNode(
+            new PlanNodeId("view"),
+            Collections.singletonMap(
+                new MeasurementPath("root.sg.d.v"), new 
TimeSeriesViewOperand("root.sg.d.s"))));
+  }
+
+  @Test
+  public void testCreateOrUpdateTableDeviceRegionAvailability() throws 
Exception {

Review Comment:
   This regression test covers table-device quota validation during the same 
region-cleared window. It verifies retryable failure without consensus writes, 
plus successful quota validation and writes when the region is available.



##########
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/executor/RegionWriteExecutorTest.java:
##########
@@ -22,32 +22,248 @@
 import org.apache.iotdb.common.rpc.thrift.TSStatus;
 import org.apache.iotdb.commons.consensus.ConsensusGroupId;
 import org.apache.iotdb.commons.consensus.DataRegionId;
+import org.apache.iotdb.commons.consensus.SchemaRegionId;
 import org.apache.iotdb.commons.exception.IllegalPathException;
+import org.apache.iotdb.commons.path.MeasurementPath;
 import org.apache.iotdb.commons.path.PartialPath;
 import org.apache.iotdb.commons.queryengine.plan.planner.plan.node.PlanNodeId;
+import 
org.apache.iotdb.commons.schema.view.viewExpression.leaf.TimeSeriesViewOperand;
+import org.apache.iotdb.consensus.ConsensusFactory;
 import org.apache.iotdb.consensus.IConsensus;
 import org.apache.iotdb.consensus.exception.ConsensusException;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.protocol.thrift.impl.DataNodeRegionManager;
+import org.apache.iotdb.db.queryengine.plan.planner.plan.node.WritePlanNode;
+import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.AlterTimeSeriesNode;
+import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.InternalCreateMultiTimeSeriesNode;
+import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.InternalCreateTimeSeriesNode;
+import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.MeasurementGroup;
+import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.view.CreateLogicalViewNode;
+import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.pipe.PipeEnrichedWritePlanNode;
 import 
org.apache.iotdb.db.queryengine.plan.planner.plan.node.write.InsertRowNode;
+import 
org.apache.iotdb.db.queryengine.plan.relational.planner.node.schema.CreateOrUpdateTableDeviceNode;
+import 
org.apache.iotdb.db.queryengine.plan.statement.metadata.AlterTimeSeriesStatement.AlterType;
 import org.apache.iotdb.db.schemaengine.SchemaEngine;
+import org.apache.iotdb.db.schemaengine.schemaregion.ISchemaRegion;
 import org.apache.iotdb.db.schemaengine.template.ClusterTemplateManager;
 import org.apache.iotdb.db.trigger.executor.TriggerFireResult;
 import org.apache.iotdb.db.trigger.executor.TriggerFireVisitor;
 import org.apache.iotdb.rpc.TSStatusCode;
 import org.apache.iotdb.trigger.api.enums.TriggerEvent;
 
 import org.apache.tsfile.enums.TSDataType;
+import org.apache.tsfile.file.metadata.enums.CompressionType;
+import org.apache.tsfile.file.metadata.enums.TSEncoding;
+import org.apache.tsfile.utils.Pair;
 import org.junit.Test;
 import org.mockito.Mockito;
 
+import java.util.Collections;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 public class RegionWriteExecutorTest {
 
+  @Test
+  public void testAlterTimeSeriesRegionAvailability() throws Exception {
+    // Alter validation fetches the measurement before consensus; a missing 
region must be
+    // retryable.
+    checkSchemaWriteWithRegionAvailability(
+        new AlterTimeSeriesNode(
+            new PlanNodeId("alter"),
+            new MeasurementPath("root.sg.d.s"),
+            AlterType.ADD_TAGS,
+            Collections.singletonMap("tag", "value"),
+            null,
+            null,
+            null,
+            false));
+  }
+
+  @Test
+  public void testCreateLogicalViewRegionAvailability() throws Exception {
+    // Ratis checks target existence locally. SimpleConsensus must retain its 
direct write path.
+    checkSchemaWriteWithRegionAvailability(
+        new CreateLogicalViewNode(
+            new PlanNodeId("view"),
+            Collections.singletonMap(
+                new MeasurementPath("root.sg.d.v"), new 
TimeSeriesViewOperand("root.sg.d.s"))));
+  }
+
+  @Test
+  public void testCreateOrUpdateTableDeviceRegionAvailability() throws 
Exception {
+    // Table-device quota validation has the same missing-region window as 
tree auto-creation.
+    checkSchemaWriteWithRegionAvailability(
+        new CreateOrUpdateTableDeviceNode(
+            new PlanNodeId("table"),
+            "db",
+            "table1",
+            Collections.singletonList(new Object[] {"device1"}),
+            Collections.emptyList(),
+            Collections.singletonList(new Object[0])));
+  }
+
+  private void checkSchemaWriteWithRegionAvailability(final WritePlanNode 
node) throws Exception {

Review Comment:
   The shared test matrix keeps the similar-path checks consistent across 
missing and available regions, both consensus protocols, and ordinary/Pipe 
requests. It also verifies the validation lock is released and that consensus 
is skipped only for the unavailable-region case.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to