Skip to content

Commit 8592202

Browse files
committed
resolve conflict
2 parents f128cd5 + 1746cdb commit 8592202

File tree

164 files changed

+6922
-747
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+6922
-747
lines changed

integration-test/src/test/java/org/apache/iotdb/db/it/auth/IoTDBAuthIT.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import static org.apache.iotdb.commons.auth.entity.User.INTERNAL_USER_END_ID;
5555
import static org.apache.iotdb.db.audit.DNAuditLogger.PREFIX_PASSWORD_HISTORY;
5656
import static org.apache.iotdb.db.it.utils.TestUtils.createUser;
57+
import static org.apache.iotdb.db.it.utils.TestUtils.executeNonQuery;
5758
import static org.apache.iotdb.db.it.utils.TestUtils.resultSetEqualTest;
5859
import static org.junit.Assert.assertEquals;
5960
import static org.junit.Assert.assertFalse;
@@ -980,6 +981,8 @@ public void testGrantAndGrantOpt() throws SQLException {
980981
adminStmt.execute("CREATE USER user1 'password123456'");
981982
adminStmt.execute("CREATE USER user2 'password123456'");
982983
adminStmt.execute("CREATE USER user3 'password123456'");
984+
adminStmt.execute("CREATE USER user4 'password123456'");
985+
adminStmt.execute("CREATE USER user5 'password123456'");
983986
adminStmt.execute("CREATE ROLE testRole");
984987
adminStmt.execute("GRANT system ON root.** TO ROLE testRole WITH GRANT OPTION");
985988
adminStmt.execute("GRANT READ_DATA ON root.t1.** TO ROLE testRole");
@@ -1094,6 +1097,18 @@ public void testGrantAndGrantOpt() throws SQLException {
10941097
}
10951098
}
10961099

1100+
try (Connection userCon = EnvFactory.getEnv().getConnection("user4", "password123456");
1101+
Statement userStmt = userCon.createStatement()) {
1102+
adminStmt.execute("GRANT SYSTEM ON root.** TO USER user4");
1103+
try {
1104+
Assert.assertThrows(
1105+
SQLException.class, () -> userStmt.execute("GRANT SYSTEM ON root.** TO USER user5"));
1106+
adminStmt.execute("GRANT SYSTEM ON root.** TO USER user5");
1107+
} finally {
1108+
userStmt.close();
1109+
}
1110+
}
1111+
10971112
adminStmt.close();
10981113
}
10991114

@@ -1381,6 +1396,7 @@ public void noNeedPrivilegeTest() {
13811396
"tempuser,",
13821397
};
13831398
resultSetEqualTest("show current_user", expectedHeader, retArray, "tempuser", "temppw123456");
1399+
executeNonQuery("SHOW AVAILABLE URLS", "tempuser", "temppw123456");
13841400
}
13851401

13861402
@Ignore

integration-test/src/test/java/org/apache/iotdb/db/it/selectinto/IoTDBSelectIntoIT.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.apache.iotdb.db.it.selectinto;
2121

