You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/04/28 06:30:09 UTC
[shardingsphere] branch master updated: Improvement scaling IT test (#17140)
This is an automated email from the ASF dual-hosted git repository.
zhonghongsheng 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 16d9ef687c2 Improvement scaling IT test (#17140)
16d9ef687c2 is described below
commit 16d9ef687c2fb4c0669a4af9ce62f14395bae7e9
Author: azexcy <10...@users.noreply.github.com>
AuthorDate: Thu Apr 28 14:30:00 2022 +0800
Improvement scaling IT test (#17140)
* Add PostgreSQL IT test
* Code optimization
* Modify package name
* Fix codestyle, more readable
* Change remote debug port
* Remove config-sharding.yaml, PostgresSQL add TODO.
---
.../pom.xml | 11 +++
.../data/{pipline => pipeline}/ScalingIT.java | 8 +-
.../cases/BaseScalingIT.java} | 90 ++++++----------------
.../cases/IncrementTaskRunnable.java | 6 +-
.../cases/command/CommonSQLCommand.java | 14 +---
.../cases/command/ExtraSQLCommand.java} | 10 ++-
.../pipeline/cases/mysql/BaseMySQLScalingIT.java | 77 ++++++++++++++++++
.../cases/mysql/MySQLManualScalingCase.java | 12 ++-
.../cases/postgresql/BasePostgreSQLScalingIT.java | 71 +++++++++++++++++
.../postgresql/PostgreSQLManualScalingCase.java} | 20 +++--
.../container/cluster/ZookeeperContainer.java | 43 +++++++++++
.../container/compose/BaseComposedContainer.java | 10 +--
.../container/compose/DockerComposedContainer.java | 8 +-
.../container/compose/LocalComposedContainer.java | 11 +--
.../database/DockerDatabaseContainer.java | 28 +++----
.../container/database/MySQLContainer.java | 70 +++++++++++++++++
.../container/database/PostgreSQLContainer.java | 60 +++++++++++++++
.../proxy/JDBCConnectionWaitStrategy.java | 50 ++++++++++++
.../proxy/ShardingSphereProxyDockerContainer.java | 49 ++++--------
.../proxy/ShardingSphereProxyLocalContainer.java | 24 +++---
.../env/ITEnvironmentContext.java | 10 +--
.../env/IntegrationTestEnvironment.java | 7 +-
.../{pipline => pipeline}/env/cases/DataSet.java | 2 +-
.../data/{pipline => pipeline}/env/cases/Type.java | 2 +-
.../env/config/SourceConfiguration.java | 4 +-
.../env/config/TargetConfiguration.java | 4 +-
.../env/enums/ITEnvTypeEnum.java | 2 +-
.../factory/DatabaseContainerFactory.java | 8 +-
.../fixture/DataImporter.java | 8 +-
.../util/DatabaseTypeUtil.java} | 33 ++++----
.../{pipline => pipeline}/util/ExecuteUtil.java | 2 +-
.../data/{pipline => pipeline}/util/Executor.java | 2 +-
.../{pipline => pipeline}/util/ScalingUtil.java | 2 +-
.../{pipline => pipeline}/util/TableCrudUtil.java | 26 ++++++-
.../pipline/cases/mysql/BaseMySQLScalingCase.java | 47 -----------
.../pipline/container/database/MySQLContainer.java | 43 -----------
.../src/test/resources/env/common/command.xml | 43 ++---------
.../src/test/resources/env/it-env.properties | 8 +-
.../test/resources/env/{conf => mysql}/server.yaml | 2 +-
.../src/test/resources/env/mysql/sql.xml | 27 +++++++
.../src/test/resources/env/postgresql/initdb.sql | 6 ++
.../postgresql.conf} | 13 ++--
.../src/test/resources/env/postgresql/server.yaml | 60 +++++++++++++++
.../resources/env/{mysql => postgresql}/sql.xml | 42 +++++-----
44 files changed, 691 insertions(+), 384 deletions(-)
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/pom.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/pom.xml
index 2174e35d7f9..85cc607a0dd 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/pom.xml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/pom.xml
@@ -74,6 +74,11 @@
<artifactId>mysql-connector-java</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ </dependency>
+
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
@@ -84,6 +89,12 @@
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
+ <configuration>
+ <skipITs>true</skipITs>
+ <includes>
+ <include>**/*Case.java</include>
+ </includes>
+ </configuration>
<executions>
<execution>
<id>integration-tests</id>
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/ScalingIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/ScalingIT.java
similarity index 86%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/ScalingIT.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/ScalingIT.java
index cf2ff119f21..5d8e37b1167 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/ScalingIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/ScalingIT.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline;
+package org.apache.shardingsphere.integration.data.pipeline;
import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.integration.data.pipline.env.ITEnvironmentContext;
-import org.apache.shardingsphere.integration.data.pipline.util.ExecuteUtil;
-import org.apache.shardingsphere.integration.data.pipline.util.ScalingUtil;
+import org.apache.shardingsphere.integration.data.pipeline.env.ITEnvironmentContext;
+import org.apache.shardingsphere.integration.data.pipeline.util.ExecuteUtil;
+import org.apache.shardingsphere.integration.data.pipeline.util.ScalingUtil;
import org.junit.Ignore;
import java.util.Map;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/BaseScalingITCase.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/BaseScalingIT.java
similarity index 56%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/BaseScalingITCase.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/BaseScalingIT.java
index 4f747c8ee59..ae0eb8e64b1 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/BaseScalingITCase.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/BaseScalingIT.java
@@ -15,27 +15,26 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.cases;
+package org.apache.shardingsphere.integration.data.pipeline.cases;
import com.google.common.base.Joiner;
import com.google.common.collect.Sets;
import lombok.AccessLevel;
import lombok.Getter;
-import lombok.SneakyThrows;
import org.apache.commons.lang3.StringUtils;
import org.apache.shardingsphere.data.pipeline.api.job.JobStatus;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.integration.data.pipline.cases.command.CommonSQLCommand;
-import org.apache.shardingsphere.integration.data.pipline.container.compose.BaseComposedContainer;
-import org.apache.shardingsphere.integration.data.pipline.container.compose.DockerComposedContainer;
-import org.apache.shardingsphere.integration.data.pipline.container.compose.LocalComposedContainer;
-import org.apache.shardingsphere.integration.data.pipline.env.IntegrationTestEnvironment;
-import org.apache.shardingsphere.integration.data.pipline.env.enums.ITEnvTypeEnum;
+import org.apache.shardingsphere.integration.data.pipeline.cases.command.CommonSQLCommand;
+import org.apache.shardingsphere.integration.data.pipeline.cases.command.ExtraSQLCommand;
+import org.apache.shardingsphere.integration.data.pipeline.container.compose.BaseComposedContainer;
+import org.apache.shardingsphere.integration.data.pipeline.container.compose.DockerComposedContainer;
+import org.apache.shardingsphere.integration.data.pipeline.container.compose.LocalComposedContainer;
+import org.apache.shardingsphere.integration.data.pipeline.env.IntegrationTestEnvironment;
+import org.apache.shardingsphere.integration.data.pipeline.env.enums.ITEnvTypeEnum;
import org.springframework.jdbc.core.JdbcTemplate;
import javax.sql.DataSource;
import javax.xml.bind.JAXB;
-import java.sql.Connection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -49,52 +48,25 @@ import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-public abstract class BaseScalingITCase {
+@Getter(AccessLevel.PROTECTED)
+public abstract class BaseScalingIT {
@Getter(AccessLevel.NONE)
private final BaseComposedContainer composedContainer;
- @Getter(AccessLevel.PROTECTED)
- private CommonSQLCommand commonSQLCommand;
+ private final CommonSQLCommand commonSQLCommand;
- @Getter(AccessLevel.PROTECTED)
- private JdbcTemplate jdbcTemplate;
+ private final ExtraSQLCommand extraSQLCommand;
- public BaseScalingITCase(final DatabaseType databaseType) {
- if (StringUtils.equalsIgnoreCase(IntegrationTestEnvironment.getInstance().getItEnvType(), ITEnvTypeEnum.DOCKER.name())) {
+ public BaseScalingIT(final DatabaseType databaseType) {
+ if (IntegrationTestEnvironment.getInstance().getItEnvType() == ITEnvTypeEnum.DOCKER) {
composedContainer = new DockerComposedContainer(databaseType);
} else {
composedContainer = new LocalComposedContainer(databaseType);
}
composedContainer.start();
- initScalingEnvironment();
- }
-
- @SneakyThrows
- protected void initScalingEnvironment() {
- commonSQLCommand = JAXB.unmarshal(BaseScalingITCase.class.getClassLoader().getResource("env/common/command.xml"), CommonSQLCommand.class);
- try (Connection connection = getProxyDataSource("").getConnection()) {
- connection.createStatement().execute(commonSQLCommand.getCreateDatabase());
- connection.createStatement().execute(commonSQLCommand.getUseDatabase());
- int dbIndex = 0;
- for (String dbName : listSourceDatabaseName()) {
- connection.createStatement().execute(String.format(commonSQLCommand.getAddResource(), dbIndex, getDatabaseUrl(), dbName));
- dbIndex++;
- }
- for (String value : listTargetDatabaseName()) {
- connection.createStatement().execute(String.format(commonSQLCommand.getAddResource(), dbIndex, getDatabaseUrl(), value));
- dbIndex++;
- }
- for (String sql : commonSQLCommand.getCreateShardingAlgorithm()) {
- connection.createStatement().execute(sql);
- }
- // TODO sleep to wait for sharding algorithm table created,otherwise, the next sql will fail.
- TimeUnit.SECONDS.sleep(2);
- connection.createStatement().execute(commonSQLCommand.getCreateShardingTable());
- connection.createStatement().execute(commonSQLCommand.getCreateShardingBinding());
- connection.createStatement().execute(commonSQLCommand.getCreateShardingScalingRule());
- }
- jdbcTemplate = new JdbcTemplate(composedContainer.getProxyDataSource("sharding_db"));
+ commonSQLCommand = JAXB.unmarshal(BaseScalingIT.class.getClassLoader().getResource("env/common/command.xml"), CommonSQLCommand.class);
+ extraSQLCommand = JAXB.unmarshal(BaseScalingIT.class.getClassLoader().getResource(String.format("env/%s/sql.xml", databaseType.getName().toLowerCase())), ExtraSQLCommand.class);
}
/**
@@ -103,7 +75,7 @@ public abstract class BaseScalingITCase {
* @param dataSourceName data source names
* @return proxy database connection
*/
- public DataSource getProxyDataSource(final String dataSourceName) {
+ protected DataSource getProxyDataSource(final String dataSourceName) {
return composedContainer.getProxyDataSource(dataSourceName);
}
@@ -112,32 +84,14 @@ public abstract class BaseScalingITCase {
*
* @return database url
*/
- public String getDatabaseUrl() {
- if (StringUtils.equalsIgnoreCase(IntegrationTestEnvironment.getInstance().getItEnvType(), ITEnvTypeEnum.DOCKER.name())) {
+ public String getDatabaseIpAndPort() {
+ if (IntegrationTestEnvironment.getInstance().getItEnvType() == ITEnvTypeEnum.DOCKER) {
return Joiner.on(":").join("db.host", composedContainer.getDatabaseContainer().getPort());
} else {
- return Joiner.on(":").join(composedContainer.getDatabaseContainer().getHost(), composedContainer.getDatabaseContainer().getFirstMappedPort());
+ return Joiner.on(":").join("localhost", composedContainer.getDatabaseContainer().getFirstMappedPort());
}
}
- /**
- * Query actual source database name.
- *
- * @return actual source database name list
- */
- public List<String> listSourceDatabaseName() {
- return composedContainer.getDatabaseContainer().getSourceDatabaseNames();
- }
-
- /**
- * Query actual target database name.
- *
- * @return actual target database name list
- */
- public List<String> listTargetDatabaseName() {
- return composedContainer.getDatabaseContainer().getTargetDatabaseNames();
- }
-
/**
* Check data match consistency.
*
@@ -179,4 +133,8 @@ public abstract class BaseScalingITCase {
Set<Object> originalSourceList = previewResList.stream().map(result -> result.get("data_source_name")).collect(Collectors.toSet());
assertThat(originalSourceList, is(Sets.newHashSet("ds_2", "ds_3", "ds_4")));
}
+
+ protected void stopContainer() {
+ composedContainer.stop();
+ }
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/IncrementTaskRunnable.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/IncrementTaskRunnable.java
similarity index 92%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/IncrementTaskRunnable.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/IncrementTaskRunnable.java
index eb567aa2cfd..03030028d34 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/IncrementTaskRunnable.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/IncrementTaskRunnable.java
@@ -15,13 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.cases;
+package org.apache.shardingsphere.integration.data.pipeline.cases;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.Pair;
-import org.apache.shardingsphere.integration.data.pipline.cases.command.CommonSQLCommand;
-import org.apache.shardingsphere.integration.data.pipline.util.TableCrudUtil;
+import org.apache.shardingsphere.integration.data.pipeline.cases.command.CommonSQLCommand;
+import org.apache.shardingsphere.integration.data.pipeline.util.TableCrudUtil;
import org.springframework.jdbc.core.JdbcTemplate;
import java.sql.SQLException;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/command/CommonSQLCommand.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/command/CommonSQLCommand.java
similarity index 88%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/command/CommonSQLCommand.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/command/CommonSQLCommand.java
index fdc5e121802..17ce8613c36 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/command/CommonSQLCommand.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/command/CommonSQLCommand.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.cases.command;
+package org.apache.shardingsphere.integration.data.pipeline.cases.command;
import lombok.Data;
@@ -30,15 +30,6 @@ import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
public final class CommonSQLCommand {
- @XmlElement(name = "add-resource")
- private String addResource;
-
- @XmlElement(name = "create-database")
- private String createDatabase;
-
- @XmlElement(name = "use-database")
- private String useDatabase;
-
@XmlElement(name = "create-sharding-algorithm")
private List<String> createShardingAlgorithm;
@@ -78,9 +69,6 @@ public final class CommonSQLCommand {
@XmlElement(name = "auto-alter-table-rule")
private String autoAlterTableRule;
- @XmlElement(name = "insert-order")
- private String insertOrder;
-
@XmlElement(name = "insert-order-item")
private String insertOrderItem;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/command/CreateTableSQLCommand.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/command/ExtraSQLCommand.java
similarity index 82%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/command/CreateTableSQLCommand.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/command/ExtraSQLCommand.java
index f9fc332c5b9..8f46c73c7bc 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/command/CreateTableSQLCommand.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/command/ExtraSQLCommand.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.cases.command;
+package org.apache.shardingsphere.integration.data.pipeline.cases.command;
import lombok.Data;
@@ -27,11 +27,17 @@ import javax.xml.bind.annotation.XmlRootElement;
@Data
@XmlRootElement(name = "command")
@XmlAccessorType(XmlAccessType.FIELD)
-public final class CreateTableSQLCommand {
+public final class ExtraSQLCommand {
@XmlElement(name = "create-table-order")
private String createTableOrder;
@XmlElement(name = "create-table-order-item")
private String createTableOrderItem;
+
+ @XmlElement(name = "use-database")
+ private String useDatabase;
+
+ @XmlElement(name = "insert-order")
+ private String insertOrder;
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/mysql/BaseMySQLScalingIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/mysql/BaseMySQLScalingIT.java
new file mode 100644
index 00000000000..b23cec8437a
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/mysql/BaseMySQLScalingIT.java
@@ -0,0 +1,77 @@
+/*
+ * 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.integration.data.pipeline.cases.mysql;
+
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.SneakyThrows;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
+import org.apache.shardingsphere.integration.data.pipeline.cases.BaseScalingIT;
+import org.apache.shardingsphere.integration.data.pipeline.util.TableCrudUtil;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+import java.sql.Connection;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+public abstract class BaseMySQLScalingIT extends BaseScalingIT {
+
+ private static final DatabaseType MYSQL_DATABASE = new MySQLDatabaseType();
+
+ private static final String ADD_RESOURCE_SQL = "ADD RESOURCE %s (URL='jdbc:mysql://%s/%s?serverTimezone=UTC&useSSL=false&rewriteBatchedStatements=true',USER=root,PASSWORD=root)";
+
+ @Getter(AccessLevel.PROTECTED)
+ private JdbcTemplate jdbcTemplate;
+
+ public BaseMySQLScalingIT() {
+ super(MYSQL_DATABASE);
+ initScalingEnvironment();
+ }
+
+ @SneakyThrows
+ protected void initScalingEnvironment() {
+ try (Connection connection = getProxyDataSource("").getConnection()) {
+ connection.createStatement().execute("CREATE DATABASE sharding_db");
+ connection.createStatement().execute("USE sharding_db");
+ connection.createStatement().execute(String.format(ADD_RESOURCE_SQL, "ds_0", getDatabaseIpAndPort(), "ds_0"));
+ connection.createStatement().execute(String.format(ADD_RESOURCE_SQL, "ds_1", getDatabaseIpAndPort(), "ds_1"));
+ connection.createStatement().execute(String.format(ADD_RESOURCE_SQL, "ds_2", getDatabaseIpAndPort(), "ds_2"));
+ connection.createStatement().execute(String.format(ADD_RESOURCE_SQL, "ds_3", getDatabaseIpAndPort(), "ds_3"));
+ connection.createStatement().execute(String.format(ADD_RESOURCE_SQL, "ds_4", getDatabaseIpAndPort(), "ds_4"));
+ for (String sql : getCommonSQLCommand().getCreateShardingAlgorithm()) {
+ connection.createStatement().execute(sql);
+ // TODO sleep to wait for sharding algorithm table created,otherwise, the next sql will fail.
+ TimeUnit.SECONDS.sleep(1);
+ }
+ connection.createStatement().execute(getCommonSQLCommand().getCreateShardingTable());
+ connection.createStatement().execute(getCommonSQLCommand().getCreateShardingBinding());
+ connection.createStatement().execute(getCommonSQLCommand().getCreateShardingScalingRule());
+ }
+ jdbcTemplate = new JdbcTemplate(getProxyDataSource("sharding_db"));
+ }
+
+ protected void initTableAndData() {
+ jdbcTemplate.execute(getExtraSQLCommand().getCreateTableOrder());
+ jdbcTemplate.execute(getExtraSQLCommand().getCreateTableOrderItem());
+ Pair<List<Object[]>, List<Object[]>> dataPair = TableCrudUtil.generateMySQLInsertDataList(3000);
+ jdbcTemplate.batchUpdate(getExtraSQLCommand().getInsertOrder(), dataPair.getLeft());
+ jdbcTemplate.batchUpdate(getCommonSQLCommand().getInsertOrderItem(), dataPair.getRight());
+ }
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/mysql/MySQLManualScalingCase.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/mysql/MySQLManualScalingCase.java
similarity index 89%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/mysql/MySQLManualScalingCase.java
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/mysql/MySQLManualScalingCase.java
index 44e7688efa5..9584c4935da 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/mysql/MySQLManualScalingCase.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/mysql/MySQLManualScalingCase.java
@@ -15,11 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.cases.mysql;
+package org.apache.shardingsphere.integration.data.pipeline.cases.mysql;
import com.google.common.collect.Sets;
import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.integration.data.pipline.cases.IncrementTaskRunnable;
+import org.apache.shardingsphere.integration.data.pipeline.cases.IncrementTaskRunnable;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -35,7 +36,7 @@ import static org.junit.Assert.assertThat;
* MySQL manual scaling test case.
*/
@Slf4j
-public final class MySQLManualScalingCase extends BaseMySQLScalingCase {
+public final class MySQLManualScalingCase extends BaseMySQLScalingIT {
private Thread increaseTaskThread;
@@ -57,4 +58,9 @@ public final class MySQLManualScalingCase extends BaseMySQLScalingCase {
increaseTaskThread.join(60 * 1000);
checkMatchConsistency(getJdbcTemplate(), jobId);
}
+
+ @After
+ public void stop() {
+ super.stopContainer();
+ }
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/postgresql/BasePostgreSQLScalingIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/postgresql/BasePostgreSQLScalingIT.java
new file mode 100644
index 00000000000..0345adbf3b7
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/postgresql/BasePostgreSQLScalingIT.java
@@ -0,0 +1,71 @@
+/*
+ * 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.integration.data.pipeline.cases.postgresql;
+
+import lombok.AccessLevel;
+import lombok.Getter;
+import lombok.SneakyThrows;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
+import org.apache.shardingsphere.integration.data.pipeline.cases.BaseScalingIT;
+import org.apache.shardingsphere.integration.data.pipeline.cases.command.ExtraSQLCommand;
+import org.apache.shardingsphere.integration.data.pipeline.util.TableCrudUtil;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+import javax.sql.DataSource;
+import javax.xml.bind.JAXB;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.List;
+
+public class BasePostgreSQLScalingIT extends BaseScalingIT {
+
+ private static final String ADD_RESOURCE = "ADD RESOURCE %s (URL='jdbc:postgresql://%s/%s?serverTimezone=UTC&useSSL=false',USER=root,PASSWORD=root)";
+
+ @Getter
+ private final ExtraSQLCommand extraSQLCommand;
+
+ @Getter(AccessLevel.PROTECTED)
+ private JdbcTemplate jdbcTemplate;
+
+ public BasePostgreSQLScalingIT() {
+ super(new PostgreSQLDatabaseType());
+ extraSQLCommand = JAXB.unmarshal(BasePostgreSQLScalingIT.class.getClassLoader().getResource("env/postgresql/sql.xml"), ExtraSQLCommand.class);
+ initScalingEnvironment();
+ }
+
+ @SneakyThrows(SQLException.class)
+ protected void initScalingEnvironment() {
+ // TODO jdbc create database not take effect
+ DataSource dataSource = getProxyDataSource("sharding_db");
+ jdbcTemplate = new JdbcTemplate(dataSource);
+ try (Connection connection = dataSource.getConnection()) {
+ connection.createStatement().execute(String.format(ADD_RESOURCE, "ds_2", getDatabaseIpAndPort(), "ds_2"));
+ connection.createStatement().execute(String.format(ADD_RESOURCE, "ds_3", getDatabaseIpAndPort(), "ds_3"));
+ connection.createStatement().execute(String.format(ADD_RESOURCE, "ds_4", getDatabaseIpAndPort(), "ds_4"));
+ }
+ }
+
+ protected void initTableAndData() {
+ jdbcTemplate.execute(extraSQLCommand.getCreateTableOrder());
+ jdbcTemplate.execute(extraSQLCommand.getCreateTableOrderItem());
+ Pair<List<Object[]>, List<Object[]>> dataPair = TableCrudUtil.generatePostgresSQLInsertDataList(3000);
+ getJdbcTemplate().batchUpdate(getExtraSQLCommand().getInsertOrder(), dataPair.getLeft());
+ getJdbcTemplate().batchUpdate(getCommonSQLCommand().getInsertOrderItem(), dataPair.getRight());
+ }
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/mysql/MySQLManualScalingCase.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/postgresql/PostgreSQLManualScalingCase.java
similarity index 82%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/mysql/MySQLManualScalingCase.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/postgresql/PostgreSQLManualScalingCase.java
index 44e7688efa5..e8762642134 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/mysql/MySQLManualScalingCase.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/postgresql/PostgreSQLManualScalingCase.java
@@ -15,13 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.cases.mysql;
+package org.apache.shardingsphere.integration.data.pipeline.cases.postgresql;
import com.google.common.collect.Sets;
import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.integration.data.pipline.cases.IncrementTaskRunnable;
+import org.apache.shardingsphere.integration.data.pipeline.cases.IncrementTaskRunnable;
+import org.junit.After;
import org.junit.Before;
-import org.junit.Test;
import java.util.List;
import java.util.Map;
@@ -31,11 +31,8 @@ import java.util.stream.Collectors;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-/**
- * MySQL manual scaling test case.
- */
@Slf4j
-public final class MySQLManualScalingCase extends BaseMySQLScalingCase {
+public final class PostgreSQLManualScalingCase extends BasePostgreSQLScalingIT {
private Thread increaseTaskThread;
@@ -46,7 +43,8 @@ public final class MySQLManualScalingCase extends BaseMySQLScalingCase {
increaseTaskThread.start();
}
- @Test
+ // TODO Wait the create database bug of proxy fixed.
+ // @Test
public void assertManualScalingSuccess() throws InterruptedException {
List<Map<String, Object>> previewResList = getJdbcTemplate().queryForList(getCommonSQLCommand().getPreviewSelectOrder());
Set<Object> originalSourceList = previewResList.stream().map(result -> result.get("data_source_name")).collect(Collectors.toSet());
@@ -56,5 +54,11 @@ public final class MySQLManualScalingCase extends BaseMySQLScalingCase {
String jobId = showScalingResMap.get("id").toString();
increaseTaskThread.join(60 * 1000);
checkMatchConsistency(getJdbcTemplate(), jobId);
+ super.stopContainer();
+ }
+
+ @After
+ public void stop() {
+ super.stopContainer();
}
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/cluster/ZookeeperContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/cluster/ZookeeperContainer.java
new file mode 100644
index 00000000000..a4164ce8b88
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/cluster/ZookeeperContainer.java
@@ -0,0 +1,43 @@
+/*
+ * 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.integration.data.pipeline.container.cluster;
+
+import org.apache.shardingsphere.integration.data.pipeline.env.IntegrationTestEnvironment;
+import org.apache.shardingsphere.integration.data.pipeline.env.enums.ITEnvTypeEnum;
+import org.apache.shardingsphere.test.integration.framework.container.atomic.governance.GovernanceContainer;
+import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
+
+/**
+ * Zookeeper container.
+ */
+public final class ZookeeperContainer extends GovernanceContainer {
+
+ public ZookeeperContainer() {
+ super("zookeeper", "zookeeper:3.6.2");
+ setWaitStrategy(new LogMessageWaitStrategy().withRegEx(".*PrepRequestProcessor \\(sid:[0-9]+\\) started.*"));
+ withExposedPorts(2181);
+ if (ITEnvTypeEnum.LOCAL == IntegrationTestEnvironment.getInstance().getItEnvType()) {
+ addFixedExposedPort(2181, 2181);
+ }
+ }
+
+ @Override
+ public String getServerLists() {
+ return getHost() + ":" + getMappedPort(2181);
+ }
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/BaseComposedContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/compose/BaseComposedContainer.java
similarity index 82%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/BaseComposedContainer.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/compose/BaseComposedContainer.java
index c47ba65683b..d332d4a76f0 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/BaseComposedContainer.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/compose/BaseComposedContainer.java
@@ -15,15 +15,15 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.container.compose;
+package org.apache.shardingsphere.integration.data.pipeline.container.compose;
import lombok.Getter;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.integration.data.pipline.container.database.DockerDatabaseContainer;
-import org.apache.shardingsphere.integration.data.pipline.factory.DatabaseContainerFactory;
+import org.apache.shardingsphere.integration.data.pipeline.container.cluster.ZookeeperContainer;
+import org.apache.shardingsphere.integration.data.pipeline.container.database.DockerDatabaseContainer;
+import org.apache.shardingsphere.integration.data.pipeline.factory.DatabaseContainerFactory;
import org.apache.shardingsphere.test.integration.framework.container.atomic.ITContainers;
import org.apache.shardingsphere.test.integration.framework.container.atomic.governance.GovernanceContainer;
-import org.apache.shardingsphere.test.integration.framework.container.atomic.governance.GovernanceContainerFactory;
import org.apache.shardingsphere.test.integration.util.NetworkAliasUtil;
import org.testcontainers.lifecycle.Startable;
@@ -40,7 +40,7 @@ public abstract class BaseComposedContainer implements Startable {
public BaseComposedContainer(final DatabaseType databaseType) {
this.containers = new ITContainers("");
- this.governanceContainer = containers.registerContainer(GovernanceContainerFactory.newInstance("ZooKeeper"), NetworkAliasUtil.getNetworkAlias("zk"));
+ this.governanceContainer = containers.registerContainer(new ZookeeperContainer(), NetworkAliasUtil.getNetworkAlias("zk"));
this.databaseContainer = containers.registerContainer(DatabaseContainerFactory.newInstance(databaseType), NetworkAliasUtil.getNetworkAlias("db"));
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/DockerComposedContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/compose/DockerComposedContainer.java
similarity index 82%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/DockerComposedContainer.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/compose/DockerComposedContainer.java
index 2f68e48ca00..b52152f4e63 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/DockerComposedContainer.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/compose/DockerComposedContainer.java
@@ -15,13 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.container.compose;
+package org.apache.shardingsphere.integration.data.pipeline.container.compose;
import com.zaxxer.hikari.HikariDataSource;
import lombok.Getter;
-import org.apache.commons.lang3.StringUtils;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.integration.data.pipline.container.proxy.ShardingSphereProxyDockerContainer;
+import org.apache.shardingsphere.integration.data.pipeline.container.proxy.ShardingSphereProxyDockerContainer;
import org.apache.shardingsphere.test.integration.env.DataSourceEnvironment;
import org.apache.shardingsphere.test.integration.util.NetworkAliasUtil;
@@ -53,8 +52,7 @@ public final class DockerComposedContainer extends BaseComposedContainer {
public DataSource getProxyDataSource(final String databaseName) {
HikariDataSource result = new HikariDataSource();
result.setDriverClassName(DataSourceEnvironment.getDriverClassName(getDatabaseContainer().getDatabaseType()));
- String jdbcUrl = DataSourceEnvironment.getURL(getDatabaseContainer().getDatabaseType(), getProxyContainer().getHost(), getProxyContainer().getFirstMappedPort(), databaseName);
- result.setJdbcUrl(StringUtils.appendIfMissing(jdbcUrl, "&rewriteBatchedStatements=true"));
+ result.setJdbcUrl(getDatabaseContainer().getJdbcUrl(getProxyContainer().getHost(), getProxyContainer().getFirstMappedPort(), databaseName));
result.setUsername("root");
result.setPassword("root");
result.setMaximumPoolSize(2);
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/LocalComposedContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/compose/LocalComposedContainer.java
similarity index 78%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/LocalComposedContainer.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/compose/LocalComposedContainer.java
index 15a064997aa..79ee72e9b4b 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/LocalComposedContainer.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/compose/LocalComposedContainer.java
@@ -15,13 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.container.compose;
+package org.apache.shardingsphere.integration.data.pipeline.container.compose;
import com.zaxxer.hikari.HikariDataSource;
import lombok.SneakyThrows;
-import org.apache.commons.lang3.StringUtils;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.integration.data.pipline.container.proxy.ShardingSphereProxyLocalContainer;
+import org.apache.shardingsphere.integration.data.pipeline.container.proxy.ShardingSphereProxyLocalContainer;
import org.apache.shardingsphere.test.integration.env.DataSourceEnvironment;
import javax.sql.DataSource;
@@ -30,7 +29,6 @@ import javax.sql.DataSource;
* Local composed container.
*/
public final class LocalComposedContainer extends BaseComposedContainer {
-
private ShardingSphereProxyLocalContainer shardingSphereProxyContainer;
public LocalComposedContainer(final DatabaseType databaseType) {
@@ -41,7 +39,7 @@ public final class LocalComposedContainer extends BaseComposedContainer {
@Override
public void start() {
super.start();
- shardingSphereProxyContainer = new ShardingSphereProxyLocalContainer(getGovernanceContainer().getServerLists(), getDatabaseContainer().getDatabaseType());
+ shardingSphereProxyContainer = new ShardingSphereProxyLocalContainer(getDatabaseContainer().getDatabaseType());
shardingSphereProxyContainer.start();
}
@@ -49,8 +47,7 @@ public final class LocalComposedContainer extends BaseComposedContainer {
public DataSource getProxyDataSource(final String databaseName) {
HikariDataSource result = new HikariDataSource();
result.setDriverClassName(DataSourceEnvironment.getDriverClassName(getDatabaseContainer().getDatabaseType()));
- String jdbcUrl = StringUtils.appendIfMissing(DataSourceEnvironment.getURL(getDatabaseContainer().getDatabaseType(), "localhost", 3307, databaseName), "&rewriteBatchedStatements=true");
- result.setJdbcUrl(jdbcUrl);
+ result.setJdbcUrl(getDatabaseContainer().getJdbcUrl("localhost", 3307, databaseName));
result.setUsername("root");
result.setPassword("root");
result.setMaximumPoolSize(2);
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/database/DockerDatabaseContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/database/DockerDatabaseContainer.java
similarity index 68%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/database/DockerDatabaseContainer.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/database/DockerDatabaseContainer.java
index a8d3df3bcdd..942a4d86e04 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/database/DockerDatabaseContainer.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/database/DockerDatabaseContainer.java
@@ -15,17 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.container.database;
+package org.apache.shardingsphere.integration.data.pipeline.container.database;
import lombok.Getter;
-import org.apache.curator.shaded.com.google.common.collect.Lists;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.test.integration.framework.container.atomic.DockerITContainer;
import org.testcontainers.containers.BindMode;
-import java.util.LinkedList;
-import java.util.List;
-
/**
* Docker storage container.
*/
@@ -34,27 +30,25 @@ public abstract class DockerDatabaseContainer extends DockerITContainer {
private final DatabaseType databaseType;
- private final List<String> sourceDatabaseNames;
-
- private final List<String> targetDatabaseNames;
-
public DockerDatabaseContainer(final DatabaseType databaseType, final String dockerImageName) {
super(databaseType.getName().toLowerCase(), dockerImageName);
this.databaseType = databaseType;
- sourceDatabaseNames = new LinkedList<>();
- targetDatabaseNames = new LinkedList<>();
}
@Override
protected void configure() {
- withClasspathResourceMapping(String.format("/env/%s", databaseType.getName()), "/docker-entrypoint-initdb.d/", BindMode.READ_ONLY);
+ withClasspathResourceMapping(String.format("/env/%s/initdb.sql", databaseType.getName().toLowerCase()), "/docker-entrypoint-initdb.d/", BindMode.READ_ONLY);
}
- @Override
- protected void postStart() {
- sourceDatabaseNames.addAll(Lists.newArrayList("ds_0", "ds_1"));
- targetDatabaseNames.addAll(Lists.newArrayList("ds_2", "ds_3", "ds_4"));
- }
+ /**
+ * Get jdbc url.
+ *
+ * @param host host
+ * @param port port
+ * @param databaseName database name
+ * @return jdbc url
+ */
+ public abstract String getJdbcUrl(String host, int port, String databaseName);
/**
* Get database port.
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/database/MySQLContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/database/MySQLContainer.java
new file mode 100644
index 00000000000..29c8b3deeec
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/database/MySQLContainer.java
@@ -0,0 +1,70 @@
+/*
+ * 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.integration.data.pipeline.container.database;
+
+import com.google.common.collect.Lists;
+import org.apache.shardingsphere.infra.database.metadata.url.JdbcUrlAppender;
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
+import org.apache.shardingsphere.integration.data.pipeline.env.IntegrationTestEnvironment;
+import org.apache.shardingsphere.integration.data.pipeline.env.enums.ITEnvTypeEnum;
+import org.apache.shardingsphere.test.integration.env.DataSourceEnvironment;
+import org.testcontainers.containers.BindMode;
+import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
+
+import java.util.Properties;
+
+public final class MySQLContainer extends DockerDatabaseContainer {
+
+ private static final DatabaseType DATABASE_TYPE = new MySQLDatabaseType();
+
+ public MySQLContainer(final String dockerImageName) {
+ super(DATABASE_TYPE, dockerImageName);
+ }
+
+ @Override
+ protected void configure() {
+ withCommand("--sql_mode=", "--default-authentication-plugin=mysql_native_password");
+ setEnv(Lists.newArrayList("LANG=C.UTF-8", "MYSQL_ROOT_PASSWORD=root", "MYSQL_ROOT_HOST=%"));
+ withClasspathResourceMapping("/env/mysql/my.cnf", "/etc/mysql/my.cnf", BindMode.READ_ONLY);
+ super.configure();
+ withExposedPorts(getPort());
+ setWaitStrategy(new LogMessageWaitStrategy().withRegEx(".*ready for connections.*"));
+ if (IntegrationTestEnvironment.getInstance().getItEnvType() == ITEnvTypeEnum.LOCAL) {
+ addFixedExposedPort(3306, 3306);
+ }
+ }
+
+ @Override
+ public String getJdbcUrl(final String host, final int port, final String databaseName) {
+ String jdbcUrl = DataSourceEnvironment.getURL(DATABASE_TYPE, host, port, databaseName);
+ return new JdbcUrlAppender().appendQueryProperties(jdbcUrl, createQueryProperties());
+ }
+
+ private Properties createQueryProperties() {
+ Properties result = new Properties();
+ result.put("useSSL", Boolean.FALSE.toString());
+ result.put("rewriteBatchedStatements", Boolean.TRUE.toString());
+ return result;
+ }
+
+ @Override
+ public int getPort() {
+ return 3306;
+ }
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/database/PostgreSQLContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/database/PostgreSQLContainer.java
new file mode 100644
index 00000000000..e89b60f5d5d
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/database/PostgreSQLContainer.java
@@ -0,0 +1,60 @@
+/*
+ * 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.integration.data.pipeline.container.database;
+
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
+import org.apache.shardingsphere.integration.data.pipeline.env.IntegrationTestEnvironment;
+import org.apache.shardingsphere.integration.data.pipeline.env.enums.ITEnvTypeEnum;
+import org.apache.shardingsphere.test.integration.env.DataSourceEnvironment;
+import org.testcontainers.containers.BindMode;
+import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
+
+public final class PostgreSQLContainer extends DockerDatabaseContainer {
+
+ private static final DatabaseType DATABASE_TYPE = new PostgreSQLDatabaseType();
+
+ public PostgreSQLContainer(final String dockerImageName) {
+ super(DATABASE_TYPE, dockerImageName);
+ setWaitStrategy(new LogMessageWaitStrategy().withRegEx(".*database system is ready to accept connections.*"));
+ }
+
+ @Override
+ protected void configure() {
+ withCommand("--max_connections=600");
+ withCommand("--wal_level=logical");
+ addEnv("POSTGRES_USER", "root");
+ addEnv("POSTGRES_PASSWORD", "root");
+ super.configure();
+ withClasspathResourceMapping("/env/postgresql/postgresql.conf", "/etc/postgresql/postgresql.conf", BindMode.READ_ONLY);
+ withExposedPorts(5432);
+ if (IntegrationTestEnvironment.getInstance().getItEnvType() == ITEnvTypeEnum.LOCAL) {
+ addFixedExposedPort(5432, 5432);
+ }
+ }
+
+ @Override
+ public String getJdbcUrl(final String host, final int port, final String databaseName) {
+ return DataSourceEnvironment.getURL(DATABASE_TYPE, host, port, databaseName);
+ }
+
+ @Override
+ public int getPort() {
+ return 5432;
+ }
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/proxy/JDBCConnectionWaitStrategy.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/proxy/JDBCConnectionWaitStrategy.java
new file mode 100644
index 00000000000..bb9005dc49e
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/proxy/JDBCConnectionWaitStrategy.java
@@ -0,0 +1,50 @@
+/*
+ * 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.integration.data.pipeline.container.proxy;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.rnorth.ducttape.unreliables.Unreliables;
+import org.testcontainers.containers.wait.strategy.AbstractWaitStrategy;
+
+import java.sql.Connection;
+import java.util.concurrent.Callable;
+import java.util.concurrent.TimeUnit;
+
+@Slf4j
+@RequiredArgsConstructor
+public final class JDBCConnectionWaitStrategy extends AbstractWaitStrategy {
+
+ private final Callable<Connection> connectionSupplier;
+
+ @Override
+ protected void waitUntilReady() {
+ Unreliables.retryUntilSuccess((int) startupTimeout.getSeconds(), TimeUnit.SECONDS, () -> {
+ getRateLimiter().doWhenReady(() -> {
+ try (Connection unused = connectionSupplier.call()) {
+ log.info("Container ready");
+ // CHECKSTYLE:OFF
+ } catch (final Exception ex) {
+ // CHECKSTYLE:ON
+ throw new RuntimeException("Not Ready yet.", ex);
+ }
+ });
+ return true;
+ });
+ }
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/proxy/ShardingSphereProxyDockerContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/proxy/ShardingSphereProxyDockerContainer.java
similarity index 52%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/proxy/ShardingSphereProxyDockerContainer.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/proxy/ShardingSphereProxyDockerContainer.java
index 9df79bef2eb..6d3fd52f1ab 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/proxy/ShardingSphereProxyDockerContainer.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/proxy/ShardingSphereProxyDockerContainer.java
@@ -15,21 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.container.proxy;
+package org.apache.shardingsphere.integration.data.pipeline.container.proxy;
-import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.integration.data.pipeline.env.IntegrationTestEnvironment;
+import org.apache.shardingsphere.integration.data.pipeline.env.enums.ITEnvTypeEnum;
+import org.apache.shardingsphere.integration.data.pipeline.util.DatabaseTypeUtil;
import org.apache.shardingsphere.test.integration.env.DataSourceEnvironment;
import org.apache.shardingsphere.test.integration.framework.container.atomic.DockerITContainer;
-import org.rnorth.ducttape.unreliables.Unreliables;
import org.testcontainers.containers.BindMode;
-import org.testcontainers.containers.wait.strategy.AbstractWaitStrategy;
-import java.sql.Connection;
import java.sql.DriverManager;
-import java.util.concurrent.Callable;
-import java.util.concurrent.TimeUnit;
/**
* ShardingSphere proxy container.
@@ -47,34 +44,22 @@ public final class ShardingSphereProxyDockerContainer extends DockerITContainer
@Override
protected void configure() {
mapConfigurationFiles();
- withExposedPorts(3307);
- setWaitStrategy(new JDBCConnectionWaitStrategy(() -> DriverManager.getConnection(DataSourceEnvironment.getURL(databaseType, getHost(), getMappedPort(3307), ""), "root", "root")));
+ if (DatabaseTypeUtil.isPostgreSQL(databaseType)) {
+ setWaitStrategy(new JDBCConnectionWaitStrategy(() -> DriverManager.getConnection(DataSourceEnvironment.getURL(databaseType, getHost(), getMappedPort(3307), "postgres"), "root", "root")));
+ } else {
+ setWaitStrategy(new JDBCConnectionWaitStrategy(() -> DriverManager.getConnection(DataSourceEnvironment.getURL(databaseType, getHost(), getMappedPort(3307), ""), "root", "root")));
+ }
}
private void mapConfigurationFiles() {
- withClasspathResourceMapping("/env/conf/", "/opt/shardingsphere-proxy/conf", BindMode.READ_ONLY);
- }
-
- @Slf4j
- @RequiredArgsConstructor
- private static class JDBCConnectionWaitStrategy extends AbstractWaitStrategy {
-
- private final Callable<Connection> connectionSupplier;
-
- @Override
- protected void waitUntilReady() {
- Unreliables.retryUntilSuccess((int) startupTimeout.getSeconds(), TimeUnit.SECONDS, () -> {
- getRateLimiter().doWhenReady(() -> {
- try (Connection unused = connectionSupplier.call()) {
- log.info("Container ready");
- // CHECKSTYLE:OFF
- } catch (final Exception ex) {
- // CHECKSTYLE:ON
- throw new RuntimeException("Not Ready yet.", ex);
- }
- });
- return true;
- });
+ // TODO PostgreSQL JDBC create databases not success, use config file instead. need to fix it.
+ if (DatabaseTypeUtil.isPostgreSQL(databaseType)) {
+ withClasspathResourceMapping("/env/postgresql/config-sharding.yaml", "/opt/shardingsphere-proxy/conf/config-sharding.yaml", BindMode.READ_ONLY);
+ }
+ withClasspathResourceMapping(String.format("/env/%s/server.yaml", databaseType.getName().toLowerCase()), "/opt/shardingsphere-proxy/conf/server.yaml", BindMode.READ_ONLY);
+ if (IntegrationTestEnvironment.getInstance().getItEnvType() == ITEnvTypeEnum.LOCAL) {
+ addFixedExposedPort(3307, 3307);
+ addFixedExposedPort(3308, 5005);
}
}
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/proxy/ShardingSphereProxyLocalContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/proxy/ShardingSphereProxyLocalContainer.java
similarity index 81%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/proxy/ShardingSphereProxyLocalContainer.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/proxy/ShardingSphereProxyLocalContainer.java
index 432dec82f0c..3c74921c3a5 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/proxy/ShardingSphereProxyLocalContainer.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/container/proxy/ShardingSphereProxyLocalContainer.java
@@ -15,12 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.container.proxy;
+package org.apache.shardingsphere.integration.data.pipeline.container.proxy;
import lombok.Getter;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.integration.data.pipeline.util.DatabaseTypeUtil;
import org.apache.shardingsphere.proxy.backend.config.ProxyConfigurationLoader;
import org.apache.shardingsphere.proxy.backend.config.YamlProxyConfiguration;
import org.apache.shardingsphere.proxy.frontend.ShardingSphereProxy;
@@ -35,18 +36,22 @@ import java.util.concurrent.TimeUnit;
@Slf4j
@Getter
-public class ShardingSphereProxyLocalContainer {
-
- private final String serverList;
+public final class ShardingSphereProxyLocalContainer {
private final DatabaseType databaseType;
+ private final String defaultDatabaseName;
+
private volatile boolean started;
@SneakyThrows
- public ShardingSphereProxyLocalContainer(final String serverList, final DatabaseType databaseType) {
- this.serverList = serverList;
+ public ShardingSphereProxyLocalContainer(final DatabaseType databaseType) {
this.databaseType = databaseType;
+ if (DatabaseTypeUtil.isPostgreSQL(databaseType)) {
+ defaultDatabaseName = "postgres";
+ } else {
+ defaultDatabaseName = "";
+ }
}
/**
@@ -57,7 +62,7 @@ public class ShardingSphereProxyLocalContainer {
@SneakyThrows
public void waitProxyStarted(final DatabaseType databaseType) {
for (int retry = 0; retry < 60; retry++) {
- try (Connection connection = DriverManager.getConnection(DataSourceEnvironment.getURL(databaseType, "localhost", 3307, ""), "root", "root")) {
+ try (Connection connection = DriverManager.getConnection(DataSourceEnvironment.getURL(databaseType, "localhost", 3307, defaultDatabaseName), "root", "root")) {
log.info("Container ready");
started = true;
return;
@@ -73,7 +78,6 @@ public class ShardingSphereProxyLocalContainer {
/**
* Start proxy.
*/
- @SneakyThrows
public void start() {
if (started) {
return;
@@ -84,8 +88,8 @@ public class ShardingSphereProxyLocalContainer {
}
new Thread(() -> {
try {
- YamlProxyConfiguration yamlConfig = ProxyConfigurationLoader.load("/env/conf");
- yamlConfig.getServerConfiguration().getMode().getRepository().getProps().setProperty("server-lists", serverList);
+ YamlProxyConfiguration yamlConfig = ProxyConfigurationLoader.load(String.format("/env/%s", databaseType.getName().toLowerCase()));
+ yamlConfig.getServerConfiguration().getMode().getRepository().getProps().setProperty("server-lists", "localhost:2181");
new BootstrapInitializer().init(yamlConfig, 3307);
new ShardingSphereProxy().start(3307);
} catch (final IOException | SQLException ex) {
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/ITEnvironmentContext.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/ITEnvironmentContext.java
similarity index 91%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/ITEnvironmentContext.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/ITEnvironmentContext.java
index fb8db92a097..0fa33438045 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/ITEnvironmentContext.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/ITEnvironmentContext.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.env;
+package org.apache.shardingsphere.integration.data.pipeline.env;
import com.google.gson.Gson;
import lombok.Getter;
@@ -25,10 +25,10 @@ import org.apache.shardingsphere.data.pipeline.api.config.rulealtered.PipelineCo
import org.apache.shardingsphere.data.pipeline.api.datasource.config.PipelineDataSourceConfiguration;
import org.apache.shardingsphere.data.pipeline.api.datasource.config.yaml.YamlPipelineDataSourceConfiguration;
import org.apache.shardingsphere.data.pipeline.core.datasource.PipelineDataSourceFactory;
-import org.apache.shardingsphere.integration.data.pipline.env.cases.DataSet;
-import org.apache.shardingsphere.integration.data.pipline.env.cases.Type;
-import org.apache.shardingsphere.integration.data.pipline.env.config.SourceConfiguration;
-import org.apache.shardingsphere.integration.data.pipline.env.config.TargetConfiguration;
+import org.apache.shardingsphere.integration.data.pipeline.env.cases.DataSet;
+import org.apache.shardingsphere.integration.data.pipeline.env.cases.Type;
+import org.apache.shardingsphere.integration.data.pipeline.env.config.SourceConfiguration;
+import org.apache.shardingsphere.integration.data.pipeline.env.config.TargetConfiguration;
import org.apache.shardingsphere.sharding.yaml.config.rule.YamlTableRuleConfiguration;
import javax.sql.DataSource;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/IntegrationTestEnvironment.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/IntegrationTestEnvironment.java
similarity index 86%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/IntegrationTestEnvironment.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/IntegrationTestEnvironment.java
index 6218197a0e0..0d13a64dc54 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/IntegrationTestEnvironment.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/IntegrationTestEnvironment.java
@@ -15,10 +15,11 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.env;
+package org.apache.shardingsphere.integration.data.pipeline.env;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.integration.data.pipeline.env.enums.ITEnvTypeEnum;
import java.io.IOException;
import java.io.InputStream;
@@ -32,11 +33,11 @@ public final class IntegrationTestEnvironment {
private final Properties props;
- private final String itEnvType;
+ private final ITEnvTypeEnum itEnvType;
private IntegrationTestEnvironment() {
props = loadProperties();
- itEnvType = props.getProperty("it.env.type");
+ itEnvType = ITEnvTypeEnum.valueOf(props.getProperty("it.env.type", ITEnvTypeEnum.DOCKER.name()).toUpperCase());
}
private Properties loadProperties() {
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/cases/DataSet.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/cases/DataSet.java
similarity index 94%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/cases/DataSet.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/cases/DataSet.java
index 81d85910364..c96f1172cc9 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/cases/DataSet.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/cases/DataSet.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.env.cases;
+package org.apache.shardingsphere.integration.data.pipeline.env.cases;
import lombok.Getter;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/cases/Type.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/cases/Type.java
similarity index 96%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/cases/Type.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/cases/Type.java
index 3e060f1668e..3c037b57664 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/cases/Type.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/cases/Type.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.env.cases;
+package org.apache.shardingsphere.integration.data.pipeline.env.cases;
import lombok.Getter;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/config/SourceConfiguration.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/config/SourceConfiguration.java
similarity index 96%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/config/SourceConfiguration.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/config/SourceConfiguration.java
index dc6a6d7abe6..01f83e442be 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/config/SourceConfiguration.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/config/SourceConfiguration.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.env.config;
+package org.apache.shardingsphere.integration.data.pipeline.env.config;
import lombok.SneakyThrows;
import org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
import org.apache.shardingsphere.infra.yaml.config.swapper.YamlDataSourceConfigurationSwapper;
import org.apache.shardingsphere.infra.yaml.config.swapper.YamlRuleConfigurationSwapperEngine;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
-import org.apache.shardingsphere.integration.data.pipline.env.IntegrationTestEnvironment;
+import org.apache.shardingsphere.integration.data.pipeline.env.IntegrationTestEnvironment;
import org.apache.shardingsphere.data.pipeline.api.datasource.config.impl.ShardingSpherePipelineDataSourceConfiguration;
import org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.yaml.config.rule.YamlTableRuleConfiguration;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/config/TargetConfiguration.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/config/TargetConfiguration.java
similarity index 92%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/config/TargetConfiguration.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/config/TargetConfiguration.java
index 478ca2b7c45..8a76e3c794b 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/config/TargetConfiguration.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/config/TargetConfiguration.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.env.config;
+package org.apache.shardingsphere.integration.data.pipeline.env.config;
import org.apache.shardingsphere.data.pipeline.api.datasource.config.impl.StandardPipelineDataSourceConfiguration;
-import org.apache.shardingsphere.integration.data.pipline.env.IntegrationTestEnvironment;
+import org.apache.shardingsphere.integration.data.pipeline.env.IntegrationTestEnvironment;
import java.util.Properties;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/enums/ITEnvTypeEnum.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/enums/ITEnvTypeEnum.java
similarity index 92%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/enums/ITEnvTypeEnum.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/enums/ITEnvTypeEnum.java
index d19990e83c0..f2fe273bf45 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/enums/ITEnvTypeEnum.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/env/enums/ITEnvTypeEnum.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.env.enums;
+package org.apache.shardingsphere.integration.data.pipeline.env.enums;
public enum ITEnvTypeEnum {
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/factory/DatabaseContainerFactory.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/factory/DatabaseContainerFactory.java
similarity index 82%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/factory/DatabaseContainerFactory.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/factory/DatabaseContainerFactory.java
index e5f3653de95..be3f62fa79f 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/factory/DatabaseContainerFactory.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/factory/DatabaseContainerFactory.java
@@ -15,14 +15,14 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.factory;
+package org.apache.shardingsphere.integration.data.pipeline.factory;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.integration.data.pipline.container.database.DockerDatabaseContainer;
-import org.apache.shardingsphere.integration.data.pipline.container.database.MySQLContainer;
-import org.apache.shardingsphere.integration.data.pipline.container.database.PostgreSQLContainer;
+import org.apache.shardingsphere.integration.data.pipeline.container.database.DockerDatabaseContainer;
+import org.apache.shardingsphere.integration.data.pipeline.container.database.MySQLContainer;
+import org.apache.shardingsphere.integration.data.pipeline.container.database.PostgreSQLContainer;
/**
* Storage container factory.
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/fixture/DataImporter.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/fixture/DataImporter.java
similarity index 90%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/fixture/DataImporter.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/fixture/DataImporter.java
index 55248ddb573..9e7e24f8138 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/fixture/DataImporter.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/fixture/DataImporter.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.fixture;
+package org.apache.shardingsphere.integration.data.pipeline.fixture;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.integration.data.pipline.env.ITEnvironmentContext;
-import org.apache.shardingsphere.integration.data.pipline.env.cases.DataSet;
-import org.apache.shardingsphere.integration.data.pipline.env.cases.Type;
+import org.apache.shardingsphere.integration.data.pipeline.env.ITEnvironmentContext;
+import org.apache.shardingsphere.integration.data.pipeline.env.cases.DataSet;
+import org.apache.shardingsphere.integration.data.pipeline.env.cases.Type;
import javax.sql.DataSource;
import java.sql.Connection;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/database/PostgreSQLContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/DatabaseTypeUtil.java
similarity index 56%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/database/PostgreSQLContainer.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/DatabaseTypeUtil.java
index d2c7d264e22..15823601d41 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/database/PostgreSQLContainer.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/DatabaseTypeUtil.java
@@ -15,24 +15,29 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.container.database;
+package org.apache.shardingsphere.integration.data.pipeline.util;
-import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
-// TODO not complete yet
-public class PostgreSQLContainer extends DockerDatabaseContainer {
+public final class DatabaseTypeUtil {
- public PostgreSQLContainer(final String dockerImageName) {
- super(DatabaseTypeRegistry.getActualDatabaseType("PostgreSQL"), dockerImageName);
+ /**
+ * Check MySQL database type.
+ *
+ * @param databaseType database type
+ * @return true if database type is MySQL, false otherwise
+ */
+ public static boolean isMySQL(final DatabaseType databaseType) {
+ return databaseType.getName().equals("MySQL");
}
- @Override
- public void start() {
-
- }
-
- @Override
- public int getPort() {
- return 5432;
+ /**
+ * Check PostgreSQL database type.
+ *
+ * @param databaseType database type
+ * @return true if database type is PostgreSQL, false otherwise
+ */
+ public static boolean isPostgreSQL(final DatabaseType databaseType) {
+ return databaseType.getName().equals("PostgreSQL");
}
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/util/ExecuteUtil.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/ExecuteUtil.java
similarity index 95%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/util/ExecuteUtil.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/ExecuteUtil.java
index 882f497b604..764e5bde899 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/util/ExecuteUtil.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/ExecuteUtil.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.util;
+package org.apache.shardingsphere.integration.data.pipeline.util;
import lombok.RequiredArgsConstructor;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/util/Executor.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/Executor.java
similarity index 93%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/util/Executor.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/Executor.java
index 99241539caa..c019ede1545 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/util/Executor.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/Executor.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.util;
+package org.apache.shardingsphere.integration.data.pipeline.util;
/**
* Executor.
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/util/ScalingUtil.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/ScalingUtil.java
similarity index 97%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/util/ScalingUtil.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/ScalingUtil.java
index d1015aca84a..aa18c183def 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/util/ScalingUtil.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/ScalingUtil.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.util;
+package org.apache.shardingsphere.integration.data.pipeline.util;
import com.google.gson.JsonElement;
import lombok.AccessLevel;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/util/TableCrudUtil.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/TableCrudUtil.java
similarity index 72%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/util/TableCrudUtil.java
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/TableCrudUtil.java
index d0479014354..0099eac29c7 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/util/TableCrudUtil.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/TableCrudUtil.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipline.util;
+package org.apache.shardingsphere.integration.data.pipeline.util;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.shardingsphere.sharding.algorithm.keygen.SnowflakeKeyGenerateAlgorithm;
@@ -34,12 +34,12 @@ public final class TableCrudUtil {
private static final ThreadLocalRandom RANDOM = ThreadLocalRandom.current();
/**
- * Generate insert data.
+ * Generate MySQL insert data.
*
* @param insertRows insert rows
* @return insert data list
*/
- public static Pair<List<Object[]>, List<Object[]>> generateInsertDataList(final int insertRows) {
+ public static Pair<List<Object[]>, List<Object[]>> generateMySQLInsertDataList(final int insertRows) {
if (insertRows < 0) {
return Pair.of(null, null);
}
@@ -56,7 +56,7 @@ public final class TableCrudUtil {
}
/**
- * Generate simple insert data.
+ * Generate MySQL simple insert data.
*
* @return insert data
*/
@@ -66,4 +66,22 @@ public final class TableCrudUtil {
int userId = RANDOM.nextInt(0, 5);
return Pair.of(new Object[]{uniqueKey, orderId, userId}, new Object[]{uniqueKey, orderId, userId, "OK"});
}
+
+ /**
+ * Generate PostgreSQL simple insert data.
+ *
+ * @param insertRows insert rows
+ * @return insert data
+ */
+ public static Pair<List<Object[]>, List<Object[]>> generatePostgresSQLInsertDataList(final int insertRows) {
+ List<Object[]> orderData = new ArrayList<>(insertRows);
+ List<Object[]> orderItemData = new ArrayList<>(insertRows);
+ for (int i = 1; i <= insertRows; i++) {
+ int orderId = RANDOM.nextInt(0, 5);
+ int userId = RANDOM.nextInt(0, 5);
+ orderData.add(new Object[]{SNOWFLAKE_GENERATE.generateKey(), orderId, userId, "OK"});
+ orderItemData.add(new Object[]{SNOWFLAKE_GENERATE.generateKey(), orderId, userId, "SUCCESS"});
+ }
+ return Pair.of(orderData, orderItemData);
+ }
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/mysql/BaseMySQLScalingCase.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/mysql/BaseMySQLScalingCase.java
deleted file mode 100644
index 8411bfaaeb4..00000000000
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/mysql/BaseMySQLScalingCase.java
+++ /dev/null
@@ -1,47 +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.integration.data.pipline.cases.mysql;
-
-import lombok.Getter;
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
-import org.apache.shardingsphere.integration.data.pipline.cases.BaseScalingITCase;
-import org.apache.shardingsphere.integration.data.pipline.cases.command.CreateTableSQLCommand;
-import org.apache.shardingsphere.integration.data.pipline.util.TableCrudUtil;
-
-import javax.xml.bind.JAXB;
-import java.util.List;
-
-public abstract class BaseMySQLScalingCase extends BaseScalingITCase {
-
- @Getter
- private final CreateTableSQLCommand createTableSQLCommand;
-
- public BaseMySQLScalingCase() {
- super(new MySQLDatabaseType());
- createTableSQLCommand = JAXB.unmarshal(BaseMySQLScalingCase.class.getClassLoader().getResource("env/mysql/sql.xml"), CreateTableSQLCommand.class);
- }
-
- protected void initTableAndData() {
- getJdbcTemplate().execute(createTableSQLCommand.getCreateTableOrder());
- getJdbcTemplate().execute(createTableSQLCommand.getCreateTableOrderItem());
- Pair<List<Object[]>, List<Object[]>> dataPair = TableCrudUtil.generateInsertDataList(3000);
- getJdbcTemplate().batchUpdate(getCommonSQLCommand().getInsertOrder(), dataPair.getLeft());
- getJdbcTemplate().batchUpdate(getCommonSQLCommand().getInsertOrderItem(), dataPair.getRight());
- }
-}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/database/MySQLContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/database/MySQLContainer.java
deleted file mode 100644
index 27633810b29..00000000000
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/database/MySQLContainer.java
+++ /dev/null
@@ -1,43 +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.integration.data.pipline.container.database;
-
-import com.google.common.collect.Lists;
-import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
-import org.testcontainers.containers.BindMode;
-
-public class MySQLContainer extends DockerDatabaseContainer {
-
- public MySQLContainer(final String dockerImageName) {
- super(DatabaseTypeRegistry.getActualDatabaseType("MySQL"), dockerImageName);
- }
-
- @Override
- protected void configure() {
- super.configure();
- withClasspathResourceMapping("/env/mysql/my.cnf", "/etc/mysql/my.cnf", BindMode.READ_ONLY);
- withExposedPorts(3306);
- setEnv(Lists.newArrayList("LANG=C.UTF-8", "MYSQL_ROOT_PASSWORD=root", "MYSQL_ROOT_HOST=%", "MYSQL_DATABASE=test"));
- withCommand("--sql_mode=", "--default-authentication-plugin=mysql_native_password", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci");
- }
-
- @Override
- public int getPort() {
- return 3306;
- }
-}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/common/command.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/common/command.xml
index 525f3e23fc4..0d29f7a8b1f 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/common/command.xml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/common/command.xml
@@ -16,23 +16,6 @@
-->
<command>
- <create-database>
- CREATE DATABASE sharding_db
- </create-database>
-
- <use-database>
- USE sharding_db
- </use-database>
-
- <add-resource>
- ADD RESOURCE ds_%s (URL="jdbc:mysql://%s/%s?serverTimezone=UTC&useSSL=false&rewriteBatchedStatements=true",USER=root,PASSWORD=root)
- </add-resource>
-
- <create-sharding-algorithm>
- CREATE SHARDING ALGORITHM t_order_item_inline (
- TYPE(NAME=INLINE,PROPERTIES("algorithm-expression"="t_order_item_${order_id % 2}")))
- </create-sharding-algorithm>
-
<create-sharding-algorithm>
CREATE SHARDING ALGORITHM database_inline (
TYPE(NAME=INLINE,PROPERTIES("algorithm-expression"="ds_${user_id % 2}")))
@@ -43,6 +26,11 @@
TYPE(NAME=INLINE,PROPERTIES("algorithm-expression"="t_order_${order_id % 2}")))
</create-sharding-algorithm>
+ <create-sharding-algorithm>
+ CREATE SHARDING ALGORITHM t_order_item_inline (
+ TYPE(NAME=INLINE,PROPERTIES("algorithm-expression"="t_order_item_${order_id % 2}")))
+ </create-sharding-algorithm>
+
<create-sharding-table>
CREATE SHARDING TABLE RULE t_order (
DATANODES("ds_${0..1}.t_order_${0..1}"),
@@ -99,7 +87,7 @@
</stop-scaling-source-writing>
<check-scaling-data-match>
- CHECK SCALING %s BY TYPE (NAME=CRC32_MATCH)
+ CHECK SCALING %s BY TYPE (NAME=DATA_MATCH)
</check-scaling-data-match>
<apply-scaling>
@@ -120,25 +108,6 @@
)
</auto-alter-table-rule>
- <insert-order>
- INSERT INTO t_order (
- id,
- order_id,
- user_id,
- t_varchar,
- t_tinyint,
- t_timestamp,
- t_datetime,
- t_binary,
- t_blob,
- t_decimal,
- t_char,
- t_double,
- t_json
- )
- VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)
- </insert-order>
-
<simple-insert-order>
INSERT INTO t_order ( id, order_id, user_id) VALUES (?, ?, ?)
</simple-insert-order>
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/it-env.properties b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/it-env.properties
index ebe37095f63..ebc7d0d82a6 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/it-env.properties
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/it-env.properties
@@ -16,10 +16,4 @@
#
# it.env.type=DOCKER,LOCAL
-it.env.type=LOCAL
-
-# it.cluster.databases=MySQL,PostgreSQL
-it.env.databases=MySQL
-
-scaling.waitMs=5000
-scaling.retry=30
+it.env.type=DOCKER
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/server.yaml
similarity index 98%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/conf/server.yaml
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/server.yaml
index ce314b28fa3..efd945d94cc 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/server.yaml
@@ -40,5 +40,5 @@ props:
kernel-executor-size: 16 # Infinite by default.
proxy-frontend-flush-threshold: 128 # The default value is 128.
proxy-hint-enabled: true
- sql-show: false
+ sql-show: true
sql-federation-enabled: true
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/sql.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/sql.xml
index 3692ac35dbf..c73a3989e82 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/sql.xml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/sql.xml
@@ -44,4 +44,31 @@
PRIMARY KEY (item_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
</create-table-order-item>
+
+ <use-database>
+ USE sharding_db
+ </use-database>
+
+ <add-resource>
+ ADD RESOURCE %s (URL='jdbc:mysql://%s/%s?serverTimezone=UTC&useSSL=false&rewriteBatchedStatements=true',USER=root,PASSWORD=root)
+ </add-resource>
+
+ <insert-order>
+ INSERT INTO t_order (
+ id,
+ order_id,
+ user_id,
+ t_varchar,
+ t_tinyint,
+ t_timestamp,
+ t_datetime,
+ t_binary,
+ t_blob,
+ t_decimal,
+ t_char,
+ t_double,
+ t_json
+ )
+ VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)
+ </insert-order>
</command>
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/postgresql/initdb.sql b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/postgresql/initdb.sql
index e3b8a181bea..7f0804f516e 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/postgresql/initdb.sql
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/postgresql/initdb.sql
@@ -14,3 +14,9 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
+
+CREATE DATABASE ds_0;
+CREATE DATABASE ds_1;
+CREATE DATABASE ds_2;
+CREATE DATABASE ds_3;
+CREATE DATABASE ds_4;
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/it-env.properties b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/postgresql/postgresql.conf
similarity index 84%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/it-env.properties
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/postgresql/postgresql.conf
index ebe37095f63..b5a012ced29 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/it-env.properties
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/postgresql/postgresql.conf
@@ -15,11 +15,8 @@
# limitations under the License.
#
-# it.env.type=DOCKER,LOCAL
-it.env.type=LOCAL
-
-# it.cluster.databases=MySQL,PostgreSQL
-it.env.databases=MySQL
-
-scaling.waitMs=5000
-scaling.retry=30
+wal_level = logical
+max_replication_slots = 10
+log_timezone = 'Asia/Shanghai'
+datestyle = 'iso, mdy'
+timezone = 'Asia/Shanghai'
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/postgresql/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/postgresql/server.yaml
new file mode 100644
index 00000000000..408a839bd0c
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/postgresql/server.yaml
@@ -0,0 +1,60 @@
+#
+# 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.
+#
+
+mode:
+ type: Cluster
+ repository:
+ type: ZooKeeper
+ props:
+ namespace: it_pgdb
+ server-lists: zk.host:2181
+ retryIntervalMilliseconds: 500
+ timeToLiveSeconds: 60
+ maxRetries: 3
+ operationTimeoutMilliseconds: 500
+ overwrite: true
+
+rules:
+ - !AUTHORITY
+ users:
+ - root@%:root
+ - sharding@:sharding
+ provider:
+ type: ALL_PRIVILEGES_PERMITTED
+
+props:
+ max-connections-size-per-query: 1
+ kernel-executor-size: 16 # Infinite by default.
+ proxy-frontend-flush-threshold: 128 # The default value is 128.
+ proxy-hint-enabled: false
+ sql-show: true
+ check-table-metadata-enabled: false
+ show-process-list-enabled: false
+ # Proxy backend query fetch size. A larger value may increase the memory usage of ShardingSphere Proxy.
+ # The default value is -1, which means set the minimum value for different JDBC drivers.
+ proxy-backend-query-fetch-size: -1
+ check-duplicate-table-enabled: false
+ proxy-frontend-executor-size: 0 # Proxy frontend executor size. The default value is 0, which means let Netty decide.
+ # Available options of proxy backend executor suitable: OLAP(default), OLTP. The OLTP option may reduce time cost of writing packets to client, but it may increase the latency of SQL execution
+ # and block other clients if client connections are more than `proxy-frontend-executor-size`, especially executing slow SQL.
+ proxy-backend-executor-suitable: OLAP
+ proxy-frontend-max-connections: 0 # Less than or equal to 0 means no limitation.
+ sql-federation-enabled: false
+ # Available proxy backend driver type: JDBC (default), ExperimentalVertx
+ proxy-backend-driver-type: JDBC
+ proxy-mysql-default-version: 5.7.22 # In the absence of schema name, the default version will be used.
+ proxy-frontend-database-protocol-type: PostgreSQL
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/sql.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/postgresql/sql.xml
similarity index 56%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/sql.xml
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/postgresql/sql.xml
index 3692ac35dbf..b3d9ef873f7 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/sql.xml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/postgresql/sql.xml
@@ -16,32 +16,30 @@
-->
<command>
<create-table-order>
- CREATE TABLE `t_order` (
- `id` BIGINT NOT NULL COMMENT 'pk id',
- `order_id` INT NOT NULL,
- `user_id` INT NOT NULL,
- `t_varchar` VARCHAR ( 255 ) NULL,
- `t_tinyint` TINYINT ( 1 ) NULL,
- `t_timestamp` TIMESTAMP NULL,
- `t_datetime` datetime NULL ON UPDATE CURRENT_TIMESTAMP,
- `t_binary` BINARY(255) NULL,
- `t_blob` BLOB NULL,
- `t_decimal` DECIMAL ( 10, 2 ) NULL,
- `t_char` CHAR ( 128 ) NULL,
- `t_double` DOUBLE NULL,
- `t_json` json NULL COMMENT 'json test',
- PRIMARY KEY ( `id` ),
- INDEX ( `order_id` )
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+ CREATE TABLE t_order (
+ id int8 NOT NULL,
+ order_id int4 NOT NULL,
+ user_id int NOT NULL,
+ t_varchar varchar(50) DEFAULT NULL,
+ PRIMARY KEY (id)
+ )
</create-table-order>
<create-table-order-item>
CREATE TABLE t_order_item (
- item_id bigint NOT NULL,
- order_id int NOT NULL,
- user_id int NOT NULL,
- status varchar(50) DEFAULT NULL,
+ item_id int8 NOT NULL,
+ order_id int4 NOT NULL,
+ user_id int8 NOT NULL,
+ status varchar(50),
PRIMARY KEY (item_id)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+ )
</create-table-order-item>
+
+ <add-resource>
+ ADD RESOURCE %s (URL="jdbc:postgresql://%s/%s?serverTimezone=UTC&useSSL=false",USER=root,PASSWORD=root)
+ </add-resource>
+
+ <insert-order>
+ INSERT INTO t_order(id, order_id, user_id, t_varchar) VALUES (?, ?, ?, ?)
+ </insert-order>
</command>