Copilot commented on code in PR #15256:
URL: https://github.com/apache/iotdb/pull/15256#discussion_r2024028188
##########
integration-test/src/test/java/org/apache/iotdb/confignode/it/partition/IoTDBPartitionTableAutoCleanIT.java:
##########
@@ -73,46 +77,100 @@ public void tearDown() {
}
@Test
- public void testAutoCleanPartitionTable() throws Exception {
- try (Connection connection = EnvFactory.getEnv().getConnection();
+ public void testAutoCleanPartitionTableForTreeModel() throws Exception {
+ try (Connection connection =
EnvFactory.getEnv().getConnection(BaseEnv.TREE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
- // Create db1
- statement.execute("CREATE DATABASE root.db1");
- statement.execute("CREATE TIMESERIES root.db1.s WITH
DATATYPE=INT64,ENCODING=PLAIN");
- // Insert expired data
- statement.execute(
- String.format(
- "INSERT INTO root.db1(timestamp, s) VALUES (%d, %d)",
- TEST_CURRENT_TIME_SLOT.getStartTime() - TEST_TTL * 2, -1));
- // Insert existed data
- statement.execute(
- String.format(
- "INSERT INTO root.db1(timestamp, s) VALUES (%d, %d)",
- TEST_CURRENT_TIME_SLOT.getStartTime(), 1));
- // Let db.TTL > device.TTL, the valid TTL should be the bigger one
- statement.execute("SET TTL TO root.db1 " + TEST_TTL);
- statement.execute("SET TTL TO root.db1.s " + 10);
- // Create db2
- statement.execute("CREATE DATABASE root.db2");
- statement.execute("CREATE TIMESERIES root.db2.s WITH
DATATYPE=INT64,ENCODING=PLAIN");
- // Insert expired data
+ // Create databases and insert test data
+ for (int i = 0; i < 3; i++) {
+ String databaseName = String.format("%s%d", TREE_DATABASE_PREFIX, i);
+ statement.execute(String.format("CREATE DATABASE %s", databaseName));
+ statement.execute(
+ String.format(
+ "CREATE TIMESERIES %s.s WITH DATATYPE=INT64,ENCODING=PLAIN",
databaseName));
+ // Insert expired data
+ statement.execute(
+ String.format(
+ "INSERT INTO %s(timestamp, s) VALUES (%d, %d)",
+ databaseName, TEST_CURRENT_TIME_SLOT.getStartTime() - TEST_TTL
* 2, -1));
+ // Insert existed data
+ statement.execute(
+ String.format(
+ "INSERT INTO %s(timestamp, s) VALUES (%d, %d)",
+ databaseName, TEST_CURRENT_TIME_SLOT.getStartTime(), 1));
+ }
+ // Let db0.TTL > device.TTL, the valid TTL should be the bigger one
+ statement.execute(String.format("SET TTL TO %s0 %d",
TREE_DATABASE_PREFIX, TEST_TTL));
+ statement.execute(String.format("SET TTL TO %s0.s %d",
TREE_DATABASE_PREFIX, 10));
+ // Let db1.TTL < device.TTL, the valid TTL should be the bigger one
+ statement.execute(String.format("SET TTL TO %s1 %d",
TREE_DATABASE_PREFIX, 10));
+ statement.execute(String.format("SET TTL TO %s1.s %d",
TREE_DATABASE_PREFIX, TEST_TTL));
+ // Set TTL to path db2.**
+ statement.execute(String.format("SET TTL TO %s2.** %d",
TREE_DATABASE_PREFIX, TEST_TTL));
+ }
+
+ TDataPartitionReq req = new TDataPartitionReq();
+ for (int i = 0; i < 3; i++) {
+ req.putToPartitionSlotsMap(String.format("%s%d", TREE_DATABASE_PREFIX,
i), new TreeMap<>());
+ }
+ try (SyncConfigNodeIServiceClient client =
+ (SyncConfigNodeIServiceClient)
EnvFactory.getEnv().getLeaderConfigNodeConnection()) {
+ for (int retry = 0; retry < 120; retry++) {
+ boolean partitionTableAutoCleaned = true;
+ TDataPartitionTableResp resp = client.getDataPartitionTable(req);
+ if (TSStatusCode.SUCCESS_STATUS.getStatusCode() ==
resp.getStatus().getCode()) {
+ partitionTableAutoCleaned =
+ resp.getDataPartitionTable().entrySet().stream()
+ .flatMap(e1 -> e1.getValue().entrySet().stream())
+ .allMatch(e2 -> e2.getValue().size() == 1);
+ }
+ if (partitionTableAutoCleaned) {
+ return;
+ }
+ TimeUnit.SECONDS.sleep(1);
+ }
+ }
+ Assert.fail("The PartitionTable in the ConfigNode is not auto cleaned!");
+ }
+
+ @Test
+ public void testAutoCleanPartitionTableForTableModel() throws Exception {
+ try (final Connection connection =
+ EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
+ final Statement statement = connection.createStatement()) {
+ // Create databases and insert test data
+ for (int i = 0; i < 2; i++) {
+ System.out.println(i);
Review Comment:
Remove the debug print statement to ensure clean test output. If logging is
needed, consider using a logger at an appropriate level.
--
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]