This is an automated email from the ASF dual-hosted git repository.
terrymanu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 120dbe5f79c Unify test classification and reduce test log noise
(#40049)
120dbe5f79c is described below
commit 120dbe5f79c43576e1cf03c407779bc79bef1fa0
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Oct 4 18:24:16 2026 +0800
Unify test classification and reduce test log noise (#40049)
* Fix temporary properties mock in schema handler tests
* Require independent review of defensive code changes
* Unify test classification and reduce test log noise
---
.github/workflows/graalvm.yml | 1 +
.../type/InstanceMethodAdviceExecutorTest.java | 60 ++++++++++++++++++
.../type/StaticMethodAdviceExecutorTest.java | 74 +++++++++++++---------
...ava => PrometheusPluginLifecycleServiceIT.java} | 4 +-
infra/common/src/test/resources/logback-test.xml | 2 +-
...stSQLTest.java => ShardingSphereDistSQLIT.java} | 2 +-
... PipelineInventoryCalculateSQLBuilderTest.java} | 2 +-
...rIT.java => PipelinePrepareSQLBuilderTest.java} | 2 +-
...ceTest.java => DatabaseTimestampServiceIT.java} | 38 +++--------
.../database/DatabaseTimestampServiceTest.java | 14 +---
test/e2e/driver/pom.xml | 19 ++++++
.../cases/base/BaseTransactionTestCase.java | 8 +--
test/native/pom.xml | 14 ++++
13 files changed, 158 insertions(+), 82 deletions(-)
diff --git a/.github/workflows/graalvm.yml b/.github/workflows/graalvm.yml
index 6a3ffa0ce43..3a783cc3ea2 100644
--- a/.github/workflows/graalvm.yml
+++ b/.github/workflows/graalvm.yml
@@ -25,6 +25,7 @@ on:
-
'.github/workflows/resources/actions/setup-build-environment/action.yml'
- '.github/workflows/graalvm.yml'
- 'infra/reachability-metadata/src/**'
+ - 'test/native/pom.xml'
- 'test/native/native-image-filter/**'
- 'test/native/src/**'
workflow_dispatch:
diff --git
a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/advisor/executor/type/InstanceMethodAdviceExecutorTest.java
b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/advisor/executor/type/InstanceMethodAdviceExecutorTest.java
index 647b925b455..3699e09a723 100644
---
a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/advisor/executor/type/InstanceMethodAdviceExecutorTest.java
+++
b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/advisor/executor/type/InstanceMethodAdviceExecutorTest.java
@@ -30,6 +30,8 @@ import
org.apache.shardingsphere.agent.api.advice.type.InstanceMethodAdvice;
import org.apache.shardingsphere.agent.api.plugin.AgentPluginEnable;
import org.apache.shardingsphere.agent.core.advisor.executor.AdviceExecutor;
import org.apache.shardingsphere.fixture.targeted.TargetObjectFixture;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.lang.reflect.Method;
@@ -41,6 +43,10 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
@@ -51,6 +57,29 @@ import static org.mockito.Mockito.when;
class InstanceMethodAdviceExecutorTest {
+ private final Logger logger =
Logger.getLogger(InstanceMethodAdviceExecutor.class.getName());
+
+ private final List<LogRecord> records = new LinkedList<>();
+
+ private final Handler handler = new RecordingHandler(records);
+
+ private boolean originalUseParentHandlers;
+
+ @BeforeEach
+ void setUp() {
+ originalUseParentHandlers = logger.getUseParentHandlers();
+ logger.setUseParentHandlers(false);
+ logger.addHandler(handler);
+ }
+
+ @AfterEach
+ void tearDown() {
+ logger.removeHandler(handler);
+ logger.setUseParentHandlers(originalUseParentHandlers);
+ handler.close();
+ records.forEach(logger::log);
+ }
+
@Test
void assertAdviceWhenCallableSucceeded() throws
ReflectiveOperationException {
List<String> queue = new LinkedList<>();
@@ -80,6 +109,16 @@ class InstanceMethodAdviceExecutorTest {
};
assertThrows(IllegalStateException.class, () -> executor.advice(new
SimpleTargetAdviceObject(), method, new Object[]{queue}, callable));
assertThat(queue, is(Arrays.asList("plain before foo", "config before
bar", "plain throw foo", "plain after foo", "config after bar")));
+ assertLog("Failed to execute the error handler of method `{0}` in
class `{1}`, {2}.", method.getName(), "callable error");
+ }
+
+ private void assertLog(final String expectedMessage, final String
methodName, final String errorMessage) {
+ assertThat(records.size(), is(1));
+ LogRecord actual = records.get(0);
+ assertThat(actual.getLevel(), is(Level.SEVERE));
+ assertThat(actual.getMessage(), is(expectedMessage));
+ assertThat(actual.getParameters(), is(new String[]{methodName,
SimpleTargetAdviceObject.class.getName(), errorMessage}));
+ records.remove(0);
}
@Test
@@ -124,6 +163,7 @@ class InstanceMethodAdviceExecutorTest {
};
assertThat(executor.advice(new SimpleTargetAdviceObject(), method, new
Object[]{queue}, callable), is("result"));
assertThat(queue, is(Arrays.asList("origin call", "first after foo",
"second after bar")));
+ assertLog("Failed to execute the pre-method of method `{0}` in class
`{1}`, {2}.", method.getName(), "before");
}
@Test
@@ -140,6 +180,7 @@ class InstanceMethodAdviceExecutorTest {
};
assertThat(executor.advice(new SimpleTargetAdviceObject(), method, new
Object[]{queue}, callable), is("result"));
assertThat(queue, is(Arrays.asList("first before foo", "second before
bar", "origin call")));
+ assertLog("Failed to execute the post-method of method `{0}` in class
`{1}`, {2}.", method.getName(), "after");
}
@SuppressWarnings({"unchecked", "rawtypes"})
@@ -156,6 +197,25 @@ class InstanceMethodAdviceExecutorTest {
assertThat(actual, is(intercepted));
}
+ @RequiredArgsConstructor
+ private static final class RecordingHandler extends Handler {
+
+ private final List<LogRecord> records;
+
+ @Override
+ public void publish(final LogRecord record) {
+ records.add(record);
+ }
+
+ @Override
+ public void flush() {
+ }
+
+ @Override
+ public void close() {
+ }
+ }
+
@RequiredArgsConstructor
private static final class RecordingInstanceMethodAdvice implements
InstanceMethodAdvice {
diff --git
a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/advisor/executor/type/StaticMethodAdviceExecutorTest.java
b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/advisor/executor/type/StaticMethodAdviceExecutorTest.java
index dd3eecbc897..917cae21ad9 100644
---
a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/advisor/executor/type/StaticMethodAdviceExecutorTest.java
+++
b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/advisor/executor/type/StaticMethodAdviceExecutorTest.java
@@ -27,6 +27,8 @@ import
org.apache.shardingsphere.agent.api.advice.type.StaticMethodAdvice;
import org.apache.shardingsphere.agent.api.plugin.AgentPluginEnable;
import org.apache.shardingsphere.agent.core.advisor.executor.AdviceExecutor;
import org.apache.shardingsphere.fixture.targeted.TargetObjectFixture;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.lang.reflect.Method;
@@ -39,6 +41,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.logging.Handler;
+import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
@@ -52,6 +55,29 @@ import static org.mockito.Mockito.when;
class StaticMethodAdviceExecutorTest {
+ private final Logger logger =
Logger.getLogger(StaticMethodAdviceExecutor.class.getName());
+
+ private final List<LogRecord> records = new LinkedList<>();
+
+ private final Handler handler = new RecordingHandler(records);
+
+ private boolean originalUseParentHandlers;
+
+ @BeforeEach
+ void setUp() {
+ originalUseParentHandlers = logger.getUseParentHandlers();
+ logger.setUseParentHandlers(false);
+ logger.addHandler(handler);
+ }
+
+ @AfterEach
+ void tearDown() {
+ logger.removeHandler(handler);
+ logger.setUseParentHandlers(originalUseParentHandlers);
+ handler.close();
+ records.forEach(logger::log);
+ }
+
@Test
void assertAdviceWhenCallableSucceeded() throws
ReflectiveOperationException {
List<String> queue = new LinkedList<>();
@@ -82,6 +108,16 @@ class StaticMethodAdviceExecutorTest {
};
assertThrows(IllegalStateException.class, () ->
executor.advice(TargetObjectFixture.class, method, new Object[]{queue},
callable));
assertThat(queue, is(Arrays.asList("plain before foo", "config before
bar", "plain throw foo", "plain after foo", "config after bar")));
+ assertLog("Failed to execute the error handler of method `{0}` in
class `{1}`, {2}.", method.getName(), "callable error");
+ }
+
+ private void assertLog(final String expectedMessage, final String
methodName, final String errorMessage) {
+ assertThat(records.size(), is(1));
+ LogRecord actual = records.get(0);
+ assertThat(actual.getLevel(), is(Level.SEVERE));
+ assertThat(actual.getMessage(), is(expectedMessage));
+ assertThat(actual.getParameters(), is(new String[]{methodName,
TargetObjectFixture.class.getName(), errorMessage}));
+ records.remove(0);
}
@Test
@@ -113,6 +149,7 @@ class StaticMethodAdviceExecutorTest {
Object actualResult = executor.advice(TargetObjectFixture.class,
method, new Object[]{queue}, callable);
assertThat(actualResult, is("result"));
assertThat(queue, is(Arrays.asList("origin call", "first after foo",
"second after bar")));
+ assertLog("Failed to execute the pre-method of method `{0}` in class
`{1}`, {2}.", method.getName(), "before");
}
@Test
@@ -130,6 +167,7 @@ class StaticMethodAdviceExecutorTest {
Object actualResult = executor.advice(TargetObjectFixture.class,
method, new Object[]{queue}, callable);
assertThat(actualResult, is("result"));
assertThat(queue, is(Arrays.asList("first before foo", "second before
bar", "origin call")));
+ assertLog("Failed to execute the post-method of method `{0}` in class
`{1}` {2}.", method.getName(), "after");
}
@Test
@@ -140,16 +178,8 @@ class StaticMethodAdviceExecutorTest {
StaticMethodAdviceExecutor executor = new
StaticMethodAdviceExecutor(advices);
Method method = TargetObjectFixture.class.getMethod("staticCall",
List.class);
Callable<Object> callable = () -> "result";
- List<LogRecord> records = new LinkedList<>();
- Logger logger =
Logger.getLogger(StaticMethodAdviceExecutor.class.getName());
- Handler handler = new RecordingHandler(records);
- logger.addHandler(handler);
- try {
- executor.advice(TargetObjectFixture.class, method, new
Object[]{queue}, callable);
- assertThat(records.get(0).getParameters()[1],
is(TargetObjectFixture.class.getName()));
- } finally {
- logger.removeHandler(handler);
- }
+ executor.advice(TargetObjectFixture.class, method, new
Object[]{queue}, callable);
+ assertLog("Failed to execute the pre-method of method `{0}` in class
`{1}`, {2}.", method.getName(), "before");
}
@Test
@@ -162,16 +192,8 @@ class StaticMethodAdviceExecutorTest {
Callable<Object> callable = () -> {
throw new IllegalStateException("callable error");
};
- List<LogRecord> records = new LinkedList<>();
- Logger logger =
Logger.getLogger(StaticMethodAdviceExecutor.class.getName());
- Handler handler = new RecordingHandler(records);
- logger.addHandler(handler);
- try {
- assertThrows(IllegalStateException.class, () ->
executor.advice(TargetObjectFixture.class, method, new Object[]{queue},
callable));
- assertThat(records.get(0).getParameters()[1],
is(TargetObjectFixture.class.getName()));
- } finally {
- logger.removeHandler(handler);
- }
+ assertThrows(IllegalStateException.class, () ->
executor.advice(TargetObjectFixture.class, method, new Object[]{queue},
callable));
+ assertLog("Failed to execute the error handler of method `{0}` in
class `{1}`, {2}.", method.getName(), "callable error");
}
@Test
@@ -182,16 +204,8 @@ class StaticMethodAdviceExecutorTest {
StaticMethodAdviceExecutor executor = new
StaticMethodAdviceExecutor(advices);
Method method = TargetObjectFixture.class.getMethod("staticCall",
List.class);
Callable<Object> callable = () -> "result";
- List<LogRecord> records = new LinkedList<>();
- Logger logger =
Logger.getLogger(StaticMethodAdviceExecutor.class.getName());
- Handler handler = new RecordingHandler(records);
- logger.addHandler(handler);
- try {
- executor.advice(TargetObjectFixture.class, method, new
Object[]{queue}, callable);
- assertThat(records.get(0).getParameters()[1],
is(TargetObjectFixture.class.getName()));
- } finally {
- logger.removeHandler(handler);
- }
+ executor.advice(TargetObjectFixture.class, method, new
Object[]{queue}, callable);
+ assertLog("Failed to execute the post-method of method `{0}` in class
`{1}` {2}.", method.getName(), "after");
}
@SuppressWarnings({"unchecked", "rawtypes"})
diff --git
a/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/PrometheusPluginLifecycleServiceTest.java
b/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/PrometheusPluginLifecycleServiceIT.java
similarity index 96%
rename from
agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/PrometheusPluginLifecycleServiceTest.java
rename to
agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/PrometheusPluginLifecycleServiceIT.java
index e639ce2b7ab..68cf79d6eba 100644
---
a/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/PrometheusPluginLifecycleServiceTest.java
+++
b/agent/plugins/metrics/type/prometheus/src/test/java/org/apache/shardingsphere/agent/plugin/metrics/prometheus/PrometheusPluginLifecycleServiceIT.java
@@ -62,9 +62,9 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@ExtendWith({AutoMockExtension.class, LogCaptureExtension.class})
-@LogCaptureSettings(suppressOutput = true)
+@LogCaptureSettings(value =
"org.apache.shardingsphere.agent.plugin.metrics.prometheus.PrometheusPluginLifecycleService",
suppressOutput = true)
@StaticMockSettings(ProxyContext.class)
-class PrometheusPluginLifecycleServiceTest {
+final class PrometheusPluginLifecycleServiceIT {
private final PrometheusPluginLifecycleService pluginLifecycleService =
new PrometheusPluginLifecycleService();
diff --git a/infra/common/src/test/resources/logback-test.xml
b/infra/common/src/test/resources/logback-test.xml
index 88bbe7f0751..239bae76a41 100644
--- a/infra/common/src/test/resources/logback-test.xml
+++ b/infra/common/src/test/resources/logback-test.xml
@@ -23,7 +23,7 @@
<pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread]
%logger{36} - %msg%n</pattern>
</encoder>
</appender>
- <logger name="org.apache.shardingsphere" level="warn" additivity="true">
+ <logger name="org.apache.shardingsphere" level="warn" additivity="false">
<appender-ref ref="console" />
</logger>
<root>
diff --git
a/jdbc/src/test/java/org/apache/shardingsphere/driver/ShardingSphereDistSQLTest.java
b/jdbc/src/test/java/org/apache/shardingsphere/driver/ShardingSphereDistSQLIT.java
similarity index 99%
rename from
jdbc/src/test/java/org/apache/shardingsphere/driver/ShardingSphereDistSQLTest.java
rename to
jdbc/src/test/java/org/apache/shardingsphere/driver/ShardingSphereDistSQLIT.java
index 051f5d05b7d..69875e2d09a 100644
---
a/jdbc/src/test/java/org/apache/shardingsphere/driver/ShardingSphereDistSQLTest.java
+++
b/jdbc/src/test/java/org/apache/shardingsphere/driver/ShardingSphereDistSQLIT.java
@@ -43,7 +43,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-class ShardingSphereDistSQLTest {
+final class ShardingSphereDistSQLIT {
private static final String URL =
"jdbc:shardingsphere:classpath:config/driver/driver-fixture-h2-mysql.yaml";
diff --git
a/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/sqlbuilder/PipelineInventoryCalculateSQLBuilderIT.java
b/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/sqlbuilder/PipelineInventoryCalculateSQLBuilderTest.java
similarity index 97%
rename from
kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/sqlbuilder/PipelineInventoryCalculateSQLBuilderIT.java
rename to
kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/sqlbuilder/PipelineInventoryCalculateSQLBuilderTest.java
index cb6e476dd34..a7a1debf718 100644
---
a/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/sqlbuilder/PipelineInventoryCalculateSQLBuilderIT.java
+++
b/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/sqlbuilder/PipelineInventoryCalculateSQLBuilderTest.java
@@ -30,7 +30,7 @@ import java.util.Collections;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
-final class PipelineInventoryCalculateSQLBuilderIT {
+class PipelineInventoryCalculateSQLBuilderTest {
private final PipelineInventoryCalculateSQLBuilder sqlBuilder =
new
PipelineInventoryCalculateSQLBuilder(TypedSPILoader.getService(DatabaseType.class,
"PostgreSQL"));
diff --git
a/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/sqlbuilder/PipelinePrepareSQLBuilderIT.java
b/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/sqlbuilder/PipelinePrepareSQLBuilderTest.java
similarity index 98%
rename from
kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/sqlbuilder/PipelinePrepareSQLBuilderIT.java
rename to
kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/sqlbuilder/PipelinePrepareSQLBuilderTest.java
index 86f31fad54a..f8c343d33af 100644
---
a/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/sqlbuilder/PipelinePrepareSQLBuilderIT.java
+++
b/kernel/data-pipeline/dialect/postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/sqlbuilder/PipelinePrepareSQLBuilderTest.java
@@ -29,7 +29,7 @@ import java.util.Optional;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
-final class PipelinePrepareSQLBuilderIT {
+class PipelinePrepareSQLBuilderTest {
private final PipelinePrepareSQLBuilder sqlBuilder = new
PipelinePrepareSQLBuilder(TypedSPILoader.getService(DatabaseType.class,
"PostgreSQL"),
new
DatabaseIdentifierContext(IdentifierCasePolicyResolver.resolveProtocol(TypedSPILoader.getService(DatabaseType.class,
"PostgreSQL"))));
diff --git
a/kernel/time-service/type/database/src/test/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimestampServiceTest.java
b/kernel/time-service/type/database/src/test/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimestampServiceIT.java
similarity index 56%
copy from
kernel/time-service/type/database/src/test/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimestampServiceTest.java
copy to
kernel/time-service/type/database/src/test/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimestampServiceIT.java
index 1e25fe5b19d..6f255e24118 100644
---
a/kernel/time-service/type/database/src/test/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimestampServiceTest.java
+++
b/kernel/time-service/type/database/src/test/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimestampServiceIT.java
@@ -17,52 +17,32 @@
package org.apache.shardingsphere.timeservice.type.database;
+import com.zaxxer.hikari.HikariDataSource;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.infra.util.props.PropertiesBuilder;
import org.apache.shardingsphere.infra.util.props.PropertiesBuilder.Property;
-import org.apache.shardingsphere.test.infra.fixture.jdbc.MockedDataSource;
import org.apache.shardingsphere.timeservice.spi.TimestampService;
-import
org.apache.shardingsphere.timeservice.type.database.exception.DatetimeLoadingException;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.internal.configuration.plugins.Plugins;
-import java.sql.Connection;
-import java.sql.SQLException;
import java.util.Properties;
-import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-class DatabaseTimestampServiceTest {
+final class DatabaseTimestampServiceIT {
- private TimestampService timestampService;
-
- @BeforeEach
- void setUp() {
+ @Test
+ void assertGetTimestamp() throws ReflectiveOperationException {
Properties props = PropertiesBuilder.build(
new Property("dataSourceClassName",
"com.zaxxer.hikari.HikariDataSource"),
new Property("jdbcUrl",
"jdbc:h2:mem:foo_db;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL"),
new Property("username", "sa"),
new Property("password", ""),
new Property("maximumPoolSize", "1"));
- timestampService = TypedSPILoader.getService(TimestampService.class,
"Database", props);
- }
-
- @Test
- void assertGetTimestamp() {
- long currentTime = System.currentTimeMillis();
- assertTrue(timestampService.getTimestamp().getTime() >= currentTime);
- }
-
- @Test
- void assertGetTimestampFailed() throws ReflectiveOperationException,
SQLException {
- Connection connection = mock(Connection.class);
- when(connection.prepareStatement(any())).thenThrow(new
SQLException(""));
-
Plugins.getMemberAccessor().set(DatabaseTimestampService.class.getDeclaredField("dataSource"),
timestampService, new MockedDataSource(connection));
- assertThrows(DatetimeLoadingException.class, () ->
timestampService.getTimestamp().getTime());
+ TimestampService timestampService =
TypedSPILoader.getService(TimestampService.class, "Database", props);
+ try (HikariDataSource dataSource = (HikariDataSource)
Plugins.getMemberAccessor().get(DatabaseTimestampService.class.getDeclaredField("dataSource"),
timestampService)) {
+ long currentTime = System.currentTimeMillis();
+ assertTrue(timestampService.getTimestamp().getTime() >=
currentTime);
+ }
}
}
diff --git
a/kernel/time-service/type/database/src/test/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimestampServiceTest.java
b/kernel/time-service/type/database/src/test/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimestampServiceTest.java
index 1e25fe5b19d..bd6a35c1020 100644
---
a/kernel/time-service/type/database/src/test/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimestampServiceTest.java
+++
b/kernel/time-service/type/database/src/test/java/org/apache/shardingsphere/timeservice/type/database/DatabaseTimestampServiceTest.java
@@ -32,7 +32,6 @@ import java.sql.SQLException;
import java.util.Properties;
import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -43,21 +42,10 @@ class DatabaseTimestampServiceTest {
@BeforeEach
void setUp() {
- Properties props = PropertiesBuilder.build(
- new Property("dataSourceClassName",
"com.zaxxer.hikari.HikariDataSource"),
- new Property("jdbcUrl",
"jdbc:h2:mem:foo_db;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL"),
- new Property("username", "sa"),
- new Property("password", ""),
- new Property("maximumPoolSize", "1"));
+ Properties props = PropertiesBuilder.build(new
Property("dataSourceClassName", MockedDataSource.class.getName()), new
Property("url", "jdbc:h2:mem:foo_db"));
timestampService = TypedSPILoader.getService(TimestampService.class,
"Database", props);
}
- @Test
- void assertGetTimestamp() {
- long currentTime = System.currentTimeMillis();
- assertTrue(timestampService.getTimestamp().getTime() >= currentTime);
- }
-
@Test
void assertGetTimestampFailed() throws ReflectiveOperationException,
SQLException {
Connection connection = mock(Connection.class);
diff --git a/test/e2e/driver/pom.xml b/test/e2e/driver/pom.xml
index a7dc7260cdf..8e2dcda8eab 100644
--- a/test/e2e/driver/pom.xml
+++ b/test/e2e/driver/pom.xml
@@ -143,4 +143,23 @@
<artifactId>curator-test</artifactId>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/cases/base/BaseTransactionTestCase.java
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/cases/base/BaseTransactionTestCase.java
index 8e5f10879a6..2eb78530abc 100644
---
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/cases/base/BaseTransactionTestCase.java
+++
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/operation/transaction/cases/base/BaseTransactionTestCase.java
@@ -75,19 +75,19 @@ public abstract class BaseTransactionTestCase {
}
protected static void executeWithLog(final Connection connection, final
String sql) throws SQLException {
- log.info("Connection execute: {}.", sql);
+ log.debug("Connection execute: {}.", sql);
connection.createStatement().execute(sql);
}
protected static int executeUpdateWithLog(final Connection connection,
final String sql) throws SQLException {
- log.info("Connection execute update: {}.", sql);
+ log.debug("Connection execute update: {}.", sql);
try (Statement statement = connection.createStatement()) {
return statement.executeUpdate(sql);
}
}
protected static ResultSet executeQueryWithLog(final Connection
connection, final String sql) throws SQLException {
- log.info("Connection execute query: {}.", sql);
+ log.debug("Connection execute query: {}.", sql);
return connection.createStatement().executeQuery(sql);
}
@@ -106,7 +106,7 @@ public abstract class BaseTransactionTestCase {
protected void executeSqlListWithLog(final Connection connection, final
String... sqlList) throws SQLException {
for (String each : sqlList) {
- log.info("Connection execute: {}.", each);
+ log.debug("Connection execute: {}.", each);
connection.createStatement().execute(each);
}
}
diff --git a/test/native/pom.xml b/test/native/pom.xml
index 2a318bf79ca..2e505b89132 100644
--- a/test/native/pom.xml
+++ b/test/native/pom.xml
@@ -150,6 +150,20 @@
</dependencies>
<build>
<plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>