This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 e58cf80c08e Merge test container (#32871)
e58cf80c08e is described below
commit e58cf80c08e7655ae778d3df14ee91a2ee180704
Author: Cong Hu <[email protected]>
AuthorDate: Thu Sep 19 14:13:27 2024 +0800
Merge test container (#32871)
* Merge ShardingSphereJdbcContainer.
* Merge ShardingSphereProxyContainer.
* Merge MySQLContainer.
* Merge ITContainers.
---
.../e2e/agent/engine/container/ITContainers.java | 104 ---------------------
.../e2e/agent/engine/container/MySQLContainer.java | 68 --------------
....java => ShardingSphereJdbcAgentContainer.java} | 9 +-
.../container/ShardingSphereProxyContainer.java | 94 -------------------
.../agent/engine/env/AgentE2ETestEnvironment.java | 59 +++++++++---
.../src/test/resources/env/jdbc/conf/config.yaml | 8 +-
.../engine/src/test/resources/env/mysql/init.sql | 9 +-
.../test/resources/env/prometheus/prometheus.yml | 4 +-
.../test/resources/env/proxy/conf/database-db.yaml | 8 +-
.../src/test/resources/env/proxy/conf/global.yaml | 4 +-
.../env/container/atomic/DockerITContainer.java | 2 +-
.../e2e/env/container/atomic/ITContainers.java | 9 +-
.../atomic/adapter/AdapterContainerFactory.java | 3 +-
.../adapter/impl/ShardingSphereJdbcContainer.java | 15 +--
.../cases/nested/NestedTransactionTestCase.java | 66 +++++++------
.../engine/base/TransactionContainerComposer.java | 2 +-
.../container/compose/DockerContainerComposer.java | 6 +-
.../jdbc/ShardingSphereJDBCContainer.java | 74 ---------------
.../env/jdbc/mysql/database-sharding-local.yaml | 43 ++++++++-
.../jdbc/opengauss/database-sharding-local.yaml | 43 ++++++++-
.../opengauss/database-sharding-xa-atomikos.yaml | 43 ++++++++-
.../opengauss/database-sharding-xa-narayana.yaml | 43 ++++++++-
.../jdbc/postgresql/database-sharding-local.yaml | 43 ++++++++-
.../postgresql/database-sharding-xa-atomikos.yaml | 43 ++++++++-
.../postgresql/database-sharding-xa-narayana.yaml | 43 ++++++++-
25 files changed, 383 insertions(+), 462 deletions(-)
diff --git
a/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/container/ITContainers.java
b/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/container/ITContainers.java
deleted file mode 100644
index 9e397c054ed..00000000000
---
a/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/container/ITContainers.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.test.e2e.agent.engine.container;
-
-import lombok.RequiredArgsConstructor;
-import
org.apache.shardingsphere.test.e2e.env.container.atomic.DockerITContainer;
-import org.apache.shardingsphere.test.e2e.env.container.atomic.ITContainer;
-import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.Network;
-import org.testcontainers.containers.output.Slf4jLogConsumer;
-import org.testcontainers.lifecycle.Startable;
-import org.testcontainers.shaded.org.awaitility.Awaitility;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.concurrent.TimeUnit;
-
-/**
- * IT containers.
- */
-// TODO Merge test container: merge with
org.apache.shardingsphere.test.e2e.env.container.atomic.ITContainers
-@RequiredArgsConstructor
-public final class ITContainers implements Startable {
-
- private final Network network = Network.newNetwork();
-
- private final Collection<DockerITContainer> dockerContainers = new
LinkedList<>();
-
- private volatile boolean started;
-
- /**
- * Register container.
- *
- * @param container container to be registered
- * @param <T> type of container
- * @return registered container
- */
- public <T extends ITContainer> T registerContainer(final T container) {
- DockerITContainer dockerContainer = (DockerITContainer) container;
- dockerContainer.setNetwork(network);
-
dockerContainer.setNetworkAliases(Collections.singletonList(getNetworkAlias(container)));
- String loggerName = String.join(":", dockerContainer.getName(),
dockerContainer.getName());
- dockerContainer.withLogConsumer(new
Slf4jLogConsumer(LoggerFactory.getLogger(loggerName), false));
- dockerContainers.add(dockerContainer);
- return container;
- }
-
- private <T extends ITContainer> String getNetworkAlias(final T container) {
- return String.join(".", container.getAbbreviation(), "host");
- }
-
- @Override
- public void start() {
- if (!started) {
- synchronized (this) {
- if (!started) {
- dockerContainers.stream().filter(each ->
!each.isCreated()).forEach(DockerITContainer::start);
- waitUntilReady();
- started = true;
- }
- }
- }
- }
-
- private void waitUntilReady() {
- dockerContainers.stream()
- .filter(each -> {
- try {
- return !each.isHealthy();
- // CHECKSTYLE:OFF
- } catch (final RuntimeException ex) {
- // CHECKSTYLE:ON
- return false;
- }
- })
- .forEach(each -> {
- while (!(each.isRunning() && each.isHealthy())) {
- Awaitility.await().pollDelay(500L,
TimeUnit.MILLISECONDS).until(() -> true);
- }
- });
- }
-
- @Override
- public void stop() {
- dockerContainers.forEach(Startable::close);
- network.close();
- }
-}
diff --git
a/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/container/MySQLContainer.java
b/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/container/MySQLContainer.java
deleted file mode 100644
index 09f45bd117d..00000000000
---
a/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/container/MySQLContainer.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.test.e2e.agent.engine.container;
-
-import org.apache.shardingsphere.infra.database.mysql.type.MySQLDatabaseType;
-import
org.apache.shardingsphere.test.e2e.env.container.atomic.DockerITContainer;
-import
org.apache.shardingsphere.test.e2e.env.container.wait.JdbcConnectionWaitStrategy;
-import org.apache.shardingsphere.test.e2e.env.runtime.DataSourceEnvironment;
-import org.testcontainers.containers.BindMode;
-
-import java.sql.DriverManager;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * MySQL container.
- */
-// TODO Merge test container: merge with
org.apache.shardingsphere.test.e2e.env.container.atomic.storage.impl.MySQLContainer
-public final class MySQLContainer extends DockerITContainer {
-
- private static final int EXPOSED_PORT = 3306;
-
- private static final String READY_USER = "root";
-
- private static final String READY_USER_PASSWORD = "123456";
-
- public MySQLContainer(final String image) {
- super("mysql", image);
- }
-
- @Override
- protected void configure() {
- withClasspathResourceMapping("/env/mysql/init.sql",
"/docker-entrypoint-initdb.d/init.sql", BindMode.READ_ONLY);
- withExposedPorts(EXPOSED_PORT);
- setCommand("--sql_mode=
--default-authentication-plugin=mysql_native_password");
- getContainerEnvironments().forEach(this::addEnv);
- setWaitStrategy(new JdbcConnectionWaitStrategy(
- () ->
DriverManager.getConnection(DataSourceEnvironment.getURL(new
MySQLDatabaseType(), getHost(), getFirstMappedPort()), READY_USER,
READY_USER_PASSWORD)));
- }
-
- private Map<String, String> getContainerEnvironments() {
- Map<String, String> result = new HashMap<>(3, 1F);
- result.put("LANG", "C.UTF-8");
- result.put("MYSQL_ROOT_PASSWORD", READY_USER_PASSWORD);
- result.put("MYSQL_ROOT_HOST", "%");
- return result;
- }
-
- @Override
- public String getAbbreviation() {
- return "mysql";
- }
-}
diff --git
a/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/container/ShardingSphereJdbcContainer.java
b/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/container/ShardingSphereJdbcAgentContainer.java
similarity index 86%
rename from
test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/container/ShardingSphereJdbcContainer.java
rename to
test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/container/ShardingSphereJdbcAgentContainer.java
index 914644cb9d2..9c8cadc12cd 100644
---
a/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/container/ShardingSphereJdbcContainer.java
+++
b/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/container/ShardingSphereJdbcAgentContainer.java
@@ -31,8 +31,7 @@ import java.util.function.Consumer;
/**
* ShardingSphere jdbc container.
*/
-// TODO Merge test container: merge with
org.apache.shardingsphere.test.e2e.env.container.atomic.adapter.impl.ShardingSphereJdbcContainer
-public final class ShardingSphereJdbcContainer extends DockerITContainer {
+public final class ShardingSphereJdbcAgentContainer extends DockerITContainer {
private static final String CONFIG_PATH_IN_CONTAINER =
"/opt/shardingsphere-jdbc-app/";
@@ -40,8 +39,8 @@ public final class ShardingSphereJdbcContainer extends
DockerITContainer {
private final Consumer<OutputFrame> consumer;
- public ShardingSphereJdbcContainer(final String image, final String
plugin, final Consumer<OutputFrame> consumer) {
- super("jdbc", image);
+ public ShardingSphereJdbcAgentContainer(final String image, final String
plugin, final Consumer<OutputFrame> consumer) {
+ super("jdbc-agent", image);
this.consumer = consumer;
this.plugin = plugin;
}
@@ -64,6 +63,6 @@ public final class ShardingSphereJdbcContainer extends
DockerITContainer {
@Override
public String getAbbreviation() {
- return "jdbc";
+ return "jdbc-agent";
}
}
diff --git
a/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/container/ShardingSphereProxyContainer.java
b/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/container/ShardingSphereProxyContainer.java
deleted file mode 100644
index 23b0b7028f4..00000000000
---
a/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/container/ShardingSphereProxyContainer.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.test.e2e.agent.engine.container;
-
-import com.google.common.base.Strings;
-import org.apache.shardingsphere.infra.database.mysql.type.MySQLDatabaseType;
-import
org.apache.shardingsphere.test.e2e.env.container.atomic.DockerITContainer;
-import
org.apache.shardingsphere.test.e2e.env.container.atomic.constants.ProxyContainerConstants;
-import
org.apache.shardingsphere.test.e2e.env.container.wait.JdbcConnectionWaitStrategy;
-import org.apache.shardingsphere.test.e2e.env.runtime.DataSourceEnvironment;
-import org.testcontainers.containers.BindMode;
-import org.testcontainers.containers.output.OutputFrame;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-import java.util.function.Consumer;
-
-/**
- * ShardingSphere proxy container.
- */
-// TODO Merge test container: merge with ShardingSphereProxyClusterContainer
-public final class ShardingSphereProxyContainer extends DockerITContainer {
-
- private static final int EXPOSED_PORT = 3307;
-
- private static final String DATABASE_NAME = "sharding_db";
-
- private static final String READY_USER = "root";
-
- private static final String READY_USER_PASSWORD = "root";
-
- private final String plugin;
-
- private final Consumer<OutputFrame> consumer;
-
- public ShardingSphereProxyContainer(final String image, final String
plugin, final Consumer<OutputFrame> consumer) {
- super("proxy", image);
- this.consumer = consumer;
- this.plugin = plugin;
- }
-
- @Override
- protected void configure() {
- createResourceMappingForProxy().forEach((key, value) ->
withClasspathResourceMapping(key, value, BindMode.READ_ONLY));
- Optional.ofNullable(consumer).ifPresent(optional ->
withLogConsumer(consumer));
- withExposedPorts(EXPOSED_PORT, 19090);
- setWaitStrategy(new JdbcConnectionWaitStrategy(
- () ->
DriverManager.getConnection(DataSourceEnvironment.getURL(new
MySQLDatabaseType(), getHost(), getMappedPort(EXPOSED_PORT)), READY_USER,
READY_USER_PASSWORD)));
- }
-
- private Map<String, String> createResourceMappingForProxy() {
- Map<String, String> result = new HashMap<>(3, 1F);
- result.put("/env/proxy/conf/global.yaml",
ProxyContainerConstants.CONFIG_PATH_IN_CONTAINER + "global.yaml");
- result.put("/env/proxy/conf/database-db.yaml",
ProxyContainerConstants.CONFIG_PATH_IN_CONTAINER + "database-db.yaml");
- if (!Strings.isNullOrEmpty(plugin)) {
- result.put(String.format("/env/agent/conf/%s/agent.yaml", plugin),
ProxyContainerConstants.AGENT_CONFIG_PATH_IN_CONTAINER + "agent.yaml");
- }
- return result;
- }
-
- /**
- * Get connection.
- *
- * @return connection
- * @throws SQLException SQL exception
- */
- public Connection getConnection() throws SQLException {
- return DriverManager.getConnection(DataSourceEnvironment.getURL(new
MySQLDatabaseType(), getHost(), getMappedPort(EXPOSED_PORT), DATABASE_NAME),
READY_USER, READY_USER_PASSWORD);
- }
-
- @Override
- public String getAbbreviation() {
- return "proxy";
- }
-}
diff --git
a/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/env/AgentE2ETestEnvironment.java
b/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/env/AgentE2ETestEnvironment.java
index 0ea49b1fa06..73527ba807b 100644
---
a/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/env/AgentE2ETestEnvironment.java
+++
b/test/e2e/agent/engine/src/test/java/org/apache/shardingsphere/test/e2e/agent/engine/env/AgentE2ETestEnvironment.java
@@ -17,31 +17,39 @@
package org.apache.shardingsphere.test.e2e.agent.engine.env;
+import com.google.common.base.Strings;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.apache.shardingsphere.test.e2e.agent.engine.container.ITContainers;
-import
org.apache.shardingsphere.test.e2e.agent.engine.container.MySQLContainer;
-import
org.apache.shardingsphere.test.e2e.agent.engine.container.ShardingSphereJdbcContainer;
-import
org.apache.shardingsphere.test.e2e.agent.engine.container.ShardingSphereProxyContainer;
+import
org.apache.shardingsphere.test.e2e.agent.engine.container.ShardingSphereJdbcAgentContainer;
import
org.apache.shardingsphere.test.e2e.agent.engine.container.plugin.AgentPluginContainerFactory;
import
org.apache.shardingsphere.test.e2e.agent.engine.container.plugin.AgentPluginHTTPEndpointProvider;
import
org.apache.shardingsphere.test.e2e.agent.engine.env.props.AgentE2ETestConfiguration;
import
org.apache.shardingsphere.test.e2e.agent.engine.env.props.AgentE2ETestImageConfiguration;
import
org.apache.shardingsphere.test.e2e.agent.fixture.proxy.ProxyRequestExecutor;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.DockerITContainer;
+import org.apache.shardingsphere.test.e2e.env.container.atomic.ITContainers;
+import
org.apache.shardingsphere.test.e2e.env.container.atomic.adapter.config.AdaptorContainerConfiguration;
+import
org.apache.shardingsphere.test.e2e.env.container.atomic.adapter.impl.ShardingSphereProxyClusterContainer;
+import
org.apache.shardingsphere.test.e2e.env.container.atomic.constants.ProxyContainerConstants;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.enums.AdapterType;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.governance.GovernanceContainer;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.governance.GovernanceContainerFactory;
+import
org.apache.shardingsphere.test.e2e.env.container.atomic.storage.config.StorageContainerConfiguration;
+import
org.apache.shardingsphere.test.e2e.env.container.atomic.storage.impl.MySQLContainer;
import org.testcontainers.containers.output.OutputFrame;
import org.testcontainers.shaded.org.awaitility.Awaitility;
import java.sql.SQLException;
import java.time.Duration;
import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.LinkedList;
+import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
@@ -104,35 +112,56 @@ public final class AgentE2ETestEnvironment {
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
private void createProxyEnvironment(final Optional<DockerITContainer>
agentPluginContainer) {
containers = new ITContainers();
- MySQLContainer storageContainer = new
MySQLContainer(imageConfig.getMysqlImage());
- GovernanceContainer governanceContainer =
GovernanceContainerFactory.newInstance("ZooKeeper");
- ShardingSphereProxyContainer proxyContainer = new
ShardingSphereProxyContainer(imageConfig.getProxyImage(),
testConfig.getPluginType(), testConfig.isLogEnabled() ? this::collectLogs :
null);
+ ShardingSphereProxyClusterContainer proxyContainer = new
ShardingSphereProxyClusterContainer(TypedSPILoader.getService(DatabaseType.class,
"MySQL"), getAdaptorContainerConfiguration());
+ proxyContainer.withLogConsumer(testConfig.isLogEnabled() ?
this::collectLogs : null);
+ MySQLContainer storageContainer = new
MySQLContainer(imageConfig.getMysqlImage(), getStorageContainerConfiguration());
proxyContainer.dependsOn(storageContainer);
+ containers.registerContainer(storageContainer);
+ GovernanceContainer governanceContainer =
GovernanceContainerFactory.newInstance("ZooKeeper");
proxyContainer.dependsOn(governanceContainer);
+ containers.registerContainer(governanceContainer);
agentPluginContainer.ifPresent(proxyContainer::dependsOn);
agentPluginContainer.ifPresent(optional ->
containers.registerContainer(optional));
- containers.registerContainer(storageContainer);
- containers.registerContainer(governanceContainer);
containers.registerContainer(proxyContainer);
containers.start();
try {
- proxyRequestExecutor = new
ProxyRequestExecutor(proxyContainer.getConnection());
+ proxyRequestExecutor = new
ProxyRequestExecutor(proxyContainer.getTargetDataSource(null).getConnection());
proxyRequestExecutor.start();
} catch (final SQLException ignored) {
}
}
+ private static StorageContainerConfiguration
getStorageContainerConfiguration() {
+ Map<String, String> containerEnvironments = new HashMap<>(3, 1F);
+ containerEnvironments.put("LANG", "C.UTF-8");
+ containerEnvironments.put("MYSQL_RANDOM_ROOT_PASSWORD", "yes");
+ Map<String, String> mountedResources = new HashMap<>();
+ mountedResources.put("/env/mysql/init.sql",
"/docker-entrypoint-initdb.d/init.sql");
+ return new StorageContainerConfiguration("--sql_mode=
--default-authentication-plugin=mysql_native_password", containerEnvironments,
+ mountedResources, Collections.emptyMap(),
Collections.emptyMap());
+ }
+
+ private AdaptorContainerConfiguration getAdaptorContainerConfiguration() {
+ Map<String, String> mountedResources = new HashMap<>(3, 1F);
+ mountedResources.put("/env/proxy/conf/global.yaml",
ProxyContainerConstants.CONFIG_PATH_IN_CONTAINER + "global.yaml");
+ mountedResources.put("/env/proxy/conf/database-db.yaml",
ProxyContainerConstants.CONFIG_PATH_IN_CONTAINER + "database-db.yaml");
+ if (!Strings.isNullOrEmpty(testConfig.getPluginType())) {
+
mountedResources.put(String.format("/env/agent/conf/%s/agent.yaml",
testConfig.getPluginType()),
ProxyContainerConstants.AGENT_CONFIG_PATH_IN_CONTAINER + "agent.yaml");
+ }
+ return new AdaptorContainerConfiguration("sharding_db",
Collections.emptyList(), mountedResources, imageConfig.getProxyImage(), "");
+ }
+
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
private void createJDBCEnvironment(final Optional<DockerITContainer>
agentPluginContainer) {
containers = new ITContainers();
- MySQLContainer storageContainer = new
MySQLContainer(imageConfig.getMysqlImage());
- ShardingSphereJdbcContainer jdbcContainer = new
ShardingSphereJdbcContainer(
+ MySQLContainer storageContainer = new
MySQLContainer(imageConfig.getMysqlImage(), getStorageContainerConfiguration());
+ ShardingSphereJdbcAgentContainer jdbcAgentContainer = new
ShardingSphereJdbcAgentContainer(
imageConfig.getJdbcProjectImage(), testConfig.getPluginType(),
testConfig.isLogEnabled() ? this::collectLogs : null);
- jdbcContainer.dependsOn(storageContainer);
- agentPluginContainer.ifPresent(jdbcContainer::dependsOn);
+ jdbcAgentContainer.dependsOn(storageContainer);
+ agentPluginContainer.ifPresent(jdbcAgentContainer::dependsOn);
agentPluginContainer.ifPresent(optional ->
containers.registerContainer(optional));
containers.registerContainer(storageContainer);
- containers.registerContainer(jdbcContainer);
+ containers.registerContainer(jdbcAgentContainer);
containers.start();
}
diff --git a/test/e2e/agent/engine/src/test/resources/env/jdbc/conf/config.yaml
b/test/e2e/agent/engine/src/test/resources/env/jdbc/conf/config.yaml
index 7f8d29de9b4..8a82bdf94a5 100644
--- a/test/e2e/agent/engine/src/test/resources/env/jdbc/conf/config.yaml
+++ b/test/e2e/agent/engine/src/test/resources/env/jdbc/conf/config.yaml
@@ -22,14 +22,14 @@ dataSources:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: com.mysql.cj.jdbc.Driver
jdbcUrl:
jdbc:mysql://mysql.host:3306/demo_ds_0?useSSL=false&characterEncoding=utf-8
- username: root
- password: 123456
+ username: test_user
+ password: Test@123
ds_1:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: com.mysql.cj.jdbc.Driver
jdbcUrl:
jdbc:mysql://mysql.host:3306/demo_ds_1?useSSL=false&characterEncoding=utf-8
- username: root
- password: 123456
+ username: test_user
+ password: Test@123
rules:
- !SHARDING
diff --git a/test/e2e/agent/engine/src/test/resources/env/mysql/init.sql
b/test/e2e/agent/engine/src/test/resources/env/mysql/init.sql
index d9b6593eb53..cda5ed86b92 100644
--- a/test/e2e/agent/engine/src/test/resources/env/mysql/init.sql
+++ b/test/e2e/agent/engine/src/test/resources/env/mysql/init.sql
@@ -15,10 +15,6 @@
-- limitations under the License.
--
-CREATE USER IF NOT EXISTS 'root'@'%' IDENTIFIED BY '123456';
-GRANT All PRIVILEGES ON *.* TO 'root'@'%';
-FLUSH PRIVILEGES;
-
SET character_set_database='utf8';
SET character_set_server='utf8';
@@ -33,3 +29,8 @@ CREATE TABLE demo_ds_0.t_order_1 (order_id INT NOT NULL,
user_id INT NOT NULL, s
CREATE TABLE demo_ds_1.t_order_0 (order_id INT NOT NULL, user_id INT NOT NULL,
status VARCHAR(45) NULL, PRIMARY KEY (order_id));
CREATE TABLE demo_ds_1.t_order_1 (order_id INT NOT NULL, user_id INT NOT NULL,
status VARCHAR(45) NULL, PRIMARY KEY (order_id));
+
+CREATE USER IF NOT EXISTS 'test_user'@'%' IDENTIFIED BY 'Test@123';
+GRANT ALL ON *.* TO 'test_user'@'%';
+
+CREATE USER IF NOT EXISTS 'ready_user'@'%' IDENTIFIED BY 'Ready@123';
diff --git
a/test/e2e/agent/engine/src/test/resources/env/prometheus/prometheus.yml
b/test/e2e/agent/engine/src/test/resources/env/prometheus/prometheus.yml
index edc01e4c8ce..9c6f155ac52 100644
--- a/test/e2e/agent/engine/src/test/resources/env/prometheus/prometheus.yml
+++ b/test/e2e/agent/engine/src/test/resources/env/prometheus/prometheus.yml
@@ -18,10 +18,10 @@
global:
scrape_interval: 15s
evaluation_interval: 15s
-
+
scrape_configs:
- job_name: 'shardingsphere-agent'
static_configs:
- targets:
- "proxy.host:19090"
- - "jdbc.host:19090"
+ - "jdbc-agent.host:19090"
diff --git
a/test/e2e/agent/engine/src/test/resources/env/proxy/conf/database-db.yaml
b/test/e2e/agent/engine/src/test/resources/env/proxy/conf/database-db.yaml
index 1154d06e932..e3989aa61a9 100644
--- a/test/e2e/agent/engine/src/test/resources/env/proxy/conf/database-db.yaml
+++ b/test/e2e/agent/engine/src/test/resources/env/proxy/conf/database-db.yaml
@@ -20,8 +20,8 @@ databaseName: sharding_db
dataSources:
ds_0:
url:
jdbc:mysql://mysql.host:3306/demo_ds_0?useSSL=false&characterEncoding=utf-8
- username: root
- password: 123456
+ username: test_user
+ password: Test@123
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
@@ -29,8 +29,8 @@ dataSources:
minPoolSize: 2
ds_1:
url:
jdbc:mysql://mysql.host:3306/demo_ds_1?useSSL=false&characterEncoding=utf-8
- username: root
- password: 123456
+ username: test_user
+ password: Test@123
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
diff --git
a/test/e2e/agent/engine/src/test/resources/env/proxy/conf/global.yaml
b/test/e2e/agent/engine/src/test/resources/env/proxy/conf/global.yaml
index 740c1fecbcf..416474ae59e 100644
--- a/test/e2e/agent/engine/src/test/resources/env/proxy/conf/global.yaml
+++ b/test/e2e/agent/engine/src/test/resources/env/proxy/conf/global.yaml
@@ -29,8 +29,8 @@ mode:
authority:
users:
- - user: root
- password: root
+ - user: proxy
+ password: Proxy@123
privilege:
type: ALL_PERMITTED
diff --git
a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/DockerITContainer.java
b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/DockerITContainer.java
index 36e33e94bc9..caf74c366ae 100644
---
a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/DockerITContainer.java
+++
b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/DockerITContainer.java
@@ -62,7 +62,7 @@ public abstract class DockerITContainer extends
GenericContainer<DockerITContain
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
- log.info("Failed to check container {} healthy.",
each.getName(), ex);
+ log.info("Failed to check container {} healthy.",
each.getName());
return false;
}
})
diff --git
a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/ITContainers.java
b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/ITContainers.java
index 27551124317..8ddb9f794be 100644
---
a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/ITContainers.java
+++
b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/ITContainers.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.test.e2e.env.container.atomic;
import com.google.common.base.Strings;
+import com.google.common.collect.Lists;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.governance.GovernanceContainer;
@@ -30,7 +31,9 @@ import org.testcontainers.shaded.org.awaitility.Awaitility;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
+import java.util.Objects;
import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
/**
* IT containers.
@@ -49,6 +52,10 @@ public final class ITContainers implements Startable {
private volatile boolean started;
+ public ITContainers() {
+ this.scenario = null;
+ }
+
public ITContainers(final String scenario) {
this.scenario = scenario;
}
@@ -70,7 +77,7 @@ public final class ITContainers implements Startable {
dockerContainer.setNetwork(network);
String networkAlias = getNetworkAlias(container);
dockerContainer.setNetworkAliases(Collections.singletonList(networkAlias));
- String loggerName = String.join(":", scenario,
dockerContainer.getName());
+ String loggerName = Lists.newArrayList(scenario,
dockerContainer.getName()).stream().filter(Objects::nonNull).collect(Collectors.joining(":"));
dockerContainer.withLogConsumer(new
Slf4jLogConsumer(LoggerFactory.getLogger(loggerName), false));
dockerContainers.add(dockerContainer);
}
diff --git
a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/adapter/AdapterContainerFactory.java
b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/adapter/AdapterContainerFactory.java
index c3c9cc2ac4a..b7a97f8c5c6 100644
---
a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/adapter/AdapterContainerFactory.java
+++
b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/adapter/AdapterContainerFactory.java
@@ -28,6 +28,7 @@ import
org.apache.shardingsphere.test.e2e.env.container.atomic.adapter.impl.Shar
import
org.apache.shardingsphere.test.e2e.env.container.atomic.enums.AdapterMode;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.enums.AdapterType;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.storage.StorageContainer;
+import
org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioCommonPath;
/**
* Adapter container factory.
@@ -57,7 +58,7 @@ public final class AdapterContainerFactory {
case PROXY_RANDOM:
return new
ShardingSphereMultiProxyClusterContainer(databaseType, containerConfig);
case JDBC:
- return new ShardingSphereJdbcContainer(scenario, databaseType,
storageContainer);
+ return new ShardingSphereJdbcContainer(storageContainer, new
ScenarioCommonPath(scenario).getRuleConfigurationFile(databaseType));
default:
throw new RuntimeException(String.format("Unknown adapter
`%s`.", adapter));
}
diff --git
a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/adapter/impl/ShardingSphereJdbcContainer.java
b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/adapter/impl/ShardingSphereJdbcContainer.java
index 16f4042f591..4b5fddc7e83 100644
---
a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/adapter/impl/ShardingSphereJdbcContainer.java
+++
b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/adapter/impl/ShardingSphereJdbcContainer.java
@@ -19,12 +19,10 @@ package
org.apache.shardingsphere.test.e2e.env.container.atomic.adapter.impl;
import com.zaxxer.hikari.HikariDataSource;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.DockerITContainer;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.EmbeddedITContainer;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.adapter.AdapterContainer;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.storage.StorageContainer;
-import
org.apache.shardingsphere.test.e2e.env.runtime.scenario.path.ScenarioCommonPath;
import javax.sql.DataSource;
import java.io.File;
@@ -42,17 +40,14 @@ import java.util.concurrent.atomic.AtomicReference;
*/
public final class ShardingSphereJdbcContainer implements EmbeddedITContainer,
AdapterContainer {
- private final ScenarioCommonPath scenarioCommonPath;
-
- private final DatabaseType databaseType;
-
private final StorageContainer storageContainer;
private final AtomicReference<DataSource> targetDataSourceProvider = new
AtomicReference<>();
- public ShardingSphereJdbcContainer(final String scenario, final
DatabaseType databaseType, final StorageContainer storageContainer) {
- scenarioCommonPath = new ScenarioCommonPath(scenario);
- this.databaseType = databaseType;
+ private final String configPath;
+
+ public ShardingSphereJdbcContainer(final StorageContainer
storageContainer, final String configPath) {
+ this.configPath = configPath;
this.storageContainer = storageContainer;
}
@@ -73,7 +68,7 @@ public final class ShardingSphereJdbcContainer implements
EmbeddedITContainer, A
private DataSource createTargetDataSource() {
HikariDataSource result = new HikariDataSource();
result.setDriverClassName("org.apache.shardingsphere.driver.ShardingSphereDriver");
- result.setJdbcUrl("jdbc:shardingsphere:absolutepath:" +
processFile(scenarioCommonPath.getRuleConfigurationFile(databaseType),
getLinkReplacements()));
+ result.setJdbcUrl("jdbc:shardingsphere:absolutepath:" +
processFile(configPath, getLinkReplacements()));
result.setUsername("root");
result.setPassword("Root@123");
result.setMaximumPoolSize(2);
diff --git
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/cases/nested/NestedTransactionTestCase.java
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/cases/nested/NestedTransactionTestCase.java
index c89cf9ce5dd..80ea15f411d 100644
---
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/cases/nested/NestedTransactionTestCase.java
+++
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/cases/nested/NestedTransactionTestCase.java
@@ -49,95 +49,93 @@ public final class NestedTransactionTestCase extends
BaseTransactionTestCase {
}
private void assertOuterCommitAndInnerRollback() throws SQLException {
- try (
- ShardingSphereConnection connection =
(ShardingSphereConnection) getDataSource().getConnection();
- Connection queryConnection = getDataSource().getConnection()) {
-
assertFalse(connection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(connection.getAutoCommit()));
+ try (Connection connection = getDataSource().getConnection()) {
+ ShardingSphereConnection shardingSphereConnection =
connection.unwrap(ShardingSphereConnection.class);
+
assertFalse(shardingSphereConnection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(shardingSphereConnection.getAutoCommit()));
connection.setAutoCommit(false);
executeWithLog(connection, "INSERT INTO account (id, balance,
transaction_id) VALUES (1, 1, 1), (2, 2, 2)");
-
assertTrue(connection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(connection.getAutoCommit()));
+
assertTrue(shardingSphereConnection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(shardingSphereConnection.getAutoCommit()));
requiresNewTransactionRollback();
executeWithLog(connection, "INSERT INTO account (id, balance,
transaction_id) VALUES (7, 7, 7), (8, 8, 8)");
-
assertTrue(connection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(connection.getAutoCommit()));
+
assertTrue(shardingSphereConnection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(shardingSphereConnection.getAutoCommit()));
connection.commit();
- assertAccountBalances(queryConnection, 1, 2, 3, 4, 7, 8);
+ assertAccountBalances(connection, 1, 2, 3, 4, 7, 8);
connection.setAutoCommit(true);
executeWithLog(connection, "DELETE FROM ACCOUNT");
}
}
private void assertOuterRollbackAndInnerRollback() throws SQLException {
- try (
- ShardingSphereConnection connection =
(ShardingSphereConnection) getDataSource().getConnection();
- Connection queryConnection = getDataSource().getConnection()) {
-
assertFalse(connection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(connection.getAutoCommit()));
+ try (Connection connection = getDataSource().getConnection()) {
+ ShardingSphereConnection shardingSphereConnection =
connection.unwrap(ShardingSphereConnection.class);
+
assertFalse(shardingSphereConnection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(shardingSphereConnection.getAutoCommit()));
connection.setAutoCommit(false);
executeWithLog(connection, "INSERT INTO account (id, balance,
transaction_id) VALUES (1, 1, 1), (2, 2, 2)");
-
assertTrue(connection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(connection.getAutoCommit()));
+
assertTrue(shardingSphereConnection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(shardingSphereConnection.getAutoCommit()));
requiresNewTransactionRollback();
executeWithLog(connection, "INSERT INTO account (id, balance,
transaction_id) VALUES (7, 7, 7), (8, 8, 8)");
-
assertTrue(connection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(connection.getAutoCommit()));
+
assertTrue(shardingSphereConnection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(shardingSphereConnection.getAutoCommit()));
connection.rollback();
- assertAccountBalances(queryConnection, 3, 4);
+ assertAccountBalances(connection, 3, 4);
connection.setAutoCommit(true);
executeWithLog(connection, "DELETE FROM ACCOUNT");
}
}
private void assertOuterCommitAndInnerCommit() throws SQLException {
- try (
- ShardingSphereConnection connection =
(ShardingSphereConnection) getDataSource().getConnection();
- Connection queryConnection = getDataSource().getConnection()) {
-
assertFalse(connection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(connection.getAutoCommit()));
+ try (Connection connection = getDataSource().getConnection()) {
+ ShardingSphereConnection shardingSphereConnection =
connection.unwrap(ShardingSphereConnection.class);
+
assertFalse(shardingSphereConnection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(shardingSphereConnection.getAutoCommit()));
connection.setAutoCommit(false);
executeWithLog(connection, "INSERT INTO account (id, balance,
transaction_id) VALUES (1, 1, 1), (2, 2, 2)");
-
assertTrue(connection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(connection.getAutoCommit()));
+
assertTrue(shardingSphereConnection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(shardingSphereConnection.getAutoCommit()));
requiresNewTransactionCommit();
executeWithLog(connection, "INSERT INTO account (id, balance,
transaction_id) VALUES (7, 7, 7), (8, 8, 8)");
-
assertTrue(connection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(connection.getAutoCommit()));
+
assertTrue(shardingSphereConnection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(shardingSphereConnection.getAutoCommit()));
connection.commit();
- assertAccountBalances(queryConnection, 1, 2, 3, 4, 5, 6, 7, 8);
+ assertAccountBalances(connection, 1, 2, 3, 4, 5, 6, 7, 8);
connection.setAutoCommit(true);
executeWithLog(connection, "DELETE FROM ACCOUNT");
}
}
private void assertOuterRollbackAndInnerCommit() throws SQLException {
- try (
- ShardingSphereConnection connection =
(ShardingSphereConnection) getDataSource().getConnection();
- Connection queryConnection = getDataSource().getConnection()) {
-
assertFalse(connection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(connection.getAutoCommit()));
+ try (Connection connection = getDataSource().getConnection()) {
+ ShardingSphereConnection shardingSphereConnection =
connection.unwrap(ShardingSphereConnection.class);
+
assertFalse(shardingSphereConnection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(shardingSphereConnection.getAutoCommit()));
connection.setAutoCommit(false);
executeWithLog(connection, "INSERT INTO account (id, balance,
transaction_id) VALUES (1, 1, 1), (2, 2, 2)");
-
assertTrue(connection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(connection.getAutoCommit()));
+
assertTrue(shardingSphereConnection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(shardingSphereConnection.getAutoCommit()));
requiresNewTransactionCommit();
executeWithLog(connection, "INSERT INTO account (id, balance,
transaction_id) VALUES (7, 7, 7), (8, 8, 8)");
-
assertTrue(connection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(connection.getAutoCommit()));
+
assertTrue(shardingSphereConnection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(shardingSphereConnection.getAutoCommit()));
connection.rollback();
- assertAccountBalances(queryConnection, 3, 4, 5, 6);
+ assertAccountBalances(connection, 3, 4, 5, 6);
connection.setAutoCommit(true);
executeWithLog(connection, "DELETE FROM ACCOUNT");
}
}
private void requiresNewTransactionRollback() throws SQLException {
- try (ShardingSphereConnection connection = (ShardingSphereConnection)
getDataSource().getConnection()) {
-
assertFalse(connection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(connection.getAutoCommit()));
+ try (Connection connection = getDataSource().getConnection()) {
+ ShardingSphereConnection shardingSphereConnection =
connection.unwrap(ShardingSphereConnection.class);
+
assertFalse(shardingSphereConnection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(shardingSphereConnection.getAutoCommit()));
executeWithLog(connection, "INSERT INTO account (id, balance,
transaction_id) VALUES (3, 3, 3), (4, 4, 4)");
connection.setAutoCommit(false);
executeWithLog(connection, "INSERT INTO account (id, balance,
transaction_id) VALUES (5, 5, 5), (6, 6, 6)");
-
assertTrue(connection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(connection.getAutoCommit()));
+
assertTrue(shardingSphereConnection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(shardingSphereConnection.getAutoCommit()));
connection.rollback();
}
}
private void requiresNewTransactionCommit() throws SQLException {
- try (ShardingSphereConnection connection = (ShardingSphereConnection)
getDataSource().getConnection()) {
-
assertFalse(connection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(connection.getAutoCommit()));
+ try (Connection connection = getDataSource().getConnection()) {
+ ShardingSphereConnection shardingSphereConnection =
connection.unwrap(ShardingSphereConnection.class);
+
assertFalse(shardingSphereConnection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(shardingSphereConnection.getAutoCommit()));
executeWithLog(connection, "INSERT INTO account (id, balance,
transaction_id) VALUES (3, 3, 3), (4, 4, 4)");
connection.setAutoCommit(false);
executeWithLog(connection, "INSERT INTO account (id, balance,
transaction_id) VALUES (5, 5, 5), (6, 6, 6)");
-
assertTrue(connection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(connection.getAutoCommit()));
+
assertTrue(shardingSphereConnection.getDatabaseConnectionManager().getConnectionTransaction().isHoldTransaction(shardingSphereConnection.getAutoCommit()));
connection.commit();
}
}
diff --git
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/engine/base/TransactionContainerComposer.java
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/engine/base/TransactionContainerComposer.java
index acec2e09a8c..85c13efa856 100644
---
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/engine/base/TransactionContainerComposer.java
+++
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/engine/base/TransactionContainerComposer.java
@@ -66,7 +66,7 @@ public final class TransactionContainerComposer implements
AutoCloseable {
private DataSource createJdbcDataSource() {
DockerContainerComposer dockerContainerComposer =
(DockerContainerComposer) containerComposer;
- return
dockerContainerComposer.getJdbcContainer().getTargetDataSource();
+ return
dockerContainerComposer.getJdbcContainer().getTargetDataSource(null);
}
@Override
diff --git
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/compose/DockerContainerComposer.java
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/compose/DockerContainerComposer.java
index 9037023ebec..3d3a84aa29f 100644
---
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/compose/DockerContainerComposer.java
+++
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/compose/DockerContainerComposer.java
@@ -21,6 +21,7 @@ import com.google.common.base.Strings;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
+import
org.apache.shardingsphere.test.e2e.env.container.atomic.adapter.impl.ShardingSphereJdbcContainer;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.adapter.impl.ShardingSphereProxyClusterContainer;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.enums.AdapterType;
import
org.apache.shardingsphere.test.e2e.env.container.atomic.governance.GovernanceContainer;
@@ -29,7 +30,6 @@ import
org.apache.shardingsphere.test.e2e.env.container.atomic.storage.DockerSto
import
org.apache.shardingsphere.test.e2e.env.container.atomic.storage.StorageContainerFactory;
import
org.apache.shardingsphere.test.e2e.transaction.framework.container.config.StorageContainerConfigurationFactory;
import
org.apache.shardingsphere.test.e2e.transaction.framework.container.config.proxy.ProxyClusterContainerConfigurationFactory;
-import
org.apache.shardingsphere.test.e2e.transaction.framework.container.jdbc.ShardingSphereJDBCContainer;
import
org.apache.shardingsphere.test.e2e.transaction.framework.param.TransactionTestParameter;
import java.net.URL;
@@ -48,7 +48,7 @@ public final class DockerContainerComposer extends
BaseContainerComposer {
private final ShardingSphereProxyClusterContainer proxyContainer;
- private final ShardingSphereJDBCContainer jdbcContainer;
+ private final ShardingSphereJdbcContainer jdbcContainer;
private final DockerStorageContainer storageContainer;
@@ -66,7 +66,7 @@ public final class DockerContainerComposer extends
BaseContainerComposer {
getContainers().registerContainer(proxyContainer);
} else {
proxyContainer = null;
- ShardingSphereJDBCContainer jdbcContainer = new
ShardingSphereJDBCContainer(storageContainer,
+ ShardingSphereJdbcContainer jdbcContainer = new
ShardingSphereJdbcContainer(storageContainer,
Objects.requireNonNull(getShardingSphereConfigResource(testParam)).getFile());
this.jdbcContainer =
getContainers().registerContainer(jdbcContainer);
}
diff --git
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/jdbc/ShardingSphereJDBCContainer.java
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/jdbc/ShardingSphereJDBCContainer.java
deleted file mode 100644
index 80d8dd4af3e..00000000000
---
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/framework/container/jdbc/ShardingSphereJDBCContainer.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package
org.apache.shardingsphere.test.e2e.transaction.framework.container.jdbc;
-
-import
org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
-import
org.apache.shardingsphere.test.e2e.env.container.atomic.EmbeddedITContainer;
-import
org.apache.shardingsphere.test.e2e.env.container.atomic.storage.DockerStorageContainer;
-
-import javax.sql.DataSource;
-import java.io.File;
-import java.io.IOException;
-import java.sql.SQLException;
-import java.util.concurrent.atomic.AtomicReference;
-
-/**
- * ShardingSphere JDBC container.
- */
-// TODO Merge test container: merge with
org.apache.shardingsphere.test.e2e.env.container.atomic.adapter.impl.ShardingSphereJdbcContainer
-public final class ShardingSphereJDBCContainer implements EmbeddedITContainer {
-
- private final DockerStorageContainer databaseContainer;
-
- private final String ruleConfigPath;
-
- private final AtomicReference<DataSource> targetDataSourceProvider = new
AtomicReference<>();
-
- public ShardingSphereJDBCContainer(final DockerStorageContainer
databaseContainer, final String ruleConfigPath) {
- this.databaseContainer = databaseContainer;
- this.ruleConfigPath = ruleConfigPath;
- }
-
- @Override
- public void start() {
- }
-
- /**
- * Get target data source.
- *
- * @return target data source
- * @throws RuntimeException runtime exception
- */
- public DataSource getTargetDataSource() {
- DataSource dataSource = targetDataSourceProvider.get();
- if (null == dataSource) {
- try {
- targetDataSourceProvider.set(
-
YamlShardingSphereDataSourceFactory.createDataSource(databaseContainer.getActualDataSourceMap(),
new File(ruleConfigPath)));
- } catch (final SQLException | IOException ex) {
- throw new RuntimeException(ex);
- }
- }
- return targetDataSourceProvider.get();
- }
-
- @Override
- public String getAbbreviation() {
- return "jdbc";
- }
-}
diff --git
a/test/e2e/operation/transaction/src/test/resources/env/jdbc/mysql/database-sharding-local.yaml
b/test/e2e/operation/transaction/src/test/resources/env/jdbc/mysql/database-sharding-local.yaml
index fd3adc10fef..ce05800c2ef 100644
---
a/test/e2e/operation/transaction/src/test/resources/env/jdbc/mysql/database-sharding-local.yaml
+++
b/test/e2e/operation/transaction/src/test/resources/env/jdbc/mysql/database-sharding-local.yaml
@@ -16,12 +16,45 @@
#
######################################################################################################
-#
+#
# If you want to configure governance, authorization and proxy properties,
please refer to this file.
-#
+#
######################################################################################################
databaseName: sharding_db
+
+dataSources:
+ ds_0:
+ url:
jdbc:mysql://mysql.default.host:3306/ds_0?useSSL=true&requireSSL=true&enabledTLSProtocols=TLSv1.2,TLSv1.3&verifyServerCertificate=false&useServerPrepStmts=true&useLocalSessionState=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true&allowMultiQueries=true&rewriteBatchedStatements=true
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+ ds_1:
+ url:
jdbc:mysql://mysql.default.host:3306/ds_1?useSSL=true&requireSSL=true&enabledTLSProtocols=TLSv1.2,TLSv1.3&verifyServerCertificate=false&useServerPrepStmts=true&useLocalSessionState=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true&allowMultiQueries=true&rewriteBatchedStatements=true
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+ ds_2:
+ url:
jdbc:mysql://mysql.default.host:3306/ds_2?useSSL=true&requireSSL=true&enabledTLSProtocols=TLSv1.2,TLSv1.3&verifyServerCertificate=false&useServerPrepStmts=true&useLocalSessionState=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true&allowMultiQueries=true&rewriteBatchedStatements=true
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+
rules:
- !SHARDING
tables:
@@ -64,7 +97,7 @@ rules:
shardingAlgorithmName: database_inline
defaultTableStrategy:
none:
-
+
shardingAlgorithms:
database_inline:
type: INLINE
@@ -86,11 +119,11 @@ rules:
type: INLINE
props:
algorithm-expression:
account_${Math.floorMod(Math.floorDiv(id.longValue(), 2L), 2L)}
-
+
keyGenerators:
snowflake:
type: SNOWFLAKE
-
+
- !BROADCAST
tables:
- t_address
diff --git
a/test/e2e/operation/transaction/src/test/resources/env/jdbc/opengauss/database-sharding-local.yaml
b/test/e2e/operation/transaction/src/test/resources/env/jdbc/opengauss/database-sharding-local.yaml
index fd3adc10fef..3aa13047d1f 100644
---
a/test/e2e/operation/transaction/src/test/resources/env/jdbc/opengauss/database-sharding-local.yaml
+++
b/test/e2e/operation/transaction/src/test/resources/env/jdbc/opengauss/database-sharding-local.yaml
@@ -16,12 +16,45 @@
#
######################################################################################################
-#
+#
# If you want to configure governance, authorization and proxy properties,
please refer to this file.
-#
+#
######################################################################################################
databaseName: sharding_db
+
+dataSources:
+ ds_0:
+ url: jdbc:opengauss://opengauss.default.host:5432/ds_0?batchMode=OFF
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+ ds_1:
+ url: jdbc:opengauss://opengauss.default.host:5432/ds_1?batchMode=OFF
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+ ds_2:
+ url: jdbc:opengauss://opengauss.default.host:5432/ds_2?batchMode=OFF
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+
rules:
- !SHARDING
tables:
@@ -64,7 +97,7 @@ rules:
shardingAlgorithmName: database_inline
defaultTableStrategy:
none:
-
+
shardingAlgorithms:
database_inline:
type: INLINE
@@ -86,11 +119,11 @@ rules:
type: INLINE
props:
algorithm-expression:
account_${Math.floorMod(Math.floorDiv(id.longValue(), 2L), 2L)}
-
+
keyGenerators:
snowflake:
type: SNOWFLAKE
-
+
- !BROADCAST
tables:
- t_address
diff --git
a/test/e2e/operation/transaction/src/test/resources/env/jdbc/opengauss/database-sharding-xa-atomikos.yaml
b/test/e2e/operation/transaction/src/test/resources/env/jdbc/opengauss/database-sharding-xa-atomikos.yaml
index e653140e92f..c796a841549 100644
---
a/test/e2e/operation/transaction/src/test/resources/env/jdbc/opengauss/database-sharding-xa-atomikos.yaml
+++
b/test/e2e/operation/transaction/src/test/resources/env/jdbc/opengauss/database-sharding-xa-atomikos.yaml
@@ -16,12 +16,45 @@
#
######################################################################################################
-#
+#
# If you want to configure governance, authorization and proxy properties,
please refer to this file.
-#
+#
######################################################################################################
databaseName: sharding_db
+
+dataSources:
+ ds_0:
+ url: jdbc:opengauss://opengauss.default.host:5432/ds_0?batchMode=OFF
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+ ds_1:
+ url: jdbc:opengauss://opengauss.default.host:5432/ds_1?batchMode=OFF
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+ ds_2:
+ url: jdbc:opengauss://opengauss.default.host:5432/ds_2?batchMode=OFF
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+
rules:
- !SHARDING
tables:
@@ -64,7 +97,7 @@ rules:
shardingAlgorithmName: database_inline
defaultTableStrategy:
none:
-
+
shardingAlgorithms:
database_inline:
type: INLINE
@@ -86,11 +119,11 @@ rules:
type: INLINE
props:
algorithm-expression:
account_${Math.floorMod(Math.floorDiv(id.longValue(), 2L), 2L)}
-
+
keyGenerators:
snowflake:
type: SNOWFLAKE
-
+
- !BROADCAST
tables:
- t_address
diff --git
a/test/e2e/operation/transaction/src/test/resources/env/jdbc/opengauss/database-sharding-xa-narayana.yaml
b/test/e2e/operation/transaction/src/test/resources/env/jdbc/opengauss/database-sharding-xa-narayana.yaml
index 63c70aecdc2..0b69a35d53e 100644
---
a/test/e2e/operation/transaction/src/test/resources/env/jdbc/opengauss/database-sharding-xa-narayana.yaml
+++
b/test/e2e/operation/transaction/src/test/resources/env/jdbc/opengauss/database-sharding-xa-narayana.yaml
@@ -16,12 +16,45 @@
#
######################################################################################################
-#
+#
# If you want to configure governance, authorization and proxy properties,
please refer to this file.
-#
+#
######################################################################################################
databaseName: sharding_db
+
+dataSources:
+ ds_0:
+ url: jdbc:opengauss://opengauss.default.host:5432/ds_0?batchMode=OFF
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+ ds_1:
+ url: jdbc:opengauss://opengauss.default.host:5432/ds_1?batchMode=OFF
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+ ds_2:
+ url: jdbc:opengauss://opengauss.default.host:5432/ds_2?batchMode=OFF
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+
rules:
- !SHARDING
tables:
@@ -64,7 +97,7 @@ rules:
shardingAlgorithmName: database_inline
defaultTableStrategy:
none:
-
+
shardingAlgorithms:
database_inline:
type: INLINE
@@ -86,11 +119,11 @@ rules:
type: INLINE
props:
algorithm-expression: account_${id % 2}
-
+
keyGenerators:
snowflake:
type: SNOWFLAKE
-
+
- !BROADCAST
tables:
- t_address
diff --git
a/test/e2e/operation/transaction/src/test/resources/env/jdbc/postgresql/database-sharding-local.yaml
b/test/e2e/operation/transaction/src/test/resources/env/jdbc/postgresql/database-sharding-local.yaml
index fd3adc10fef..ce2aa872b20 100644
---
a/test/e2e/operation/transaction/src/test/resources/env/jdbc/postgresql/database-sharding-local.yaml
+++
b/test/e2e/operation/transaction/src/test/resources/env/jdbc/postgresql/database-sharding-local.yaml
@@ -16,12 +16,45 @@
#
######################################################################################################
-#
+#
# If you want to configure governance, authorization and proxy properties,
please refer to this file.
-#
+#
######################################################################################################
databaseName: sharding_db
+
+dataSources:
+ ds_0:
+ url:
jdbc:postgresql://postgresql.default.host:5432/ds_0?ssl=on&sslmode=prefer
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+ ds_1:
+ url:
jdbc:postgresql://postgresql.default.host:5432/ds_1?ssl=on&sslmode=prefer
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+ ds_2:
+ url:
jdbc:postgresql://postgresql.default.host:5432/ds_2?ssl=on&sslmode=prefer
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+
rules:
- !SHARDING
tables:
@@ -64,7 +97,7 @@ rules:
shardingAlgorithmName: database_inline
defaultTableStrategy:
none:
-
+
shardingAlgorithms:
database_inline:
type: INLINE
@@ -86,11 +119,11 @@ rules:
type: INLINE
props:
algorithm-expression:
account_${Math.floorMod(Math.floorDiv(id.longValue(), 2L), 2L)}
-
+
keyGenerators:
snowflake:
type: SNOWFLAKE
-
+
- !BROADCAST
tables:
- t_address
diff --git
a/test/e2e/operation/transaction/src/test/resources/env/jdbc/postgresql/database-sharding-xa-atomikos.yaml
b/test/e2e/operation/transaction/src/test/resources/env/jdbc/postgresql/database-sharding-xa-atomikos.yaml
index e653140e92f..c9fb8d4ef1d 100644
---
a/test/e2e/operation/transaction/src/test/resources/env/jdbc/postgresql/database-sharding-xa-atomikos.yaml
+++
b/test/e2e/operation/transaction/src/test/resources/env/jdbc/postgresql/database-sharding-xa-atomikos.yaml
@@ -16,12 +16,45 @@
#
######################################################################################################
-#
+#
# If you want to configure governance, authorization and proxy properties,
please refer to this file.
-#
+#
######################################################################################################
databaseName: sharding_db
+
+dataSources:
+ ds_0:
+ url:
jdbc:postgresql://postgresql.default.host:5432/ds_0?ssl=on&sslmode=prefer
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+ ds_1:
+ url:
jdbc:postgresql://postgresql.default.host:5432/ds_1?ssl=on&sslmode=prefer
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+ ds_2:
+ url:
jdbc:postgresql://postgresql.default.host:5432/ds_2?ssl=on&sslmode=prefer
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+
rules:
- !SHARDING
tables:
@@ -64,7 +97,7 @@ rules:
shardingAlgorithmName: database_inline
defaultTableStrategy:
none:
-
+
shardingAlgorithms:
database_inline:
type: INLINE
@@ -86,11 +119,11 @@ rules:
type: INLINE
props:
algorithm-expression:
account_${Math.floorMod(Math.floorDiv(id.longValue(), 2L), 2L)}
-
+
keyGenerators:
snowflake:
type: SNOWFLAKE
-
+
- !BROADCAST
tables:
- t_address
diff --git
a/test/e2e/operation/transaction/src/test/resources/env/jdbc/postgresql/database-sharding-xa-narayana.yaml
b/test/e2e/operation/transaction/src/test/resources/env/jdbc/postgresql/database-sharding-xa-narayana.yaml
index 63c70aecdc2..6ad9d87a852 100644
---
a/test/e2e/operation/transaction/src/test/resources/env/jdbc/postgresql/database-sharding-xa-narayana.yaml
+++
b/test/e2e/operation/transaction/src/test/resources/env/jdbc/postgresql/database-sharding-xa-narayana.yaml
@@ -16,12 +16,45 @@
#
######################################################################################################
-#
+#
# If you want to configure governance, authorization and proxy properties,
please refer to this file.
-#
+#
######################################################################################################
databaseName: sharding_db
+
+dataSources:
+ ds_0:
+ url:
jdbc:postgresql://postgresql.default.host:5432/ds_0?ssl=on&sslmode=prefer
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+ ds_1:
+ url:
jdbc:postgresql://postgresql.default.host:5432/ds_1?ssl=on&sslmode=prefer
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+ ds_2:
+ url:
jdbc:postgresql://postgresql.default.host:5432/ds_2?ssl=on&sslmode=prefer
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ username: test_user
+ password: Test@123
+ connectionTimeoutMilliseconds: 30000
+ idleTimeoutMilliseconds: 60000
+ maxLifetimeMilliseconds: 1800000
+ maxPoolSize: 50
+ minPoolSize: 2
+
rules:
- !SHARDING
tables:
@@ -64,7 +97,7 @@ rules:
shardingAlgorithmName: database_inline
defaultTableStrategy:
none:
-
+
shardingAlgorithms:
database_inline:
type: INLINE
@@ -86,11 +119,11 @@ rules:
type: INLINE
props:
algorithm-expression: account_${id % 2}
-
+
keyGenerators:
snowflake:
type: SNOWFLAKE
-
+
- !BROADCAST
tables:
- t_address