diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/database/DatabaseTypeEngine.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/database/DatabaseTypeEngine.java index ca00d065be931d..15ebbdf3ce7d93 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/database/DatabaseTypeEngine.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/database/DatabaseTypeEngine.java @@ -19,15 +19,14 @@ import lombok.AccessLevel; import lombok.NoArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.apache.shardingsphere.infra.config.database.DatabaseConfiguration; import org.apache.shardingsphere.infra.config.props.ConfigurationProperties; import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey; import org.apache.shardingsphere.infra.database.core.type.DatabaseType; import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeFactory; -import org.apache.shardingsphere.infra.state.datasource.DataSourceStateManager; import org.apache.shardingsphere.infra.exception.core.external.sql.type.wrapper.SQLWrapperException; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; +import org.apache.shardingsphere.infra.state.datasource.DataSourceStateManager; import javax.sql.DataSource; import java.sql.Connection; @@ -42,7 +41,6 @@ * Database type engine. */ @NoArgsConstructor(access = AccessLevel.PRIVATE) -@Slf4j public final class DatabaseTypeEngine { private static final String DEFAULT_DATABASE_TYPE = "MySQL"; @@ -112,7 +110,6 @@ public static DatabaseType getStorageType(final Collection dataSourc private static DatabaseType getStorageType(final DataSource dataSource) { try (Connection connection = dataSource.getConnection()) { - log.error("=========URL=======:" + connection.getMetaData().getURL()); return DatabaseTypeFactory.get(connection.getMetaData().getURL()); } catch (final SQLException ex) { throw new SQLWrapperException(ex); diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/unit/StorageUnit.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/unit/StorageUnit.java index 36cb3b5811dc62..fd59f0d651c7e0 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/unit/StorageUnit.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/resource/unit/StorageUnit.java @@ -18,7 +18,6 @@ package org.apache.shardingsphere.infra.metadata.database.resource.unit; import lombok.Getter; -import lombok.extern.slf4j.Slf4j; import org.apache.shardingsphere.infra.database.DatabaseTypeEngine; import org.apache.shardingsphere.infra.database.core.connector.ConnectionProperties; import org.apache.shardingsphere.infra.database.core.connector.ConnectionPropertiesParser; @@ -38,7 +37,6 @@ * Storage unit. */ @Getter -@Slf4j public final class StorageUnit { private final DataSource dataSource; @@ -56,9 +54,7 @@ public StorageUnit(final String databaseName, final DataSource dataSource, final this.dataSourcePoolProperties = dataSourcePoolProperties; this.storageNode = storageNode; boolean isDataSourceEnabled = !DataSourceStateManager.getInstance().getEnabledDataSources(databaseName, Collections.singletonMap(storageNode.getName().getName(), dataSource)).isEmpty(); - log.error("========isDataSourceEnabled======" + isDataSourceEnabled); storageType = createStorageType(isDataSourceEnabled); - log.error("========storageType======" + storageType); connectionProperties = createConnectionProperties(isDataSourceEnabled); } diff --git a/proxy/backend/core/pom.xml b/proxy/backend/core/pom.xml index 1f2ae164d00b03..6f208a63187b92 100644 --- a/proxy/backend/core/pom.xml +++ b/proxy/backend/core/pom.xml @@ -246,9 +246,5 @@ org.awaitility awaitility - - mysql - mysql-connector-java - diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationUpdaterTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationUpdaterTest.java index 34a2f386e3cde9..2054eda0498820 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationUpdaterTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationUpdaterTest.java @@ -35,8 +35,10 @@ import org.apache.shardingsphere.mode.manager.ContextManager; import org.apache.shardingsphere.proxy.backend.context.ProxyContext; import org.apache.shardingsphere.proxy.backend.util.YamlDatabaseConfigurationImportExecutor; +import org.apache.shardingsphere.test.fixture.jdbc.MockedDriver; import org.apache.shardingsphere.test.mock.AutoMockExtension; import org.apache.shardingsphere.test.mock.StaticMockSettings; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.internal.configuration.plugins.Plugins; @@ -59,6 +61,11 @@ class ImportDatabaseConfigurationUpdaterTest { private ImportDatabaseConfigurationUpdater importDatabaseConfigUpdater; + @BeforeAll + static void setUp() throws ClassNotFoundException { + Class.forName(MockedDriver.class.getName()); + } + @Test void assertImportDatabaseExecutorForSharding() throws SQLException { assertExecute("sharding_db", "/conf/import/config-sharding.yaml"); diff --git a/proxy/backend/core/src/test/resources/conf/import/config-duplicated-logic-table.yaml b/proxy/backend/core/src/test/resources/conf/import/config-duplicated-logic-table.yaml index e1b64b99b38ef3..446c64bc569af6 100644 --- a/proxy/backend/core/src/test/resources/conf/import/config-duplicated-logic-table.yaml +++ b/proxy/backend/core/src/test/resources/conf/import/config-duplicated-logic-table.yaml @@ -19,7 +19,7 @@ databaseName: sharding_db dataSources: ds_0: - url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false + url: jdbc:mock://127.0.0.1/demo_ds_0 username: root password: connectionTimeoutMilliseconds: 30000 @@ -28,7 +28,7 @@ dataSources: maxPoolSize: 50 minPoolSize: 1 ds_1: - url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false + url: jdbc:mock://127.0.0.1/demo_ds_1 username: root password: connectionTimeoutMilliseconds: 30000 diff --git a/proxy/backend/core/src/test/resources/conf/import/config-empty-database-name.yaml b/proxy/backend/core/src/test/resources/conf/import/config-empty-database-name.yaml index 90fe05ebcf327e..c48a6296b3da36 100644 --- a/proxy/backend/core/src/test/resources/conf/import/config-empty-database-name.yaml +++ b/proxy/backend/core/src/test/resources/conf/import/config-empty-database-name.yaml @@ -17,7 +17,7 @@ dataSources: ds_0: - url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false + url: jdbc:mock://127.0.0.1/demo_ds_0 username: root password: connectionTimeoutMilliseconds: 30000 @@ -26,7 +26,7 @@ dataSources: maxPoolSize: 50 minPoolSize: 1 ds_1: - url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false + url: jdbc:mock://127.0.0.1/demo_ds_1 username: root password: connectionTimeoutMilliseconds: 30000 diff --git a/proxy/backend/core/src/test/resources/conf/import/config-encrypt.yaml b/proxy/backend/core/src/test/resources/conf/import/config-encrypt.yaml index 167fea16568585..c6b0fdd565e1b6 100644 --- a/proxy/backend/core/src/test/resources/conf/import/config-encrypt.yaml +++ b/proxy/backend/core/src/test/resources/conf/import/config-encrypt.yaml @@ -19,7 +19,7 @@ databaseName: encrypt_db dataSources: ds_0: - url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false + url: jdbc:mock://127.0.0.1/demo_ds_0 username: root password: connectionTimeoutMilliseconds: 30000 @@ -28,7 +28,7 @@ dataSources: maxPoolSize: 50 minPoolSize: 1 ds_1: - url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false + url: jdbc:mock://127.0.0.1/demo_ds_1 username: root password: connectionTimeoutMilliseconds: 30000 diff --git a/proxy/backend/core/src/test/resources/conf/import/config-invalid-algorithm.yaml b/proxy/backend/core/src/test/resources/conf/import/config-invalid-algorithm.yaml index 18f7c5f0581206..887b2d93a6ae61 100644 --- a/proxy/backend/core/src/test/resources/conf/import/config-invalid-algorithm.yaml +++ b/proxy/backend/core/src/test/resources/conf/import/config-invalid-algorithm.yaml @@ -19,7 +19,7 @@ databaseName: sharding_db dataSources: ds_0: - url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false + url: jdbc:mock://127.0.0.1/demo_ds_0 username: root password: connectionTimeoutMilliseconds: 30000 @@ -28,7 +28,7 @@ dataSources: maxPoolSize: 50 minPoolSize: 1 ds_1: - url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false + url: jdbc:mock://127.0.0.1/demo_ds_1 username: root password: connectionTimeoutMilliseconds: 30000 diff --git a/proxy/backend/core/src/test/resources/conf/import/config-mask.yaml b/proxy/backend/core/src/test/resources/conf/import/config-mask.yaml index 3c9986f6712ec6..6479e7c954aa60 100644 --- a/proxy/backend/core/src/test/resources/conf/import/config-mask.yaml +++ b/proxy/backend/core/src/test/resources/conf/import/config-mask.yaml @@ -19,7 +19,7 @@ databaseName: mask_db dataSources: ds_0: - url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false + url: jdbc:mock://127.0.0.1/demo_ds_0 username: root password: connectionTimeoutMilliseconds: 30000 @@ -28,7 +28,7 @@ dataSources: maxPoolSize: 50 minPoolSize: 1 ds_1: - url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false + url: jdbc:mock://127.0.0.1/demo_ds_1 username: root password: connectionTimeoutMilliseconds: 30000 diff --git a/proxy/backend/core/src/test/resources/conf/import/config-readwrite-splitting.yaml b/proxy/backend/core/src/test/resources/conf/import/config-readwrite-splitting.yaml index 5d80acaff67c8b..4b09a4e1d1834b 100644 --- a/proxy/backend/core/src/test/resources/conf/import/config-readwrite-splitting.yaml +++ b/proxy/backend/core/src/test/resources/conf/import/config-readwrite-splitting.yaml @@ -19,7 +19,7 @@ databaseName: readwrite_splitting_db dataSources: write_ds: - url: jdbc:mysql://127.0.0.1:3306/demo_write_ds?serverTimezone=UTC&useSSL=false + url: jdbc:mock://127.0.0.1/demo_write_ds username: root password: connectionTimeoutMilliseconds: 30000 @@ -28,7 +28,7 @@ dataSources: maxPoolSize: 50 minPoolSize: 1 read_ds_0: - url: jdbc:mysql://127.0.0.1:3306/demo_read_ds_0?serverTimezone=UTC&useSSL=false + url: jdbc:mock://127.0.0.1/demo_read_ds_0 username: root password: connectionTimeoutMilliseconds: 30000 @@ -37,7 +37,7 @@ dataSources: maxPoolSize: 50 minPoolSize: 1 read_ds_1: - url: jdbc:mysql://127.0.0.1:3306/demo_read_ds_1?serverTimezone=UTC&useSSL=false + url: jdbc:mock://127.0.0.1/demo_read_ds_1 username: root password: connectionTimeoutMilliseconds: 30000 diff --git a/proxy/backend/core/src/test/resources/conf/import/config-shadow.yaml b/proxy/backend/core/src/test/resources/conf/import/config-shadow.yaml index 19e94dca277837..ec52ad40e70ccf 100644 --- a/proxy/backend/core/src/test/resources/conf/import/config-shadow.yaml +++ b/proxy/backend/core/src/test/resources/conf/import/config-shadow.yaml @@ -19,7 +19,7 @@ databaseName: shadow_db dataSources: ds: - url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false + url: jdbc:mock://127.0.0.1/demo_ds_0 username: root password: connectionTimeoutMilliseconds: 30000 @@ -28,7 +28,7 @@ dataSources: maxPoolSize: 50 minPoolSize: 1 shadow_ds: - url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false + url: jdbc:mock://127.0.0.1/demo_ds_1 username: root password: connectionTimeoutMilliseconds: 30000 diff --git a/proxy/backend/core/src/test/resources/conf/import/config-sharding.yaml b/proxy/backend/core/src/test/resources/conf/import/config-sharding.yaml index f195f58ce36ebd..77cb41c42d3d76 100644 --- a/proxy/backend/core/src/test/resources/conf/import/config-sharding.yaml +++ b/proxy/backend/core/src/test/resources/conf/import/config-sharding.yaml @@ -19,7 +19,7 @@ databaseName: sharding_db dataSources: ds_0: - url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false + url: jdbc:mock://127.0.0.1/demo_ds_0 username: root password: connectionTimeoutMilliseconds: 30000 @@ -28,7 +28,7 @@ dataSources: maxPoolSize: 50 minPoolSize: 1 ds_1: - url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false + url: jdbc:mock://127.0.0.1/demo_ds_1 username: root password: connectionTimeoutMilliseconds: 30000