22+
import org.apache.iotdb.db.it.utils.TSDataTypeTestUtils;
2223
import org.apache.iotdb.it.env.EnvFactory;
2324
import org.apache.iotdb.it.framework.IoTDBTestRunner;
2425
import org.apache.iotdb.itbase.category.ClusterIT;
@@ -104,13 +105,11 @@ public class IoTDBSelectIntoIT {
104105
static {
105106
SELECT_INTO_SQL_LIST.add("CREATE DATABASE root.sg_type");
106107
for (int deviceId = 0; deviceId < 6; deviceId++) {
107-
for (TSDataType dataType : TSDataType.values()) {
108-
if (!dataType.equals(TSDataType.VECTOR) && !dataType.equals(TSDataType.UNKNOWN)) {
109-
SELECT_INTO_SQL_LIST.add(
110-
String.format(
111-
"CREATE TIMESERIES root.sg_type.d_%d.s_%s %s",
112-
deviceId, dataType.name().toLowerCase(), dataType));
113-
}
108+
for (TSDataType dataType : TSDataTypeTestUtils.getSupportedTypes()) {
109+
SELECT_INTO_SQL_LIST.add(
110+
String.format(
111+
"CREATE TIMESERIES root.sg_type.d_%d.s_%s %s",
112+
deviceId, dataType.name().toLowerCase(), dataType));
114113
}
115114
}
116115
for (int time = 0; time < 12; time++) {
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.iotdb.db.it.utils;
20+
21+
import org.apache.tsfile.enums.TSDataType;
22+
23+
import java.util.Arrays;
24+
import java.util.HashSet;
25+
import java.util.List;
26+
import java.util.Set;
27+
import java.util.stream.Collectors;
28+
29+
/**
30+
* Utility class for TSDataType operations in integration tests. This class provides helper methods
31+
* to filter out unsupported data types that should not be used in tests.
32+
*
33+
* <p>Usage in IT tests:
34+
*
35+
* <pre>{@code
36+
* Set<TSDataType> dataTypes = TSDataTypeTestUtils.getSupportedTypes();
37+
* for (TSDataType from : dataTypes) {
38+
* for (TSDataType to : dataTypes) {
39+
* // test logic
40+
* }
41+
* }
42+
* }</pre>
43+
*
44+
* <p>To find this utility class quickly, search for: "TSDataTypeTestUtils" or "getSupportedTypes"
45+
*/
46+
public class TSDataTypeTestUtils {
47+
48+
private TSDataTypeTestUtils() {
49+
// utility class
50+
}
51+
52+
/**
53+
* Get the set of unsupported TSDataType values that should be filtered out in tests.
54+
*
55+
* <p>Currently includes: VECTOR, UNKNOWN, OBJECT
56+
*
57+
* @return Set of unsupported TSDataType values
58+
*/
59+
public static Set<TSDataType> getUnsupportedTypes() {
60+
Set<TSDataType> unsupported = new HashSet<>();
61+
unsupported.add(TSDataType.VECTOR);
62+
unsupported.add(TSDataType.UNKNOWN);
63+
unsupported.add(TSDataType.OBJECT);
64+
return unsupported;
65+
}
66+
67+
/**
68+
* Check if a TSDataType is supported for general use (not an internal type).
69+
*
70+
* @param dataType the TSDataType to check
71+
* @return true if the type is supported, false otherwise
72+
*/
73+
public static boolean isSupportedType(TSDataType dataType) {
74+
return !getUnsupportedTypes().contains(dataType);
75+
}
76+
77+
/**
78+
* Get all supported TSDataType values (filters out unsupported types).
79+
*
80+
* <p>This method filters out VECTOR, UNKNOWN, and any other types returned by {@link
81+
* #getUnsupportedTypes()}.
82+
*
83+
* @return Set of supported TSDataType values
84+
*/
85+
public static Set<TSDataType> getSupportedTypes() {
86+
Set<TSDataType> allTypes = new HashSet<>(Arrays.asList(TSDataType.values()));
87+
allTypes.removeAll(getUnsupportedTypes());
88+
return allTypes;
89+
}
90+
91+
/**
92+
* Get all supported TSDataType values as a List (filters out unsupported types).
93+
*
94+
* @return List of supported TSDataType values
95+
*/
96+
public static List<TSDataType> getSupportedTypesList() {
97+
return Arrays.stream(TSDataType.values())
98+
.filter(TSDataTypeTestUtils::isSupportedType)
99+
.collect(Collectors.toList());
100+
}
101+
102+
/**
103+
* Filter a collection of TSDataType values to only include supported types.
104+
*
105+
* @param dataTypes collection of TSDataType values to filter
106+
* @return Set containing only supported types
107+
*/
108+
public static Set<TSDataType> filterSupportedTypes(Set<TSDataType> dataTypes) {
109+
Set<TSDataType> result = new HashSet<>(dataTypes);
110+
result.removeAll(getUnsupportedTypes());
111+
return result;
112+
}
113+
}

integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/tablemodel/TableModelUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public static void insertData(
108108
for (int i = startInclusive; i < endExclusive; ++i) {
109109
list.add(
110110
String.format(
111-
"insert into %s (s0, s3, s2, s1, s4, s5, s6, s7, s8, s9, s10, s11, time) values ('t%s','t%s','t%s','t%s','%s', %s.0, %s, %s, %d, %d.0, '%s', '%s', %s)",
111+
"insert into %s (s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, time) values ('t%s','t%s','t%s','t%s','%s', %s.0, %s, %s, %d, %d.0, '%s', '%s', %s)",
112112
tableName, i, i, i, i, i, i, i, i, i, i, getDateStr(i), i, i));
113113
}
114114
list.add("flush");
@@ -128,7 +128,7 @@ public static void insertData(
128128
for (int i = startInclusive; i < endExclusive; ++i) {
129129
list.add(
130130
String.format(
131-
"insert into %s (s0, s3, s2, s1, s4, s5, s6, s7, s8, s9, s10, s11, time) values ('t%s','t%s','t%s','t%s','%s', %s.0, %s, %s, %d, %d.0, '%s', '%s', %s)",
131+
"insert into %s (s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, time) values ('t%s','t%s','t%s','t%s','%s', %s.0, %s, %s, %d, %d.0, '%s', '%s', %s)",
132132
tableName,
133133
deviceIndex,
134134
deviceIndex,
@@ -208,7 +208,7 @@ public static boolean insertDataNotThrowError(
208208
for (int i = start; i < end; ++i) {
209209
list.add(
210210
String.format(
211-
"insert into %s (s0, s3, s2, s1, s4, s5, s6, s7, s8, s9, s10, s11, time) values ('t%s','t%s','t%s','t%s','%s', %s.0, %s, %s, %d, %d.0, '%s', '%s', %s)",
211+
"insert into %s (s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, time) values ('t%s','t%s','t%s','t%s','%s', %s.0, %s, %s, %d, %d.0, '%s', '%s', %s)",
212212
tableName, i, i, i, i, i, i, i, i, i, i, getDateStr(i), i, i));
213213
}
214214
try {
@@ -230,7 +230,7 @@ public static boolean insertData(
230230
for (int i = start; i < end; ++i) {
231231
list.add(
232232
String.format(
233-
"insert into %s (s0, s3, s2, s1, s4, s5, s6, s7, s8, s9, s10, s11, time) values ('t%s','t%s','t%s','t%s','%s', %s.0, %s, %s, %d, %d.0, '%s', '%s', %s)",
233+
"insert into %s (s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, time) values ('t%s','t%s','t%s','t%s','%s', %s.0, %s, %s, %d, %d.0, '%s', '%s', %s)",
234234
tableName, i, i, i, i, i, i, i, i, i, i, getDateStr(i), i, i));
235235
}
236236
list.add("flush");

integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/auto/basic/IoTDBPipeSyntaxIT.java

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.junit.experimental.categories.Category;
3838
import org.junit.runner.RunWith;
3939

40+
import java.io.File;
4041
import java.sql.Connection;
4142
import java.sql.SQLException;
4243
import java.sql.Statement;
@@ -757,4 +758,64 @@ public void testValidPipeWithoutWithSink() {
757758
fail(e.getMessage());
758759
}
759760
}
761+
762+
@Test
763+
public void testPipePluginValidation() {
764+
try (final Connection connection = senderEnv.getConnection();
765+
final Statement statement = connection.createStatement()) {
766+
try {
767+
statement.execute(
768+
"create pipePlugin TestProcessor as 'org.apache.iotdb.db.pipe.example.TestProcessor' USING URI 'xxx'");
769+
fail();
770+
} catch (final SQLException e) {
771+
Assert.assertEquals(
772+
"701: Untrusted uri xxx, current trusted_uri_pattern is file:.*", e.getMessage());
773+
}
774+
try {
775+
statement.execute(
776+
"create pipePlugin TestProcessor as 'org.apache.iotdb.db.pipe.example.TestProcessor' USING URI 'file:.*'");
777+
fail();
778+
} catch (final SQLException e) {
779+
Assert.assertEquals("701: URI is not hierarchical", e.getMessage());
780+
}
781+
try {
782+
statement.execute(
783+
String.format(
784+
"create pipePlugin TestProcessor as 'org.apache.iotdb.db.pipe.example.TestProcessor' USING URI '%s'",
785+
new File(
786+
System.getProperty("user.dir")
787+
+ File.separator
788+
+ "target"
789+
+ File.separator
790+
+ "test-classes"
791+
+ File.separator)
792+
.toURI()
793+
+ "PipePlugin.jar"));
794+
fail();
795+
} catch (final SQLException e) {
796+
Assert.assertEquals(
797+
"1603: Failed to get executable for PipePlugin TestProcessor, please check the URI.",
798+
e.getMessage());
799+
}
800+
try {
801+
statement.execute("drop pipePlugin test_processor");
802+
fail();
803+
} catch (final SQLException e) {
804+
Assert.assertEquals(
805+
"1601: Failed to drop pipe plugin TEST_PROCESSOR. Failures: TEST_PROCESSOR does not exist.",
806+
e.getMessage());
807+
}
808+
try {
809+
statement.execute("drop pipePlugin `Do-Nothing-Sink`");
810+
fail();
811+
} catch (final SQLException e) {
812+
Assert.assertEquals(
813+
"1601: Failed to drop PipePlugin [DO-NOTHING-SINK], the PipePlugin is a built-in PipePlugin",
814+
e.getMessage());
815+
}
816+
} catch (final SQLException e) {
817+
e.printStackTrace();
818+
fail(e.getMessage());
819+
}
820+
}
760821
}

integration-test/src/test/java/org/apache/iotdb/pipe/it/single/IoTDBPipePermissionIT.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
package org.apache.iotdb.pipe.it.single;
2121

22-
import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
23-
import org.apache.iotdb.confignode.rpc.thrift.TShowPipeReq;
2422
import org.apache.iotdb.db.it.utils.TestUtils;
2523
import org.apache.iotdb.it.framework.IoTDBTestRunner;
2624
import org.apache.iotdb.itbase.category.MultiClusterIT1;
@@ -33,6 +31,7 @@
3331
import org.junit.runner.RunWith;
3432

3533
import java.sql.Connection;
34+
import java.sql.ResultSet;
3635
import java.sql.SQLException;
3736
import java.sql.Statement;
3837
import java.util.Arrays;
@@ -44,7 +43,7 @@
4443
public class IoTDBPipePermissionIT extends AbstractPipeSingleIT {
4544
@Test
4645
public void testSinkPermission() {
47-
TestUtils.executeNonQuery(env, "create user `thulab` 'passwd'", null);
46+
TestUtils.executeNonQuery(env, "create user `thulab` 'StrngPsWd@623451'", null);
4847

4948
// Shall fail if username is specified without password
5049
try (final Connection connection = env.getConnection(BaseEnv.TABLE_SQL_DIALECT);
@@ -90,7 +89,8 @@ public void testSinkPermission() {
9089
// Successfully alter
9190
try (final Connection connection = env.getConnection(BaseEnv.TABLE_SQL_DIALECT);
9291
final Statement statement = connection.createStatement()) {
93-
statement.execute("alter pipe a2b modify sink ('username'='thulab', 'password'='passwd')");
92+
statement.execute(
93+
"alter pipe a2b modify sink ('username'='thulab', 'password'='StrngPsWd@623451')");
9494
} catch (final SQLException e) {
9595
e.printStackTrace();
9696
fail("Alter pipe shall not fail if user and password are specified");
@@ -156,14 +156,12 @@ public void testSinkPermission() {
156156
}
157157

158158
// A user shall only see its own pipe
159-
try (final SyncConfigNodeIServiceClient client =
160-
(SyncConfigNodeIServiceClient) env.getLeaderConfigNodeConnection()) {
161-
Assert.assertEquals(
162-
1,
163-
client
164-
.showPipe(new TShowPipeReq().setIsTableModel(true).setUserName("thulab"))
165-
.pipeInfoList
166-
.size());
159+
try (final Connection connection =
160+
env.getConnection("thulab", "StrngPsWd@623451", BaseEnv.TABLE_SQL_DIALECT);
161+
final Statement statement = connection.createStatement()) {
162+
final ResultSet result = statement.executeQuery("show pipes");
163+
Assert.assertTrue(result.next());
164+
Assert.assertFalse(result.next());
167165
} catch (Exception e) {
168166
fail(e.getMessage());
169167
}
@@ -181,7 +179,8 @@ public void testSinkPermissionWithHistoricalDataAndTablePattern() {
181179
BaseEnv.TABLE_SQL_DIALECT,
182180
env,
183181
Arrays.asList(
184-
"create user thulab 'passwD@123456'", "grant INSERT on test.test1 to user thulab"),
182+
"create user thulab 'StrngPsWd@623451@123456'",
183+
"grant INSERT on test.test1 to user thulab"),
185184
null);
186185

187186
// Write some data
@@ -196,7 +195,7 @@ public void testSinkPermissionWithHistoricalDataAndTablePattern() {
196195
"create pipe a2b "
197196
+ "with source ('database'='test1', 'table'='test1') "
198197
+ "with processor('processor'='rename-database-processor', 'processor.new-db-name'='test') "
199-
+ "with sink ('sink'='write-back-sink', 'username'='thulab', 'password'='passwD@123456')");
198+
+ "with sink ('sink'='write-back-sink', 'username'='thulab', 'password'='StrngPsWd@623451@123456')");
200199
} catch (final SQLException e) {
201200
e.printStackTrace();
202201
fail("Create pipe without user shall succeed if use the current session");

0 commit comments

Comments
 (0)