Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ private void checkRegionDistribution(
.merge(regionInfo.getDataNodeId(), 1, Integer::sum);
});
// The number of RegionGroups should not less than the testMinRegionGroupNum for each database
// +1 for AUDIT database
Assert.assertEquals(TEST_DATABASE_NUM + 1, databaseRegionCounter.size());
Assert.assertEquals(TEST_DATABASE_NUM, databaseRegionCounter.size());
databaseRegionCounter.forEach(
(database, regionCount) ->
Assert.assertTrue(
Expand All @@ -209,8 +208,7 @@ private void checkRegionDistribution(
<= 1);
// The maximal Region count - minimal Region count should be less than or equal to 1 for each
// Database
// +1 for system database
Assert.assertEquals(TEST_DATABASE_NUM + 1, databaseDataNodeRegionCounter.size());
Assert.assertEquals(TEST_DATABASE_NUM, databaseDataNodeRegionCounter.size());
databaseDataNodeRegionCounter.forEach(
(database, dataNodeRegionCount) ->
Assert.assertTrue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,7 @@ public void testGetSchemaNodeManagementPartition() throws Exception {
nodeManagementResp = client.getSchemaNodeManagementPartition(nodeManagementReq);
Assert.assertEquals(
TSStatusCode.SUCCESS_STATUS.getStatusCode(), nodeManagementResp.getStatus().getCode());
// +1 for AUDIT database
Assert.assertEquals(databaseNum + 1, nodeManagementResp.getMatchedNodeSize());
Assert.assertEquals(databaseNum, nodeManagementResp.getMatchedNodeSize());
Assert.assertNotNull(nodeManagementResp.getSchemaRegionMap());
Assert.assertEquals(0, nodeManagementResp.getSchemaRegionMapSize());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ private void recoverTest(int configNodeNum, boolean needRestartLeader) throws Ex
Callable<Boolean> finalCheck =
() -> {
TShowDatabaseResp resp1 = newLeaderClient.showDatabase(showAllDatabasesReq);
if (MAX_STATE != resp1.getDatabaseInfoMap().size() - 1) {
if (resp1.getDatabaseInfoMap() == null
|| MAX_STATE != resp1.getDatabaseInfoMap().size()) {
return false;
}
resp1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ public void singleRegionTest() throws Exception {
Set<Integer> allDataNodeId = getAllDataNodes(statement);

// expect one data region, one schema region
// plus one AUDIT data region, one AUDIT schema region
Assert.assertEquals(4, regionMap.size());
Assert.assertEquals(2, regionMap.size());

// expand
for (int selectedRegion : regionMap.keySet()) {
Expand Down Expand Up @@ -217,8 +216,7 @@ public void multiRegionNormalTest() throws Exception {
Set<Integer> allDataNodeId = getAllDataNodes(statement);

// expect one data region, one schema region
// plus one AUDIT data region, one AUDIT schema region
Assert.assertEquals(4, regionMap.size());
Assert.assertEquals(2, regionMap.size());

// select multiple regions for testing
List<Integer> selectedRegions = new ArrayList<>(regionMap.keySet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void normal1C3DTest() throws Exception {
Set<Integer> allDataNodeId = getAllDataNodes(statement);

// select datanode
final int selectedRegion = 3;
final int selectedRegion = 1;
Assert.assertTrue(dataRegionMap.containsKey(selectedRegion));
Pair<Integer, Set<Integer>> leaderAndNodeIds = dataRegionMap.get(selectedRegion);
Assert.assertEquals(2, leaderAndNodeIds.right.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void testCompressionRatioFile() throws SQLException {
statement.execute("insert into root.comprssion_ratio_file.d1(timestamp,s1) values(1,1.0)");
statement.execute("flush");
// one global file and two data region file (including one AUDIT region)
assertEquals(3, collectCompressionRatioFiles(nodeWrapper).size());
assertEquals(2, collectCompressionRatioFiles(nodeWrapper).size());

statement.execute("drop database root.comprssion_ratio_file");
// one global file and system region file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
package org.apache.iotdb.db.it.auth;

import org.apache.iotdb.commons.auth.entity.PrivilegeType;
import org.apache.iotdb.commons.conf.CommonDescriptor;
import org.apache.iotdb.commons.schema.column.ColumnHeaderConstant;
import org.apache.iotdb.commons.utils.AuthUtils;
import org.apache.iotdb.db.it.utils.TestUtils;
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
Expand Down Expand Up @@ -51,8 +49,6 @@
import java.util.Set;
import java.util.concurrent.Callable;

import static org.apache.iotdb.commons.auth.entity.User.INTERNAL_USER_END_ID;
import static org.apache.iotdb.db.audit.DNAuditLogger.PREFIX_PASSWORD_HISTORY;
import static org.apache.iotdb.db.it.utils.TestUtils.createUser;
import static org.apache.iotdb.db.it.utils.TestUtils.executeNonQuery;
import static org.apache.iotdb.db.it.utils.TestUtils.resultSetEqualTest;
Expand Down Expand Up @@ -1521,107 +1517,6 @@ public void testStrongPassword() throws SQLException {
}
}

@Test
public void testPasswordHistory() {
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
testPasswordHistoryEncrypted(statement);
testPasswordHistoryCreateAndDrop(statement);
testPasswordHistoryAlter(statement);
} catch (SQLException e) {
e.printStackTrace();
fail(e.getMessage());
}
}

public void testPasswordHistoryEncrypted(Statement statement) throws SQLException {
ResultSet resultSet =
statement.executeQuery("SELECT password,oldPassword from root.__audit.password_history._0");
assertTrue(resultSet.next());
assertEquals(
AuthUtils.encryptPassword(CommonDescriptor.getInstance().getConfig().getAdminPassword()),
resultSet.getString("root.__audit.password_history._0.password"));
assertEquals(
AuthUtils.encryptPassword(CommonDescriptor.getInstance().getConfig().getAdminPassword()),
resultSet.getString("root.__audit.password_history._0.oldPassword"));
}

public void testPasswordHistoryCreateAndDrop(Statement statement) throws SQLException {
statement.execute("create user userA 'abcdef123456'");

long expectedUserAId = INTERNAL_USER_END_ID + 1;
try (ResultSet resultSet =
statement.executeQuery(
String.format(
"select last password from %s.`_" + expectedUserAId + "`",
PREFIX_PASSWORD_HISTORY))) {
if (!resultSet.next()) {
fail("Password history not found");
}
assertEquals(AuthUtils.encryptPassword("abcdef123456"), resultSet.getString("Value"));
}

try (ResultSet resultSet =
statement.executeQuery(
String.format(
"select last oldPassword from %s.`_" + expectedUserAId + "`",
PREFIX_PASSWORD_HISTORY))) {
if (!resultSet.next()) {
fail("Password history not found");
}
assertEquals(AuthUtils.encryptPassword("abcdef123456"), resultSet.getString("Value"));
}

statement.execute("drop user userA");

try (ResultSet resultSet =
statement.executeQuery(
String.format(
"select last password from %s.`_" + expectedUserAId + "`",
PREFIX_PASSWORD_HISTORY))) {
assertFalse(resultSet.next());
}

try (ResultSet resultSet =
statement.executeQuery(
String.format(
"select last oldPassword from %s.`_" + expectedUserAId + "`",
PREFIX_PASSWORD_HISTORY))) {
assertFalse(resultSet.next());
}
}

public void testPasswordHistoryAlter(Statement statement) throws SQLException {
statement.execute("create user userA 'abcdef123456'");
statement.execute("alter user userA set password 'abcdef654321'");

long expectedUserAId = INTERNAL_USER_END_ID + 2;
try (ResultSet resultSet =
statement.executeQuery(
String.format(
"select last password from %s.`_" + expectedUserAId + "`",
PREFIX_PASSWORD_HISTORY))) {
if (!resultSet.next()) {
fail("Password history not found");
}
assertEquals(AuthUtils.encryptPassword("abcdef654321"), resultSet.getString("Value"));
}

try (ResultSet resultSet =
statement.executeQuery(
String.format(
"select oldPassword from %s.`_" + expectedUserAId + "` order by time desc limit 1",
PREFIX_PASSWORD_HISTORY))) {
if (!resultSet.next()) {
fail("Password history not found");
}
assertEquals(
AuthUtils.encryptPassword("abcdef123456"),
resultSet.getString(
String.format("%s._" + expectedUserAId + ".oldPassword", PREFIX_PASSWORD_HISTORY)));
}
}

@Test
public void testChangeBackPassword() {
try (Connection connection = EnvFactory.getEnv().getConnection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void setUp() throws Exception {
mqtt.setUserName(USER);
mqtt.setPassword(PASSWORD);
mqtt.setConnectAttemptsMax(3);
mqtt.setReconnectDelay(10);
mqtt.setReconnectDelay(1000);
mqtt.setClientId("jsonClientId1");

connection = mqtt.blockingConnection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ public void testDeleteAllDatabases() throws Exception {
result.add(resultSet.getString(1));
}
}
// One for un-deletable AUDIT database
assertEquals(1, result.size());
assertEquals(0, result.size());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public void testLifeCycleWithHistoryDisabled() throws Exception {
"count(timeseries),",
Collections.singleton("0,"));
TestUtils.assertDataEventuallyOnEnv(
receiverEnv, "count databases", "count,", Collections.singleton("4,"));
receiverEnv, "count databases", "count,", Collections.singleton("3,"));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,10 @@ private void doTestUseNodeUrls(String sinkName) throws Exception {
null);

TestUtils.assertDataEventuallyOnEnv(
receiverEnv, "count timeseries", "count(timeseries),", Collections.singleton("4,"));
receiverEnv, "count timeseries", "count(timeseries),", Collections.singleton("2,"));

TestUtils.assertDataEventuallyOnEnv(
receiverEnv, "count databases", "count,", Collections.singleton("3,"));
receiverEnv, "count databases", "count,", Collections.singleton("2,"));

// Test file mode
sourceAttributes.put("source.inclusion", "data");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1040,8 +1040,6 @@ public void testRealtimeLooseRange() throws Exception {
}

private void assertTimeseriesCountOnReceiver(BaseEnv receiverEnv, int count) {
// for system password history
count += 2;
TestUtils.assertDataEventuallyOnEnv(
receiverEnv,
"count timeseries root.**",
Expand Down
Loading
Loading