Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ Generated source directories that need to be on the source path:
### Code Style

- **Always run `mvn spotless:apply` after editing Java files**: Spotless runs `spotless:check` automatically during the `compile` phase. Format violations cause an immediate BUILD FAILURE. Make it a habit to run `mvn spotless:apply -pl <module>` right after editing, not at the end. For files under `integration-test/`, add `-P with-integration-tests`.
- **Always run `black` and `isort` after editing Python files under `iotdb-core/ainode/`**: The AINode Code Style Check CI runs `black --check .` and `isort --check-only --profile black .` on that directory. Run `cd iotdb-core/ainode && black . && isort --profile black .` before committing. Requires `pip install black==25.1.0 isort==6.0.1`.
- **Gson version compatibility**: `JsonObject.isEmpty()` / `JsonArray.isEmpty()` may not be available in the Gson version used by this project. Use `size() > 0` instead and add a comment explaining why.

## Git Commit
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@
import org.apache.iotdb.itbase.category.AIClusterIT;
import org.apache.iotdb.itbase.env.BaseEnv;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
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;

Expand All @@ -44,39 +43,56 @@
@Category({AIClusterIT.class})
public class AINodeClusterConfigIT {

@Before
public void setUp() throws Exception {
// Init 1C1D1A cluster environment
@BeforeClass
public static void setUp() throws Exception {
EnvFactory.getEnv().initClusterEnvironment(1, 1);
}

@After
public void tearDown() throws Exception {
@AfterClass
public static void tearDown() throws Exception {
EnvFactory.getEnv().cleanClusterEnvironment();
}

@Test
public void aiNodeRegisterAndRemoveTestInTree() throws SQLException {
public void aiNodeRegisterAndRemoveTest() throws SQLException {
String show_sql = "SHOW AINODES";
String title = "NodeID,Status,InternalAddress,InternalPort";

// Verify AINode exists via both dialects before removal
try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TREE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
aiNodeRegisterAndRemoveTest(statement);
verifyAINodeExists(statement, show_sql, title);
}
try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
verifyAINodeExists(statement, show_sql, title);
}
}

@Test
public void aiNodeRegisterAndRemoveTestInTable() throws SQLException {
// Remove AINode
try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TREE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
statement.execute("REMOVE AINODE");
waitForAINodeRemoval(statement, show_sql, title);
}

// Verify removal is visible via table dialect as well
try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
aiNodeRegisterAndRemoveTest(statement);
try (ResultSet resultSet = statement.executeQuery(show_sql)) {
checkHeader(resultSet.getMetaData(), title);
int count = 0;
while (resultSet.next()) {
count++;
}
assertEquals(0, count);
}
}
}

private void aiNodeRegisterAndRemoveTest(Statement statement) throws SQLException {
String show_sql = "SHOW AINODES";
String title = "NodeID,Status,InternalAddress,InternalPort";
try (ResultSet resultSet = statement.executeQuery(show_sql)) {
ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
checkHeader(resultSetMetaData, title);
private static void verifyAINodeExists(Statement statement, String showSql, String title)
throws SQLException {
try (ResultSet resultSet = statement.executeQuery(showSql)) {
checkHeader(resultSet.getMetaData(), title);
int count = 0;
while (resultSet.next()) {
assertEquals("2", resultSet.getString(1));
Expand All @@ -85,22 +101,23 @@ private void aiNodeRegisterAndRemoveTest(Statement statement) throws SQLExceptio
}
assertEquals(1, count);
}
String remove_sql = "REMOVE AINODE";
statement.execute(remove_sql);
}

private static void waitForAINodeRemoval(Statement statement, String showSql, String title)
throws SQLException {
for (int retry = 0; retry < 500; retry++) {
try (ResultSet resultSet = statement.executeQuery(show_sql)) {
ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
checkHeader(resultSetMetaData, title);
try (ResultSet resultSet = statement.executeQuery(showSql)) {
checkHeader(resultSet.getMetaData(), title);
int count = 0;
while (resultSet.next()) {
count++;
}
if (count == 0) {
return; // Successfully removed the AI node
return;
}
}
try {
Thread.sleep(1000); // Wait before retrying
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
Expand Down

This file was deleted.

Loading
Loading