You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2024/06/04 13:24:48 UTC
(iotdb) branch ty/TableModelDevelop updated (456b960d470 -> d52875a6f0a)
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a change to branch ty/TableModelDevelop
in repository https://gitbox.apache.org/repos/asf/iotdb.git
from 456b960d470 add sqlDialect parameter for IT framework
new 822b1f60f0f Add IT for database management
new d52875a6f0a Add IT for database management
The 2 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.
Summary of changes:
.../java/org/apache/iotdb/itbase/env/BaseEnv.java | 19 +++
.../relational/it/schema/IoTDBDatabaseIT.java | 159 +++++++++++++++++++++
.../it/schema/IoTDBTableIT.java} | 7 +-
3 files changed, 180 insertions(+), 5 deletions(-)
create mode 100644 integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java
copy integration-test/src/test/java/org/apache/iotdb/{db/it/orderBy/IoTDBOrderBy2IT.java => relational/it/schema/IoTDBTableIT.java} (83%)
(iotdb) 01/02: Add IT for database management
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch ty/TableModelDevelop
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 822b1f60f0f78eaa81be57d42221d2094762aa74
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Tue Jun 4 21:09:13 2024 +0800
Add IT for database management
---
.../java/org/apache/iotdb/itbase/env/BaseEnv.java | 19 ++++
.../relational/it/schema/IoTDBDatabaseIT.java | 121 +++++++++++++++++++++
.../iotdb/relational/it/schema/IoTDBTableIT.java | 45 ++++++++
3 files changed, 185 insertions(+)
diff --git a/integration-test/src/main/java/org/apache/iotdb/itbase/env/BaseEnv.java b/integration-test/src/main/java/org/apache/iotdb/itbase/env/BaseEnv.java
index 0544438fca4..472df6c6f63 100644
--- a/integration-test/src/main/java/org/apache/iotdb/itbase/env/BaseEnv.java
+++ b/integration-test/src/main/java/org/apache/iotdb/itbase/env/BaseEnv.java
@@ -108,15 +108,34 @@ public interface BaseEnv {
SessionConfig.DEFAULT_USER, SessionConfig.DEFAULT_PASSWORD, TREE_SQL_DIALECT);
}
+ default Connection getConnection(String sqlDialect) throws SQLException {
+ return getConnection(SessionConfig.DEFAULT_USER, SessionConfig.DEFAULT_PASSWORD, sqlDialect);
+ }
+
default Connection getConnection(Constant.Version version) throws SQLException {
return getConnection(
version, SessionConfig.DEFAULT_USER, SessionConfig.DEFAULT_PASSWORD, TREE_SQL_DIALECT);
}
+ default Connection getConnection(Constant.Version version, String sqlDialect)
+ throws SQLException {
+ return getConnection(
+ version, SessionConfig.DEFAULT_USER, SessionConfig.DEFAULT_PASSWORD, sqlDialect);
+ }
+
+ default Connection getConnection(Constant.Version version, String username, String password)
+ throws SQLException {
+ return getConnection(version, username, password, TREE_SQL_DIALECT);
+ }
+
Connection getConnection(
Constant.Version version, String username, String password, String sqlDialect)
throws SQLException;
+ default Connection getConnection(String username, String password) throws SQLException {
+ return getConnection(username, password, TREE_SQL_DIALECT);
+ }
+
Connection getConnection(String username, String password, String sqlDialect) throws SQLException;
default Connection getWriteOnlyConnectionWithSpecifiedDataNode(DataNodeWrapper dataNode)
diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java
new file mode 100644
index 00000000000..b76676f9c78
--- /dev/null
+++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java
@@ -0,0 +1,121 @@
+/*
+ * 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.relational.it.schema;
+
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.itbase.category.LocalStandaloneIT;
+import org.apache.iotdb.itbase.env.BaseEnv;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import static org.apache.iotdb.db.queryengine.common.header.ColumnHeaderConstant.showDBColumnHeaders;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({LocalStandaloneIT.class, ClusterIT.class})
+public class IoTDBDatabaseIT {
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ EnvFactory.getEnv().initClusterEnvironment();
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ EnvFactory.getEnv().cleanClusterEnvironment();
+ }
+
+ @Test
+ public void testManageDatabase() {
+ try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ Statement statement = connection.createStatement()) {
+
+ // create
+ statement.execute("create database test");
+
+ String[] databaseNames = new String[] {"test"};
+ int[] schemaReplicaFactors = new int[] {1};
+ int[] dataReplicaFactors = new int[] {1};
+ int[] timePartitionInterval = new int[] {604800000};
+
+ // show
+ try (ResultSet resultSet = statement.executeQuery("SHOW DATABASES")) {
+ int cnt = 0;
+ ResultSetMetaData metaData = resultSet.getMetaData();
+ assertEquals(showDBColumnHeaders.size(), metaData.getColumnCount());
+ for (int i = 0; i < showDBColumnHeaders.size(); i++) {
+ assertEquals(showDBColumnHeaders.get(i).getColumnName(), metaData.getColumnName(i + 1));
+ }
+ while (resultSet.next()) {
+ assertEquals(databaseNames[cnt], resultSet.getString(1));
+ assertEquals(schemaReplicaFactors[cnt], resultSet.getInt(2));
+ assertEquals(dataReplicaFactors[cnt], resultSet.getInt(3));
+ assertEquals(timePartitionInterval[cnt], resultSet.getLong(4));
+ cnt++;
+ }
+ assertEquals(databaseNames.length, cnt);
+ }
+
+ // use
+ statement.execute("use test");
+
+ // use nonexistent database
+ try {
+ statement.execute("use test1");
+ fail("use test1 shouldn't succeed because test1 doesn't exist");
+ } catch (SQLException e) {
+ assertEquals("500: Database test1 doesn't exists.", e.getMessage());
+ }
+
+ // drop
+ statement.execute("drop database test");
+ try (ResultSet resultSet = statement.executeQuery("SHOW DATABASES")) {
+ assertFalse(resultSet.next());
+ }
+
+ // drop nonexistent database
+ try {
+ statement.execute("drop database test");
+ fail("drop database test shouldn't succeed because test1 doesn't exist");
+ } catch (SQLException e) {
+ // TODO error msg should be changed to 500: Database test1 doesn't exists
+ assertEquals("508: Path [root.test] does not exist", e.getMessage());
+ }
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+}
diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java
new file mode 100644
index 00000000000..a01741d2cda
--- /dev/null
+++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java
@@ -0,0 +1,45 @@
+/*
+ * 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.relational.it.schema;
+
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.ClusterIT;
+import org.apache.iotdb.itbase.category.LocalStandaloneIT;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({LocalStandaloneIT.class, ClusterIT.class})
+public class IoTDBTableIT {
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ EnvFactory.getEnv().initClusterEnvironment();
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ EnvFactory.getEnv().cleanClusterEnvironment();
+ }
+}
(iotdb) 02/02: Add IT for database management
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch ty/TableModelDevelop
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit d52875a6f0aa358e475f2e8a4d2d647c892e9ff0
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Tue Jun 4 21:24:37 2024 +0800
Add IT for database management
---
.../relational/it/schema/IoTDBDatabaseIT.java | 38 ++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java
index b76676f9c78..fca431f8432 100644
--- a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java
@@ -40,6 +40,7 @@ import java.sql.Statement;
import static org.apache.iotdb.db.queryengine.common.header.ColumnHeaderConstant.showDBColumnHeaders;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@RunWith(IoTDBTestRunner.class)
@@ -113,6 +114,43 @@ public class IoTDBDatabaseIT {
assertEquals("508: Path [root.test] does not exist", e.getMessage());
}
+ // create with strange name
+ try {
+ statement.execute("create database 1test");
+ fail("create database 1test shouldn't succeed because test1 doesn't exist");
+ } catch (SQLException e) {
+ assertTrue(
+ e.getMessage(),
+ e.getMessage()
+ .endsWith(
+ "identifiers must not start with a digit; surround the identifier with double quotes"));
+ }
+
+ statement.execute("create database \"1test\"");
+ statement.execute("use \"1test\"");
+
+ try {
+ statement.execute("create database 1");
+ fail("create database 1test shouldn't succeed because test1 doesn't exist");
+ } catch (SQLException e) {
+ // TODO add error msg assert
+ }
+
+ // TODO fix it, should succeed
+ statement.execute("create database \"1\"");
+ statement.execute("use \"1\"");
+
+ try {
+ statement.execute("create database a.b");
+ fail("create database 1test shouldn't succeed because test1 doesn't exist");
+ } catch (SQLException e) {
+ // TODO add error msg assert
+ }
+
+ // TODO fix it, should succeed
+ statement.execute("create database \"a.b\"");
+ statement.execute("use \"a.b\"");
+
} catch (SQLException e) {
e.printStackTrace();
fail(e.getMessage());