This is an automated email from the ASF dual-hosted git repository.
jt2594838 pushed a commit to branch dev/1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/dev/1.3 by this push:
new aa2e761f694 Fix IT log directory test class names (#18131) (#18174)
aa2e761f694 is described below
commit aa2e761f694c80bf3fc85ad73c4c8d141a57dc56
Author: Caideyipi <[email protected]>
AuthorDate: Mon Jul 13 10:31:59 2026 +0800
Fix IT log directory test class names (#18131) (#18174)
---
.../java/org/apache/iotdb/it/env/MultiEnvFactory.java | 8 +++++++-
.../org/apache/iotdb/it/env/cluster/env/AbstractEnv.java | 15 +++++++++++++++
.../apache/iotdb/it/env/cluster/env/MultiClusterEnv.java | 9 +++++++++
.../main/java/org/apache/iotdb/itbase/env/BaseEnv.java | 4 ++++
.../org/apache/iotdb/it/framework/IoTDBTestRunner.java | 8 ++++++++
.../iotdb/it/framework/IoTDBTestRunnerWithParameters.java | 15 ++++++++++++++-
6 files changed, 57 insertions(+), 2 deletions(-)
diff --git
a/integration-test/src/main/java/org/apache/iotdb/it/env/MultiEnvFactory.java
b/integration-test/src/main/java/org/apache/iotdb/it/env/MultiEnvFactory.java
index f2e5f9c1f90..d9fafd1353a 100644
---
a/integration-test/src/main/java/org/apache/iotdb/it/env/MultiEnvFactory.java
+++
b/integration-test/src/main/java/org/apache/iotdb/it/env/MultiEnvFactory.java
@@ -33,11 +33,17 @@ public class MultiEnvFactory {
private static final List<BaseEnv> envList = new ArrayList<>();
private static final Logger logger = IoTDBTestLogger.logger;
private static String currentMethodName;
+ private static String currentClassName;
private MultiEnvFactory() {
// Empty constructor
}
+ public static void setTestClassName(final String testClassName) {
+ currentClassName = testClassName;
+ envList.forEach(baseEnv -> baseEnv.setTestClassName(testClassName));
+ }
+
public static void setTestMethodName(final String testMethodName) {
currentMethodName = testMethodName;
envList.forEach(baseEnv -> baseEnv.setTestMethodName(testMethodName));
@@ -56,7 +62,7 @@ public class MultiEnvFactory {
for (int i = 0; i < num; ++i) {
try {
Class.forName(Config.JDBC_DRIVER_NAME);
- envList.add(new MultiClusterEnv(startTime, i, currentMethodName));
+ envList.add(new MultiClusterEnv(startTime, i, currentClassName,
currentMethodName));
} catch (final ClassNotFoundException e) {
logger.error("Create env error", e);
System.exit(-1);
diff --git
a/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/env/AbstractEnv.java
b/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/env/AbstractEnv.java
index f2b7a103f52..ffbd9b78d70 100644
---
a/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/env/AbstractEnv.java
+++
b/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/env/AbstractEnv.java
@@ -88,6 +88,7 @@ public abstract class AbstractEnv implements BaseEnv {
protected List<ConfigNodeWrapper> configNodeWrapperList =
Collections.emptyList();
protected List<DataNodeWrapper> dataNodeWrapperList =
Collections.emptyList();
protected List<AINodeWrapper> aiNodeWrapperList = Collections.emptyList();
+ protected String testClassName = null;
protected String testMethodName = null;
protected int index = 0;
protected long startTime;
@@ -321,6 +322,9 @@ public abstract class AbstractEnv implements BaseEnv {
}
public String getTestClassName() {
+ if (testClassName != null) {
+ return testClassName;
+ }
final StackTraceElement[] stack = Thread.currentThread().getStackTrace();
for (final StackTraceElement stackTraceElement : stack) {
final String className = stackTraceElement.getClassName();
@@ -948,6 +952,17 @@ public abstract class AbstractEnv implements BaseEnv {
return testMethodName;
}
+ @Override
+ public void setTestClassName(final String testClassName) {
+ if (testClassName == null || testClassName.isEmpty()) {
+ this.testClassName = null;
+ return;
+ }
+ final int lastDotIndex = testClassName.lastIndexOf(".");
+ this.testClassName =
+ lastDotIndex >= 0 ? testClassName.substring(lastDotIndex + 1) :
testClassName;
+ }
+
@Override
public void setTestMethodName(final String testMethodName) {
this.testMethodName = testMethodName;
diff --git
a/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/env/MultiClusterEnv.java
b/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/env/MultiClusterEnv.java
index d462b5a668b..554fc768586 100644
---
a/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/env/MultiClusterEnv.java
+++
b/integration-test/src/main/java/org/apache/iotdb/it/env/cluster/env/MultiClusterEnv.java
@@ -26,8 +26,17 @@ import org.apache.tsfile.utils.Pair;
public class MultiClusterEnv extends AbstractEnv {
public MultiClusterEnv(final long startTime, final int index, final String
currentMethodName) {
+ this(startTime, index, null, currentMethodName);
+ }
+
+ public MultiClusterEnv(
+ final long startTime,
+ final int index,
+ final String currentClassName,
+ final String currentMethodName) {
super(startTime);
this.index = index;
+ setTestClassName(currentClassName);
this.testMethodName = currentMethodName;
}
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 bede2b001f7..2bdcc36edd4 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
@@ -145,6 +145,10 @@ public interface BaseEnv {
Connection getConnectionWithSpecifiedDataNode(
DataNodeWrapper dataNode, String username, String password) throws
SQLException;
+ default void setTestClassName(String testClassName) {
+ // Default no-op for env implementations that do not create local node log
directories.
+ }
+
void setTestMethodName(String testCaseName);
void dumpTestJVMSnapshot();
diff --git
a/integration-test/src/test/java/org/apache/iotdb/it/framework/IoTDBTestRunner.java
b/integration-test/src/test/java/org/apache/iotdb/it/framework/IoTDBTestRunner.java
index 17e20d91e9a..a215dfd682a 100644
---
a/integration-test/src/test/java/org/apache/iotdb/it/framework/IoTDBTestRunner.java
+++
b/integration-test/src/test/java/org/apache/iotdb/it/framework/IoTDBTestRunner.java
@@ -44,6 +44,11 @@ public class IoTDBTestRunner extends BlockJUnit4ClassRunner {
@Override
public void run(final RunNotifier notifier) {
TimeZone.setDefault(TimeZone.getTimeZone("UTC+08:00"));
+ final String testClassName = getTestClass().getJavaClass().getSimpleName();
+ if (EnvType.getSystemEnvType() != EnvType.MultiCluster) {
+ EnvFactory.getEnv().setTestClassName(testClassName);
+ }
+ MultiEnvFactory.setTestClassName(testClassName);
listener = new IoTDBTestListener(this.getName());
notifier.addListener(listener);
super.run(notifier);
@@ -54,9 +59,12 @@ public class IoTDBTestRunner extends BlockJUnit4ClassRunner {
final Description description = describeChild(method);
logger.info("Run {}", description.getMethodName());
final long currentTime = System.currentTimeMillis();
+ final String testClassName = getTestClass().getJavaClass().getSimpleName();
if (EnvType.getSystemEnvType() != EnvType.MultiCluster) {
+ EnvFactory.getEnv().setTestClassName(testClassName);
EnvFactory.getEnv().setTestMethodName(description.getMethodName());
}
+ MultiEnvFactory.setTestClassName(testClassName);
MultiEnvFactory.setTestMethodName(description.getMethodName());
super.runChild(method, notifier);
final double timeCost = (System.currentTimeMillis() - currentTime) /
1000.0;
diff --git
a/integration-test/src/test/java/org/apache/iotdb/it/framework/IoTDBTestRunnerWithParameters.java
b/integration-test/src/test/java/org/apache/iotdb/it/framework/IoTDBTestRunnerWithParameters.java
index e11a930f5ad..312e29bea77 100644
---
a/integration-test/src/test/java/org/apache/iotdb/it/framework/IoTDBTestRunnerWithParameters.java
+++
b/integration-test/src/test/java/org/apache/iotdb/it/framework/IoTDBTestRunnerWithParameters.java
@@ -20,6 +20,8 @@
package org.apache.iotdb.it.framework;
import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.env.EnvType;
+import org.apache.iotdb.it.env.MultiEnvFactory;
import org.junit.runner.Description;
import org.junit.runner.notification.RunNotifier;
@@ -40,6 +42,11 @@ public class IoTDBTestRunnerWithParameters extends
BlockJUnit4ClassRunnerWithPar
@Override
public void run(RunNotifier notifier) {
+ final String testClassName = getTestClass().getJavaClass().getSimpleName();
+ if (EnvType.getSystemEnvType() != EnvType.MultiCluster) {
+ EnvFactory.getEnv().setTestClassName(testClassName);
+ }
+ MultiEnvFactory.setTestClassName(testClassName);
listener = new IoTDBTestListener(this.getName());
notifier.addListener(listener);
super.run(notifier);
@@ -50,7 +57,13 @@ public class IoTDBTestRunnerWithParameters extends
BlockJUnit4ClassRunnerWithPar
Description description = describeChild(method);
logger.info("Run {}", description.getMethodName());
long currentTime = System.currentTimeMillis();
- EnvFactory.getEnv().setTestMethodName(description.getMethodName());
+ final String testClassName = getTestClass().getJavaClass().getSimpleName();
+ if (EnvType.getSystemEnvType() != EnvType.MultiCluster) {
+ EnvFactory.getEnv().setTestClassName(testClassName);
+ EnvFactory.getEnv().setTestMethodName(description.getMethodName());
+ }
+ MultiEnvFactory.setTestClassName(testClassName);
+ MultiEnvFactory.setTestMethodName(description.getMethodName());
super.runChild(method, notifier);
double timeCost = (System.currentTimeMillis() - currentTime) / 1000.0;
String testName = description.getClassName() + "." +
description.getMethodName();