You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/06/16 02:39:03 UTC

[GitHub] [iotdb] JackieTien97 commented on a diff in pull request #6290: [IOTDB-3482] Add IT for UDF management in new Cluster

JackieTien97 commented on code in PR #6290:
URL: https://github.com/apache/iotdb/pull/6290#discussion_r898636210


##########
integration-test/src/test/java/org/apache/iotdb/db/it/udf/IoTDBUDFManagementIT.java:
##########
@@ -279,86 +253,58 @@ public void testDropFunction2() { // drop
 
   @Test
   public void testDropBuiltInFunction() throws SQLException { // drop
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+    try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
       try {
         statement.execute("drop function abs");
         fail();
       } catch (SQLException throwable) {
-        assertTrue(throwable.getMessage().contains("Built-in function"));
+        assertTrue(
+            throwable.getMessage().contains("Built-in function ABS can not be deregistered"));
       }
-      statement.execute("INSERT INTO root.vehicle.d1(time, s1) VALUES(1, -10.0)");
-      ResultSet rs = statement.executeQuery("SELECT ABS(s1) FROM root.vehicle.d1");
-      Assert.assertTrue(rs.next());
-      Assert.assertEquals(1, rs.getLong(1));
-      Assert.assertEquals(10.0F, rs.getFloat(2), 0.00001);
-      Assert.assertFalse(rs.next());

Review Comment:
   Why delete these assert



##########
integration-test/src/test/java/org/apache/iotdb/db/it/udf/IoTDBUDFManagementIT.java:
##########
@@ -16,77 +16,69 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+package org.apache.iotdb.db.it.udf;
 
-package org.apache.iotdb.db.integration;
-
-import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.commons.udf.builtin.BuiltinAggregationFunction;
-import org.apache.iotdb.commons.udf.builtin.BuiltinTimeSeriesGeneratingFunction;
-import org.apache.iotdb.commons.udf.service.UDFRegistrationService;
-import org.apache.iotdb.db.service.IoTDB;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.itbase.category.LocalStandaloneTest;
-import org.apache.iotdb.jdbc.Config;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
+import org.apache.iotdb.it.env.ConfigFactory;
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.env.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.itbase.category.LocalStandaloneIT;
 
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
 
 import java.sql.Connection;
-import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 
-import static org.apache.iotdb.commons.conf.IoTDBConstant.FUNCTION_TYPE_BUILTIN_UDTF;
-import static org.apache.iotdb.commons.conf.IoTDBConstant.FUNCTION_TYPE_EXTERNAL_UDTF;
-import static org.apache.iotdb.commons.conf.IoTDBConstant.FUNCTION_TYPE_NATIVE;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-@Category({LocalStandaloneTest.class})
+@RunWith(IoTDBTestRunner.class)
+@Category({LocalStandaloneIT.class, ClusterIT.class})
 public class IoTDBUDFManagementIT {
 
   private static final int NATIVE_FUNCTIONS_COUNT =
-      BuiltinAggregationFunction.getNativeFunctionNames().size();
+      BuiltinAggregationFunctionEnum.getNativeFunctionNames().size();
   private static final int BUILTIN_FUNCTIONS_COUNT =
-      BuiltinTimeSeriesGeneratingFunction.values().length;
+      BuiltinTimeSeriesGeneratingFunctionEnum.values().length;
+
+  private static final String FUNCTION_TYPE_NATIVE = "native";
+  private static final String FUNCTION_TYPE_BUILTIN_UDTF = "built-in UDTF";
+  private static final String FUNCTION_TYPE_EXTERNAL_UDTF = "external UDTF";
+
+  protected static boolean enableSeqSpaceCompaction;
+  protected static boolean enableUnseqSpaceCompaction;
+  protected static boolean enableCrossSpaceCompaction;
 
   @Before
   public void setUp() throws Exception {
-    EnvironmentUtils.envSetUp();
-    IoTDB.schemaProcessor.setStorageGroup(new PartialPath("root.vehicle"));
-    IoTDB.schemaProcessor.createTimeseries(
-        new PartialPath("root.vehicle.d1.s1"),
-        TSDataType.FLOAT,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaProcessor.createTimeseries(
-        new PartialPath("root.vehicle.d1.s2"),
-        TSDataType.FLOAT,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    Class.forName(Config.JDBC_DRIVER_NAME);
+    enableSeqSpaceCompaction = ConfigFactory.getConfig().isEnableSeqSpaceCompaction();
+    enableUnseqSpaceCompaction = ConfigFactory.getConfig().isEnableUnseqSpaceCompaction();
+    enableCrossSpaceCompaction = ConfigFactory.getConfig().isEnableCrossSpaceCompaction();
+    ConfigFactory.getConfig().setEnableSeqSpaceCompaction(false);
+    ConfigFactory.getConfig().setEnableUnseqSpaceCompaction(false);
+    ConfigFactory.getConfig().setEnableCrossSpaceCompaction(false);
+    EnvFactory.getEnv().initBeforeClass();
   }
 
   @After
-  public void tearDown() throws Exception {
-    EnvironmentUtils.cleanEnv();
+  public void tearDown() {
+    EnvFactory.getEnv().cleanAfterClass();

Review Comment:
   ```suggestion
       EnvFactory.getEnv().cleanAfterTest();
   ```



##########
integration-test/src/test/java/org/apache/iotdb/db/it/udf/IoTDBUDFManagementIT.java:
##########
@@ -16,77 +16,69 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+package org.apache.iotdb.db.it.udf;
 
-package org.apache.iotdb.db.integration;
-
-import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.commons.udf.builtin.BuiltinAggregationFunction;
-import org.apache.iotdb.commons.udf.builtin.BuiltinTimeSeriesGeneratingFunction;
-import org.apache.iotdb.commons.udf.service.UDFRegistrationService;
-import org.apache.iotdb.db.service.IoTDB;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.itbase.category.LocalStandaloneTest;
-import org.apache.iotdb.jdbc.Config;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
+import org.apache.iotdb.it.env.ConfigFactory;
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.env.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.itbase.category.LocalStandaloneIT;
 
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
 
 import java.sql.Connection;
-import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 
-import static org.apache.iotdb.commons.conf.IoTDBConstant.FUNCTION_TYPE_BUILTIN_UDTF;
-import static org.apache.iotdb.commons.conf.IoTDBConstant.FUNCTION_TYPE_EXTERNAL_UDTF;
-import static org.apache.iotdb.commons.conf.IoTDBConstant.FUNCTION_TYPE_NATIVE;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-@Category({LocalStandaloneTest.class})
+@RunWith(IoTDBTestRunner.class)
+@Category({LocalStandaloneIT.class, ClusterIT.class})
 public class IoTDBUDFManagementIT {
 
   private static final int NATIVE_FUNCTIONS_COUNT =
-      BuiltinAggregationFunction.getNativeFunctionNames().size();
+      BuiltinAggregationFunctionEnum.getNativeFunctionNames().size();
   private static final int BUILTIN_FUNCTIONS_COUNT =
-      BuiltinTimeSeriesGeneratingFunction.values().length;
+      BuiltinTimeSeriesGeneratingFunctionEnum.values().length;
+
+  private static final String FUNCTION_TYPE_NATIVE = "native";
+  private static final String FUNCTION_TYPE_BUILTIN_UDTF = "built-in UDTF";
+  private static final String FUNCTION_TYPE_EXTERNAL_UDTF = "external UDTF";
+
+  protected static boolean enableSeqSpaceCompaction;
+  protected static boolean enableUnseqSpaceCompaction;
+  protected static boolean enableCrossSpaceCompaction;
 
   @Before
   public void setUp() throws Exception {
-    EnvironmentUtils.envSetUp();
-    IoTDB.schemaProcessor.setStorageGroup(new PartialPath("root.vehicle"));
-    IoTDB.schemaProcessor.createTimeseries(
-        new PartialPath("root.vehicle.d1.s1"),
-        TSDataType.FLOAT,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaProcessor.createTimeseries(
-        new PartialPath("root.vehicle.d1.s2"),
-        TSDataType.FLOAT,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    Class.forName(Config.JDBC_DRIVER_NAME);
+    enableSeqSpaceCompaction = ConfigFactory.getConfig().isEnableSeqSpaceCompaction();
+    enableUnseqSpaceCompaction = ConfigFactory.getConfig().isEnableUnseqSpaceCompaction();
+    enableCrossSpaceCompaction = ConfigFactory.getConfig().isEnableCrossSpaceCompaction();
+    ConfigFactory.getConfig().setEnableSeqSpaceCompaction(false);
+    ConfigFactory.getConfig().setEnableUnseqSpaceCompaction(false);
+    ConfigFactory.getConfig().setEnableCrossSpaceCompaction(false);
+    EnvFactory.getEnv().initBeforeClass();

Review Comment:
   ```suggestion
       EnvFactory.getEnv().initBeforeTest();
   ```
   If you mean that you need to do this setUp() method every time test case is running, you should call `initBeforeTest`.



##########
integration-test/src/test/java/org/apache/iotdb/db/it/udf/IoTDBUDFManagementIT.java:
##########
@@ -16,77 +16,69 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+package org.apache.iotdb.db.it.udf;
 
-package org.apache.iotdb.db.integration;
-
-import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.commons.udf.builtin.BuiltinAggregationFunction;
-import org.apache.iotdb.commons.udf.builtin.BuiltinTimeSeriesGeneratingFunction;
-import org.apache.iotdb.commons.udf.service.UDFRegistrationService;
-import org.apache.iotdb.db.service.IoTDB;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.itbase.category.LocalStandaloneTest;
-import org.apache.iotdb.jdbc.Config;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
+import org.apache.iotdb.it.env.ConfigFactory;
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.env.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.itbase.category.LocalStandaloneIT;
 
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
 
 import java.sql.Connection;
-import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 
-import static org.apache.iotdb.commons.conf.IoTDBConstant.FUNCTION_TYPE_BUILTIN_UDTF;
-import static org.apache.iotdb.commons.conf.IoTDBConstant.FUNCTION_TYPE_EXTERNAL_UDTF;
-import static org.apache.iotdb.commons.conf.IoTDBConstant.FUNCTION_TYPE_NATIVE;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-@Category({LocalStandaloneTest.class})
+@RunWith(IoTDBTestRunner.class)
+@Category({LocalStandaloneIT.class, ClusterIT.class})
 public class IoTDBUDFManagementIT {
 
   private static final int NATIVE_FUNCTIONS_COUNT =
-      BuiltinAggregationFunction.getNativeFunctionNames().size();
+      BuiltinAggregationFunctionEnum.getNativeFunctionNames().size();
   private static final int BUILTIN_FUNCTIONS_COUNT =
-      BuiltinTimeSeriesGeneratingFunction.values().length;
+      BuiltinTimeSeriesGeneratingFunctionEnum.values().length;
+
+  private static final String FUNCTION_TYPE_NATIVE = "native";
+  private static final String FUNCTION_TYPE_BUILTIN_UDTF = "built-in UDTF";
+  private static final String FUNCTION_TYPE_EXTERNAL_UDTF = "external UDTF";
+
+  protected static boolean enableSeqSpaceCompaction;
+  protected static boolean enableUnseqSpaceCompaction;
+  protected static boolean enableCrossSpaceCompaction;
 
   @Before
   public void setUp() throws Exception {
-    EnvironmentUtils.envSetUp();
-    IoTDB.schemaProcessor.setStorageGroup(new PartialPath("root.vehicle"));
-    IoTDB.schemaProcessor.createTimeseries(
-        new PartialPath("root.vehicle.d1.s1"),
-        TSDataType.FLOAT,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaProcessor.createTimeseries(
-        new PartialPath("root.vehicle.d1.s2"),
-        TSDataType.FLOAT,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    Class.forName(Config.JDBC_DRIVER_NAME);
+    enableSeqSpaceCompaction = ConfigFactory.getConfig().isEnableSeqSpaceCompaction();
+    enableUnseqSpaceCompaction = ConfigFactory.getConfig().isEnableUnseqSpaceCompaction();
+    enableCrossSpaceCompaction = ConfigFactory.getConfig().isEnableCrossSpaceCompaction();
+    ConfigFactory.getConfig().setEnableSeqSpaceCompaction(false);
+    ConfigFactory.getConfig().setEnableUnseqSpaceCompaction(false);
+    ConfigFactory.getConfig().setEnableCrossSpaceCompaction(false);
+    EnvFactory.getEnv().initBeforeClass();
   }
 
   @After
-  public void tearDown() throws Exception {
-    EnvironmentUtils.cleanEnv();
+  public void tearDown() {
+    EnvFactory.getEnv().cleanAfterClass();
+    ConfigFactory.getConfig().setEnableSeqSpaceCompaction(enableSeqSpaceCompaction);
+    ConfigFactory.getConfig().setEnableUnseqSpaceCompaction(enableUnseqSpaceCompaction);
+    ConfigFactory.getConfig().setEnableCrossSpaceCompaction(enableCrossSpaceCompaction);
   }
 
   @Test
   public void testCreateReflectShowDrop() {
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+    try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
       statement.execute("create function udf as 'org.apache.iotdb.db.query.udf.example.Adder'");
       statement.execute("select udf(*, *) from root.vehicle");

Review Comment:
   Why executing query sql here, not verifying the correctness?



-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org