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


##########
integration-test/src/test/java/org/apache/iotdb/pipe/it/tablemodel/IoTDBPipeTypeConversionISessionIT.java:
##########
@@ -0,0 +1,504 @@
+/*
+ * 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.pipe.it.tablemodel;
+
+import org.apache.iotdb.commons.utils.function.CheckedTriConsumer;
+import org.apache.iotdb.db.it.utils.TestUtils;
+import org.apache.iotdb.db.pipe.receiver.transform.converter.ValueConverter;
+import org.apache.iotdb.isession.ITableSession;
+import org.apache.iotdb.isession.SessionDataSet;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.MultiClusterIT2TableModel;
+import org.apache.iotdb.itbase.env.BaseEnv;
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.StatementExecutionException;
+
+import org.apache.tsfile.common.conf.TSFileConfig;
+import org.apache.tsfile.enums.TSDataType;
+import org.apache.tsfile.read.common.Field;
+import org.apache.tsfile.read.common.RowRecord;
+import org.apache.tsfile.utils.Binary;
+import org.apache.tsfile.utils.DateUtils;
+import org.apache.tsfile.utils.Pair;
+import org.apache.tsfile.write.record.Tablet;
+import org.apache.tsfile.write.schema.IMeasurementSchema;
+import org.apache.tsfile.write.schema.MeasurementSchema;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({MultiClusterIT2TableModel.class})
+public class IoTDBPipeTypeConversionISessionIT extends 
AbstractPipeTableModelTestIT {
+  private static final int generateDataSize = 100;
+
+  @Test
+  public void insertTablet() {
+    prepareTypeConversionTest(
+        (ITableSession senderSession, ITableSession receiverSession, Tablet 
tablet) -> {
+          senderSession.insert(tablet);
+        },
+        false);
+  }
+
+  @Test
+  public void insertTabletReceiveByTsFile() {
+    prepareTypeConversionTest(
+        (ITableSession senderSession, ITableSession receiverSession, Tablet 
tablet) -> {
+          senderSession.insert(tablet);
+        },
+        true);
+  }
+
+  private SessionDataSet query(
+      ITableSession session, List<IMeasurementSchema> measurementSchemas, 
String deviceId)
+      throws IoTDBConnectionException, StatementExecutionException {
+    String sql = "select ";
+    StringBuffer param = new StringBuffer();
+    for (IMeasurementSchema schema : measurementSchemas) {
+      param.append(schema.getMeasurementName());
+      param.append(',');
+    }
+    sql = sql + param.substring(0, param.length() - 1);
+    sql = sql + " from " + deviceId + " ORDER BY time ASC";
+    session.executeNonQueryStatement("use test");
+    return session.executeQueryStatement(sql);
+  }
+
+  private void prepareTypeConversionTest(
+      CheckedTriConsumer<ITableSession, ITableSession, Tablet, Exception> 
consumer,
+      boolean isTsFile) {
+    List<Pair<MeasurementSchema, MeasurementSchema>> measurementSchemas =
+        generateMeasurementSchemas();
+    Tablet tablet = generateTabletAndMeasurementSchema(measurementSchemas, 
"test");
+    createTimeSeries(measurementSchemas, true, tablet.getColumnTypes(), 
senderEnv);
+    createTimeSeries(measurementSchemas, false, tablet.getColumnTypes(), 
receiverEnv);
+    try (ITableSession senderSession = senderEnv.getTableSessionConnection();
+        ITableSession receiverSession = 
receiverEnv.getTableSessionConnection()) {
+
+      if (isTsFile) {
+        // Send TsFile data to receiver
+        consumer.accept(senderSession, receiverSession, tablet);
+        Thread.sleep(2000);
+        senderSession.executeNonQueryStatement("flush");
+        createDataPipe(true);
+      } else {
+        // Send Tablet data to receiver
+        createDataPipe(false);
+        Thread.sleep(2000);
+        // The actual implementation logic of inserting data
+        consumer.accept(senderSession, receiverSession, tablet);
+        senderSession.executeNonQueryStatement("flush");
+      }
+
+      // Verify receiver data
+      long timeoutSeconds = 30;
+      List<List<Object>> expectedValues =
+          generateTabletResultSetForTable(tablet, measurementSchemas);
+      await()
+          .pollInSameThread()
+          .pollDelay(1L, TimeUnit.SECONDS)
+          .pollInterval(1L, TimeUnit.SECONDS)
+          .atMost(timeoutSeconds, TimeUnit.SECONDS)
+          .untilAsserted(
+              () -> {
+                try {
+                  validateResultSet(
+                      query(receiverSession, tablet.getSchemas(), 
tablet.getDeviceId()),
+                      expectedValues,
+                      tablet.timestamps);
+                } catch (Exception e) {
+                  e.printStackTrace();
+                  fail();

Review Comment:
   May add e.getMessage() to fail(). If the message is clear enough and the 
test fails, you will not need to scroll up to look for the message.



##########
integration-test/src/test/java/org/apache/iotdb/pipe/it/tablemodel/IoTDBPipeTypeConversionISessionIT.java:
##########
@@ -0,0 +1,504 @@
+/*
+ * 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.pipe.it.tablemodel;
+
+import org.apache.iotdb.commons.utils.function.CheckedTriConsumer;
+import org.apache.iotdb.db.it.utils.TestUtils;
+import org.apache.iotdb.db.pipe.receiver.transform.converter.ValueConverter;
+import org.apache.iotdb.isession.ITableSession;
+import org.apache.iotdb.isession.SessionDataSet;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.MultiClusterIT2TableModel;
+import org.apache.iotdb.itbase.env.BaseEnv;
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.StatementExecutionException;
+
+import org.apache.tsfile.common.conf.TSFileConfig;
+import org.apache.tsfile.enums.TSDataType;
+import org.apache.tsfile.read.common.Field;
+import org.apache.tsfile.read.common.RowRecord;
+import org.apache.tsfile.utils.Binary;
+import org.apache.tsfile.utils.DateUtils;
+import org.apache.tsfile.utils.Pair;
+import org.apache.tsfile.write.record.Tablet;
+import org.apache.tsfile.write.schema.IMeasurementSchema;
+import org.apache.tsfile.write.schema.MeasurementSchema;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({MultiClusterIT2TableModel.class})
+public class IoTDBPipeTypeConversionISessionIT extends 
AbstractPipeTableModelTestIT {
+  private static final int generateDataSize = 100;
+
+  @Test
+  public void insertTablet() {
+    prepareTypeConversionTest(
+        (ITableSession senderSession, ITableSession receiverSession, Tablet 
tablet) -> {
+          senderSession.insert(tablet);
+        },
+        false);
+  }
+
+  @Test
+  public void insertTabletReceiveByTsFile() {
+    prepareTypeConversionTest(
+        (ITableSession senderSession, ITableSession receiverSession, Tablet 
tablet) -> {
+          senderSession.insert(tablet);
+        },
+        true);
+  }
+
+  private SessionDataSet query(
+      ITableSession session, List<IMeasurementSchema> measurementSchemas, 
String deviceId)
+      throws IoTDBConnectionException, StatementExecutionException {
+    String sql = "select ";
+    StringBuffer param = new StringBuffer();
+    for (IMeasurementSchema schema : measurementSchemas) {
+      param.append(schema.getMeasurementName());
+      param.append(',');
+    }
+    sql = sql + param.substring(0, param.length() - 1);
+    sql = sql + " from " + deviceId + " ORDER BY time ASC";
+    session.executeNonQueryStatement("use test");
+    return session.executeQueryStatement(sql);
+  }
+
+  private void prepareTypeConversionTest(
+      CheckedTriConsumer<ITableSession, ITableSession, Tablet, Exception> 
consumer,
+      boolean isTsFile) {
+    List<Pair<MeasurementSchema, MeasurementSchema>> measurementSchemas =
+        generateMeasurementSchemas();
+    Tablet tablet = generateTabletAndMeasurementSchema(measurementSchemas, 
"test");
+    createTimeSeries(measurementSchemas, true, tablet.getColumnTypes(), 
senderEnv);
+    createTimeSeries(measurementSchemas, false, tablet.getColumnTypes(), 
receiverEnv);
+    try (ITableSession senderSession = senderEnv.getTableSessionConnection();
+        ITableSession receiverSession = 
receiverEnv.getTableSessionConnection()) {
+
+      if (isTsFile) {
+        // Send TsFile data to receiver
+        consumer.accept(senderSession, receiverSession, tablet);
+        Thread.sleep(2000);
+        senderSession.executeNonQueryStatement("flush");
+        createDataPipe(true);
+      } else {
+        // Send Tablet data to receiver
+        createDataPipe(false);
+        Thread.sleep(2000);
+        // The actual implementation logic of inserting data
+        consumer.accept(senderSession, receiverSession, tablet);
+        senderSession.executeNonQueryStatement("flush");
+      }
+
+      // Verify receiver data
+      long timeoutSeconds = 30;
+      List<List<Object>> expectedValues =
+          generateTabletResultSetForTable(tablet, measurementSchemas);
+      await()
+          .pollInSameThread()
+          .pollDelay(1L, TimeUnit.SECONDS)
+          .pollInterval(1L, TimeUnit.SECONDS)
+          .atMost(timeoutSeconds, TimeUnit.SECONDS)
+          .untilAsserted(
+              () -> {
+                try {
+                  validateResultSet(
+                      query(receiverSession, tablet.getSchemas(), 
tablet.getDeviceId()),
+                      expectedValues,
+                      tablet.timestamps);
+                } catch (Exception e) {
+                  e.printStackTrace();
+                  fail();
+                }
+              });
+      senderSession.close();
+      receiverSession.close();

Review Comment:
   Already in try-with-resource, unnecessary.



##########
integration-test/src/test/java/org/apache/iotdb/pipe/it/tablemodel/IoTDBPipeTypeConversionISessionIT.java:
##########
@@ -0,0 +1,504 @@
+/*
+ * 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.pipe.it.tablemodel;
+
+import org.apache.iotdb.commons.utils.function.CheckedTriConsumer;
+import org.apache.iotdb.db.it.utils.TestUtils;
+import org.apache.iotdb.db.pipe.receiver.transform.converter.ValueConverter;
+import org.apache.iotdb.isession.ITableSession;
+import org.apache.iotdb.isession.SessionDataSet;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.MultiClusterIT2TableModel;
+import org.apache.iotdb.itbase.env.BaseEnv;
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.StatementExecutionException;
+
+import org.apache.tsfile.common.conf.TSFileConfig;
+import org.apache.tsfile.enums.TSDataType;
+import org.apache.tsfile.read.common.Field;
+import org.apache.tsfile.read.common.RowRecord;
+import org.apache.tsfile.utils.Binary;
+import org.apache.tsfile.utils.DateUtils;
+import org.apache.tsfile.utils.Pair;
+import org.apache.tsfile.write.record.Tablet;
+import org.apache.tsfile.write.schema.IMeasurementSchema;
+import org.apache.tsfile.write.schema.MeasurementSchema;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({MultiClusterIT2TableModel.class})
+public class IoTDBPipeTypeConversionISessionIT extends 
AbstractPipeTableModelTestIT {
+  private static final int generateDataSize = 100;
+
+  @Test
+  public void insertTablet() {
+    prepareTypeConversionTest(
+        (ITableSession senderSession, ITableSession receiverSession, Tablet 
tablet) -> {
+          senderSession.insert(tablet);
+        },
+        false);
+  }
+
+  @Test
+  public void insertTabletReceiveByTsFile() {
+    prepareTypeConversionTest(
+        (ITableSession senderSession, ITableSession receiverSession, Tablet 
tablet) -> {
+          senderSession.insert(tablet);
+        },
+        true);
+  }
+
+  private SessionDataSet query(
+      ITableSession session, List<IMeasurementSchema> measurementSchemas, 
String deviceId)
+      throws IoTDBConnectionException, StatementExecutionException {
+    String sql = "select ";
+    StringBuffer param = new StringBuffer();
+    for (IMeasurementSchema schema : measurementSchemas) {
+      param.append(schema.getMeasurementName());
+      param.append(',');
+    }
+    sql = sql + param.substring(0, param.length() - 1);
+    sql = sql + " from " + deviceId + " ORDER BY time ASC";
+    session.executeNonQueryStatement("use test");
+    return session.executeQueryStatement(sql);
+  }
+
+  private void prepareTypeConversionTest(
+      CheckedTriConsumer<ITableSession, ITableSession, Tablet, Exception> 
consumer,
+      boolean isTsFile) {
+    List<Pair<MeasurementSchema, MeasurementSchema>> measurementSchemas =
+        generateMeasurementSchemas();
+    Tablet tablet = generateTabletAndMeasurementSchema(measurementSchemas, 
"test");
+    createTimeSeries(measurementSchemas, true, tablet.getColumnTypes(), 
senderEnv);
+    createTimeSeries(measurementSchemas, false, tablet.getColumnTypes(), 
receiverEnv);
+    try (ITableSession senderSession = senderEnv.getTableSessionConnection();
+        ITableSession receiverSession = 
receiverEnv.getTableSessionConnection()) {
+
+      if (isTsFile) {
+        // Send TsFile data to receiver
+        consumer.accept(senderSession, receiverSession, tablet);
+        Thread.sleep(2000);
+        senderSession.executeNonQueryStatement("flush");
+        createDataPipe(true);
+      } else {
+        // Send Tablet data to receiver
+        createDataPipe(false);
+        Thread.sleep(2000);
+        // The actual implementation logic of inserting data
+        consumer.accept(senderSession, receiverSession, tablet);
+        senderSession.executeNonQueryStatement("flush");
+      }

Review Comment:
   What is the sleep for? I think 2 seconds is too long for a single insertion 
or pipe creation. If all tests are like this, then maybe the ci resource is 
significantly wasted.
   Is it possible to make the consumer a blocked one?



##########
integration-test/src/test/java/org/apache/iotdb/pipe/it/tablemodel/IoTDBPipeTypeConversionISessionIT.java:
##########
@@ -0,0 +1,504 @@
+/*
+ * 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.pipe.it.tablemodel;
+
+import org.apache.iotdb.commons.utils.function.CheckedTriConsumer;
+import org.apache.iotdb.db.it.utils.TestUtils;
+import org.apache.iotdb.db.pipe.receiver.transform.converter.ValueConverter;
+import org.apache.iotdb.isession.ITableSession;
+import org.apache.iotdb.isession.SessionDataSet;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.MultiClusterIT2TableModel;
+import org.apache.iotdb.itbase.env.BaseEnv;
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.StatementExecutionException;
+
+import org.apache.tsfile.common.conf.TSFileConfig;
+import org.apache.tsfile.enums.TSDataType;
+import org.apache.tsfile.read.common.Field;
+import org.apache.tsfile.read.common.RowRecord;
+import org.apache.tsfile.utils.Binary;
+import org.apache.tsfile.utils.DateUtils;
+import org.apache.tsfile.utils.Pair;
+import org.apache.tsfile.write.record.Tablet;
+import org.apache.tsfile.write.schema.IMeasurementSchema;
+import org.apache.tsfile.write.schema.MeasurementSchema;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({MultiClusterIT2TableModel.class})
+public class IoTDBPipeTypeConversionISessionIT extends 
AbstractPipeTableModelTestIT {
+  private static final int generateDataSize = 100;
+
+  @Test
+  public void insertTablet() {
+    prepareTypeConversionTest(
+        (ITableSession senderSession, ITableSession receiverSession, Tablet 
tablet) -> {
+          senderSession.insert(tablet);
+        },
+        false);
+  }
+
+  @Test
+  public void insertTabletReceiveByTsFile() {
+    prepareTypeConversionTest(
+        (ITableSession senderSession, ITableSession receiverSession, Tablet 
tablet) -> {
+          senderSession.insert(tablet);
+        },
+        true);
+  }
+
+  private SessionDataSet query(
+      ITableSession session, List<IMeasurementSchema> measurementSchemas, 
String deviceId)
+      throws IoTDBConnectionException, StatementExecutionException {
+    String sql = "select ";
+    StringBuffer param = new StringBuffer();
+    for (IMeasurementSchema schema : measurementSchemas) {
+      param.append(schema.getMeasurementName());
+      param.append(',');
+    }
+    sql = sql + param.substring(0, param.length() - 1);
+    sql = sql + " from " + deviceId + " ORDER BY time ASC";
+    session.executeNonQueryStatement("use test");
+    return session.executeQueryStatement(sql);
+  }
+
+  private void prepareTypeConversionTest(
+      CheckedTriConsumer<ITableSession, ITableSession, Tablet, Exception> 
consumer,
+      boolean isTsFile) {
+    List<Pair<MeasurementSchema, MeasurementSchema>> measurementSchemas =
+        generateMeasurementSchemas();
+    Tablet tablet = generateTabletAndMeasurementSchema(measurementSchemas, 
"test");
+    createTimeSeries(measurementSchemas, true, tablet.getColumnTypes(), 
senderEnv);
+    createTimeSeries(measurementSchemas, false, tablet.getColumnTypes(), 
receiverEnv);
+    try (ITableSession senderSession = senderEnv.getTableSessionConnection();
+        ITableSession receiverSession = 
receiverEnv.getTableSessionConnection()) {
+
+      if (isTsFile) {
+        // Send TsFile data to receiver
+        consumer.accept(senderSession, receiverSession, tablet);
+        Thread.sleep(2000);
+        senderSession.executeNonQueryStatement("flush");
+        createDataPipe(true);
+      } else {
+        // Send Tablet data to receiver
+        createDataPipe(false);
+        Thread.sleep(2000);
+        // The actual implementation logic of inserting data
+        consumer.accept(senderSession, receiverSession, tablet);
+        senderSession.executeNonQueryStatement("flush");
+      }
+
+      // Verify receiver data
+      long timeoutSeconds = 30;
+      List<List<Object>> expectedValues =
+          generateTabletResultSetForTable(tablet, measurementSchemas);
+      await()
+          .pollInSameThread()
+          .pollDelay(1L, TimeUnit.SECONDS)
+          .pollInterval(1L, TimeUnit.SECONDS)
+          .atMost(timeoutSeconds, TimeUnit.SECONDS)
+          .untilAsserted(
+              () -> {
+                try {
+                  validateResultSet(
+                      query(receiverSession, tablet.getSchemas(), 
tablet.getDeviceId()),
+                      expectedValues,
+                      tablet.timestamps);
+                } catch (Exception e) {
+                  e.printStackTrace();
+                  fail();
+                }
+              });
+      senderSession.close();
+      receiverSession.close();
+      tablet.reset();
+    } catch (Exception e) {
+      e.printStackTrace();
+      fail(e.getMessage());
+    }
+  }
+
+  private void createTimeSeries(

Review Comment:
   createTimeSeries -> createDdAndTable



##########
integration-test/src/test/java/org/apache/iotdb/pipe/it/tablemodel/IoTDBPipeTypeConversionISessionIT.java:
##########
@@ -0,0 +1,504 @@
+/*
+ * 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.pipe.it.tablemodel;
+
+import org.apache.iotdb.commons.utils.function.CheckedTriConsumer;
+import org.apache.iotdb.db.it.utils.TestUtils;
+import org.apache.iotdb.db.pipe.receiver.transform.converter.ValueConverter;
+import org.apache.iotdb.isession.ITableSession;
+import org.apache.iotdb.isession.SessionDataSet;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.MultiClusterIT2TableModel;
+import org.apache.iotdb.itbase.env.BaseEnv;
+import org.apache.iotdb.rpc.IoTDBConnectionException;
+import org.apache.iotdb.rpc.StatementExecutionException;
+
+import org.apache.tsfile.common.conf.TSFileConfig;
+import org.apache.tsfile.enums.TSDataType;
+import org.apache.tsfile.read.common.Field;
+import org.apache.tsfile.read.common.RowRecord;
+import org.apache.tsfile.utils.Binary;
+import org.apache.tsfile.utils.DateUtils;
+import org.apache.tsfile.utils.Pair;
+import org.apache.tsfile.write.record.Tablet;
+import org.apache.tsfile.write.schema.IMeasurementSchema;
+import org.apache.tsfile.write.schema.MeasurementSchema;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.TimeUnit;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({MultiClusterIT2TableModel.class})
+public class IoTDBPipeTypeConversionISessionIT extends 
AbstractPipeTableModelTestIT {
+  private static final int generateDataSize = 100;
+
+  @Test
+  public void insertTablet() {
+    prepareTypeConversionTest(
+        (ITableSession senderSession, ITableSession receiverSession, Tablet 
tablet) -> {
+          senderSession.insert(tablet);
+        },
+        false);
+  }
+
+  @Test
+  public void insertTabletReceiveByTsFile() {
+    prepareTypeConversionTest(
+        (ITableSession senderSession, ITableSession receiverSession, Tablet 
tablet) -> {
+          senderSession.insert(tablet);
+        },
+        true);
+  }
+
+  private SessionDataSet query(
+      ITableSession session, List<IMeasurementSchema> measurementSchemas, 
String deviceId)
+      throws IoTDBConnectionException, StatementExecutionException {
+    String sql = "select ";
+    StringBuffer param = new StringBuffer();
+    for (IMeasurementSchema schema : measurementSchemas) {
+      param.append(schema.getMeasurementName());
+      param.append(',');
+    }
+    sql = sql + param.substring(0, param.length() - 1);
+    sql = sql + " from " + deviceId + " ORDER BY time ASC";
+    session.executeNonQueryStatement("use test");
+    return session.executeQueryStatement(sql);
+  }
+
+  private void prepareTypeConversionTest(
+      CheckedTriConsumer<ITableSession, ITableSession, Tablet, Exception> 
consumer,
+      boolean isTsFile) {
+    List<Pair<MeasurementSchema, MeasurementSchema>> measurementSchemas =
+        generateMeasurementSchemas();
+    Tablet tablet = generateTabletAndMeasurementSchema(measurementSchemas, 
"test");
+    createTimeSeries(measurementSchemas, true, tablet.getColumnTypes(), 
senderEnv);
+    createTimeSeries(measurementSchemas, false, tablet.getColumnTypes(), 
receiverEnv);
+    try (ITableSession senderSession = senderEnv.getTableSessionConnection();
+        ITableSession receiverSession = 
receiverEnv.getTableSessionConnection()) {
+
+      if (isTsFile) {
+        // Send TsFile data to receiver
+        consumer.accept(senderSession, receiverSession, tablet);
+        Thread.sleep(2000);
+        senderSession.executeNonQueryStatement("flush");
+        createDataPipe(true);
+      } else {
+        // Send Tablet data to receiver
+        createDataPipe(false);
+        Thread.sleep(2000);
+        // The actual implementation logic of inserting data
+        consumer.accept(senderSession, receiverSession, tablet);
+        senderSession.executeNonQueryStatement("flush");
+      }
+
+      // Verify receiver data
+      long timeoutSeconds = 30;
+      List<List<Object>> expectedValues =
+          generateTabletResultSetForTable(tablet, measurementSchemas);
+      await()
+          .pollInSameThread()
+          .pollDelay(1L, TimeUnit.SECONDS)
+          .pollInterval(1L, TimeUnit.SECONDS)
+          .atMost(timeoutSeconds, TimeUnit.SECONDS)
+          .untilAsserted(
+              () -> {
+                try {
+                  validateResultSet(
+                      query(receiverSession, tablet.getSchemas(), 
tablet.getDeviceId()),
+                      expectedValues,
+                      tablet.timestamps);
+                } catch (Exception e) {
+                  e.printStackTrace();
+                  fail();

Review Comment:
   May add e.getMessage() to fail(). If the message is clear enough and the 
test fails, you will not need to scroll up to look for the message.



-- 
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