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 19b7f1e09a8 Improve migration IT case (#20835)
19b7f1e09a8 is described below
commit 19b7f1e09a86da6728e996c24d3a779947be13c2
Author: Xinze Guo <[email protected]>
AuthorDate: Wed Sep 7 10:36:57 2022 +0800
Improve migration IT case (#20835)
* Move package and rename some IT cases
* Remove unused id
* Fix ci error
---
.../data/pipeline/cases/base/BaseITCase.java | 59 +++++++++++-------
.../CreateTableSQLGeneratorIT.java | 8 +--
.../AbstractMigrationITCase.java | 72 ++++++++++------------
.../general/MySQLMigrationGeneralIT.java | 25 ++++----
.../general/PostgreSQLMigrationGeneralIT.java | 25 ++++----
.../primarykey/TextPrimaryKeyMigrationIT.java | 19 +++---
.../pipeline/cases/task/MySQLIncrementTask.java | 14 ++---
.../cases/task/PostgreSQLIncrementTask.java | 12 ++--
.../{cases => }/command/ExtraSQLCommand.java | 2 +-
.../command/MigrationDistSQLCommand.java | 2 +-
.../CreateTableSQLGeneratorAssertionEntity.java | 2 +-
...reateTableSQLGeneratorAssertionsRootEntity.java | 2 +-
.../entity/CreateTableSQLGeneratorInputEntity.java | 2 +-
.../CreateTableSQLGeneratorOutputEntity.java | 2 +-
.../framework/helper/ScalingCaseHelper.java | 14 ++---
.../AutoIncrementKeyGenerateAlgorithm.java} | 37 +++++------
.../test/resources/env/scenario/general/mysql.xml | 9 ++-
.../resources/env/scenario/general/postgresql.xml | 7 +--
.../text_primary_key/mysql.xml | 7 +--
.../text_primary_key/postgresql.xml | 9 ++-
20 files changed, 164 insertions(+), 165 deletions(-)
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java
index 40cd2c1e3cc..eee2f9b9698 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java
@@ -21,10 +21,13 @@ import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
+import org.apache.shardingsphere.data.pipeline.api.job.JobStatus;
import org.apache.shardingsphere.data.pipeline.core.util.ThreadUtil;
+import org.apache.shardingsphere.infra.database.metadata.url.JdbcUrlAppender;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import
org.apache.shardingsphere.integration.data.pipeline.cases.command.ExtraSQLCommand;
+import
org.apache.shardingsphere.integration.data.pipeline.command.ExtraSQLCommand;
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.framework.container.compose.BaseContainerComposer;
@@ -38,7 +41,6 @@ import
org.apache.shardingsphere.test.integration.env.container.atomic.util.Data
import
org.apache.shardingsphere.test.integration.env.container.atomic.util.StorageContainerUtil;
import
org.apache.shardingsphere.test.integration.env.runtime.DataSourceEnvironment;
import org.junit.Rule;
-import org.opengauss.util.PSQLException;
import javax.sql.DataSource;
import javax.xml.bind.JAXB;
@@ -50,13 +52,18 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.Properties;
+import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@Slf4j
@@ -160,6 +167,15 @@ public abstract class BaseITCase {
proxyExecuteWithLog(distSQL, 2);
}
+ protected String appendBatchInsertParam(final String jdbcUrl) {
+ if (DatabaseTypeUtil.isMySQL(getDatabaseType())) {
+ Properties addProps = new Properties();
+ addProps.setProperty("rewriteBatchedStatements", "true");
+ return new JdbcUrlAppender().appendQueryProperties(jdbcUrl,
addProps);
+ }
+ return jdbcUrl;
+ }
+
protected String getActualJdbcUrlTemplate(final String databaseName, final
boolean isInContainer) {
if (ITEnvTypeEnum.DOCKER == ENV.getItEnvType()) {
DockerStorageContainer storageContainer =
((DockerContainerComposer) containerComposer).getStorageContainer();
@@ -192,25 +208,6 @@ public abstract class BaseITCase {
sourceExecuteWithLog(extraSQLCommand.getCreateTableOrderItem());
}
- protected void createSourceSchema(final String schemaName) throws
SQLException {
- if (DatabaseTypeUtil.isPostgreSQL(databaseType)) {
- sourceExecuteWithLog(String.format("CREATE SCHEMA IF NOT EXISTS
%s", schemaName));
- return;
- }
- if (DatabaseTypeUtil.isOpenGauss(databaseType)) {
- try {
- sourceExecuteWithLog(String.format("CREATE SCHEMA %s",
schemaName));
- } catch (final SQLException ex) {
- // only used for native mode.
- if (ex instanceof PSQLException &&
"42P06".equals(ex.getSQLState())) {
- log.info("Schema {} already exists.", schemaName);
- } else {
- throw ex;
- }
- }
- }
- }
-
protected void sourceExecuteWithLog(final String sql) throws SQLException {
log.info("source execute :{}", sql);
try (Connection connection = sourceDataSource.getConnection()) {
@@ -267,6 +264,26 @@ public abstract class BaseITCase {
getIncreaseTaskThread().start();
}
+ protected void waitJobFinished(final String distSQL) throws
InterruptedException {
+ if (null != getIncreaseTaskThread()) {
+ TimeUnit.SECONDS.timedJoin(getIncreaseTaskThread(), 60);
+ }
+ Set<String> actualStatus;
+ for (int i = 0; i < 10; i++) {
+ List<Map<String, Object>> listJobStatus =
queryForListWithLog(distSQL);
+ log.info("show status result: {}", listJobStatus);
+ actualStatus = listJobStatus.stream().map(each ->
each.get("status").toString()).collect(Collectors.toSet());
+ assertFalse(CollectionUtils.containsAny(actualStatus,
Arrays.asList(JobStatus.PREPARING_FAILURE.name(),
JobStatus.EXECUTE_INVENTORY_TASK_FAILURE.name(),
+ JobStatus.EXECUTE_INCREMENTAL_TASK_FAILURE.name())));
+ if (actualStatus.size() == 1 &&
actualStatus.contains(JobStatus.EXECUTE_INCREMENTAL_TASK.name())) {
+ break;
+ } else if (actualStatus.size() >= 1 &&
actualStatus.containsAll(new HashSet<>(Arrays.asList("",
JobStatus.EXECUTE_INCREMENTAL_TASK.name())))) {
+ log.warn("one of the shardingItem was not started correctly");
+ }
+ ThreadUtil.sleep(3, TimeUnit.SECONDS);
+ }
+ }
+
protected void assertGreaterThanOrderTableInitRows(final int
tableInitRows, final String schema) throws SQLException {
proxyExecuteWithLog("REFRESH TABLE METADATA", 2);
String countSQL = StringUtils.isBlank(schema) ? "SELECT COUNT(*) as
count FROM t_order" : String.format("SELECT COUNT(*) as count FROM %s.t_order",
schema);
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/CreateTableSQLGeneratorIT.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/createtable/CreateTableSQLGeneratorIT.java
similarity index 95%
rename from
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/CreateTableSQLGeneratorIT.java
rename to
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/createtable/CreateTableSQLGeneratorIT.java
index 98cbe05e557..738d642963f 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/CreateTableSQLGeneratorIT.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/createtable/CreateTableSQLGeneratorIT.java
@@ -15,15 +15,15 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipeline.cases.general;
+package org.apache.shardingsphere.integration.data.pipeline.cases.createtable;
import
org.apache.shardingsphere.data.pipeline.spi.ddlgenerator.CreateTableSQLGeneratorFactory;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import
org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
import
org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
-import
org.apache.shardingsphere.integration.data.pipeline.cases.entity.CreateTableSQLGeneratorAssertionEntity;
-import
org.apache.shardingsphere.integration.data.pipeline.cases.entity.CreateTableSQLGeneratorAssertionsRootEntity;
-import
org.apache.shardingsphere.integration.data.pipeline.cases.entity.CreateTableSQLGeneratorOutputEntity;
+import
org.apache.shardingsphere.integration.data.pipeline.entity.CreateTableSQLGeneratorAssertionEntity;
+import
org.apache.shardingsphere.integration.data.pipeline.entity.CreateTableSQLGeneratorAssertionsRootEntity;
+import
org.apache.shardingsphere.integration.data.pipeline.entity.CreateTableSQLGeneratorOutputEntity;
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.framework.param.ScalingParameterized;
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/AbstractMigrationITCase.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/migration/AbstractMigrationITCase.java
similarity index 77%
rename from
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/AbstractMigrationITCase.java
rename to
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/migration/AbstractMigrationITCase.java
index 9aeb09de62f..4b7487773bc 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/AbstractMigrationITCase.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/migration/AbstractMigrationITCase.java
@@ -15,30 +15,27 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipeline.cases.base;
+package org.apache.shardingsphere.integration.data.pipeline.cases.migration;
-import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections4.CollectionUtils;
import org.apache.shardingsphere.data.pipeline.api.job.JobStatus;
import org.apache.shardingsphere.data.pipeline.core.util.ThreadUtil;
-import
org.apache.shardingsphere.integration.data.pipeline.cases.command.MigrationDistSQLCommand;
+import
org.apache.shardingsphere.integration.data.pipeline.cases.base.BaseITCase;
+import
org.apache.shardingsphere.integration.data.pipeline.command.MigrationDistSQLCommand;
import
org.apache.shardingsphere.integration.data.pipeline.env.enums.ITEnvTypeEnum;
import
org.apache.shardingsphere.integration.data.pipeline.framework.param.ScalingParameterized;
+import
org.apache.shardingsphere.test.integration.env.container.atomic.util.DatabaseTypeUtil;
+import org.opengauss.util.PSQLException;
import javax.xml.bind.JAXB;
import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@@ -62,21 +59,40 @@ public abstract class AbstractMigrationITCase extends
BaseITCase {
}
String addSourceResource =
migrationDistSQLCommand.getAddMigrationSourceResourceTemplate().replace("${user}",
getUsername())
.replace("${password}", getPassword())
- .replace("${ds0}", getActualJdbcUrlTemplate(DS_0, true));
+ .replace("${ds0}",
appendBatchInsertParam(getActualJdbcUrlTemplate(DS_0, true)));
addResource(addSourceResource);
}
protected void addMigrationTargetResource() throws SQLException {
String addTargetResource =
migrationDistSQLCommand.getAddMigrationTargetResourceTemplate().replace("${user}",
getUsername())
.replace("${password}", getPassword())
- .replace("${ds2}", getActualJdbcUrlTemplate(DS_2, true))
- .replace("${ds3}", getActualJdbcUrlTemplate(DS_3, true))
- .replace("${ds4}", getActualJdbcUrlTemplate(DS_4, true));
+ .replace("${ds2}",
appendBatchInsertParam(getActualJdbcUrlTemplate(DS_2, true)))
+ .replace("${ds3}",
appendBatchInsertParam(getActualJdbcUrlTemplate(DS_3, true)))
+ .replace("${ds4}",
appendBatchInsertParam(getActualJdbcUrlTemplate(DS_4, true)));
addResource(addTargetResource);
List<Map<String, Object>> resources = queryForListWithLog("SHOW
DATABASE RESOURCES from sharding_db");
assertThat(resources.size(), is(3));
}
+ protected void createSourceSchema(final String schemaName) throws
SQLException {
+ if (DatabaseTypeUtil.isPostgreSQL(getDatabaseType())) {
+ sourceExecuteWithLog(String.format("CREATE SCHEMA IF NOT EXISTS
%s", schemaName));
+ return;
+ }
+ if (DatabaseTypeUtil.isOpenGauss(getDatabaseType())) {
+ try {
+ sourceExecuteWithLog(String.format("CREATE SCHEMA %s",
schemaName));
+ } catch (final SQLException ex) {
+ // only used for native mode.
+ if (ex instanceof PSQLException &&
"42P06".equals(ex.getSQLState())) {
+ log.info("Schema {} already exists.", schemaName);
+ } else {
+ throw ex;
+ }
+ }
+ }
+ }
+
protected void createTargetOrderTableRule() throws SQLException {
proxyExecuteWithLog(migrationDistSQLCommand.getCreateTargetOrderTableRule(), 2);
}
@@ -113,7 +129,7 @@ public abstract class AbstractMigrationITCase extends
BaseITCase {
try {
proxyExecuteWithLog(migrationDistSQLCommand.getAddMigrationProcessConfig(), 0);
} catch (final SQLException ex) {
- if ("58000".equals(ex.getSQLState()) ||
"42000".equals(ex.getSQLState())) {
+ if ("58000".equals(ex.getSQLState()) ||
"HY000".equals(ex.getSQLState())) {
log.warn(ex.getMessage());
return;
}
@@ -143,34 +159,8 @@ public abstract class AbstractMigrationITCase extends
BaseITCase {
return jobList.stream().filter(a ->
a.get("tables").toString().equals(tableName)).findFirst().orElseThrow(() -> new
RuntimeException("not find " + tableName + " table")).get("id").toString();
}
- @SneakyThrows(InterruptedException.class)
- protected void waitMigrationFinished(final String jobId) {
- if (null != getIncreaseTaskThread()) {
- TimeUnit.SECONDS.timedJoin(getIncreaseTaskThread(), 60);
- }
- log.info("jobId: {}", jobId);
- Set<String> actualStatus;
- for (int i = 0; i < 10; i++) {
- List<Map<String, Object>> showJobStatusResult =
showJobStatus(jobId);
- log.info("show migration status result: {}", showJobStatusResult);
- actualStatus = showJobStatusResult.stream().map(each ->
each.get("status").toString()).collect(Collectors.toSet());
- assertFalse(CollectionUtils.containsAny(actualStatus,
Arrays.asList(JobStatus.PREPARING_FAILURE.name(),
JobStatus.EXECUTE_INVENTORY_TASK_FAILURE.name(),
- JobStatus.EXECUTE_INCREMENTAL_TASK_FAILURE.name())));
- if (actualStatus.size() == 1 &&
actualStatus.contains(JobStatus.EXECUTE_INCREMENTAL_TASK.name())) {
- break;
- } else if (actualStatus.size() >= 1 &&
actualStatus.containsAll(new HashSet<>(Arrays.asList("",
JobStatus.EXECUTE_INCREMENTAL_TASK.name())))) {
- log.warn("one of the shardingItem was not started correctly");
- }
- ThreadUtil.sleep(3, TimeUnit.SECONDS);
- }
- }
-
- protected List<Map<String, Object>> showJobStatus(final String jobId) {
- return queryForListWithLog(String.format("SHOW MIGRATION STATUS '%s'",
jobId));
- }
-
protected void assertCheckMigrationSuccess(final String jobId) {
- for (int i = 0; i < 10; i++) {
+ for (int i = 0; i < 5; i++) {
if (checkJobIncrementTaskFinished(jobId)) {
break;
}
@@ -186,7 +176,7 @@ public abstract class AbstractMigrationITCase extends
BaseITCase {
}
protected boolean checkJobIncrementTaskFinished(final String jobId) {
- List<Map<String, Object>> listJobStatus = showJobStatus(jobId);
+ List<Map<String, Object>> listJobStatus =
queryForListWithLog(String.format("SHOW MIGRATION STATUS '%s'", jobId));
log.info("list job status result: {}", listJobStatus);
for (Map<String, Object> entry : listJobStatus) {
if
(!JobStatus.EXECUTE_INCREMENTAL_TASK.name().equalsIgnoreCase(entry.get("status").toString()))
{
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/MySQLMigrationGeneralIT.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/migration/general/MySQLMigrationGeneralIT.java
similarity index 82%
rename from
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/MySQLMigrationGeneralIT.java
rename to
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/migration/general/MySQLMigrationGeneralIT.java
index 4912720ffdf..3cfcd013495 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/MySQLMigrationGeneralIT.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/migration/general/MySQLMigrationGeneralIT.java
@@ -15,18 +15,18 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipeline.cases.general;
+package
org.apache.shardingsphere.integration.data.pipeline.cases.migration.general;
-import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
-import
org.apache.shardingsphere.integration.data.pipeline.cases.base.AbstractMigrationITCase;
+import
org.apache.shardingsphere.integration.data.pipeline.cases.migration.AbstractMigrationITCase;
import
org.apache.shardingsphere.integration.data.pipeline.cases.task.MySQLIncrementTask;
import
org.apache.shardingsphere.integration.data.pipeline.env.enums.ITEnvTypeEnum;
import
org.apache.shardingsphere.integration.data.pipeline.framework.helper.ScalingCaseHelper;
import
org.apache.shardingsphere.integration.data.pipeline.framework.param.ScalingParameterized;
-import
org.apache.shardingsphere.sharding.algorithm.keygen.SnowflakeKeyGenerateAlgorithm;
+import
org.apache.shardingsphere.integration.data.pipeline.util.AutoIncrementKeyGenerateAlgorithm;
+import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -70,8 +70,7 @@ public final class MySQLMigrationGeneralIT extends
AbstractMigrationITCase {
}
@Test
- @SneakyThrows
- public void assertMigrationSuccess() {
+ public void assertMigrationSuccess() throws SQLException,
InterruptedException {
addMigrationProcessConfig();
createSourceOrderTable();
createSourceOrderItemTable();
@@ -80,13 +79,11 @@ public final class MySQLMigrationGeneralIT extends
AbstractMigrationITCase {
createTargetOrderTableRule();
createTargetOrderTableEncryptRule();
createTargetOrderItemTableRule();
- SnowflakeKeyGenerateAlgorithm keyGenerateAlgorithm = new
SnowflakeKeyGenerateAlgorithm();
+ KeyGenerateAlgorithm keyGenerateAlgorithm = new
AutoIncrementKeyGenerateAlgorithm();
JdbcTemplate jdbcTemplate = new JdbcTemplate(getSourceDataSource());
- for (int i = 0; i < TABLE_INIT_ROW_COUNT / 1000; i++) {
- Pair<List<Object[]>, List<Object[]>> dataPair =
ScalingCaseHelper.generateFullInsertData(keyGenerateAlgorithm,
parameterized.getDatabaseType(), 1000);
-
jdbcTemplate.batchUpdate(getExtraSQLCommand().getFullInsertOrder(),
dataPair.getLeft());
-
jdbcTemplate.batchUpdate(getExtraSQLCommand().getFullInsertOrderItem(),
dataPair.getRight());
- }
+ Pair<List<Object[]>, List<Object[]>> dataPair =
ScalingCaseHelper.generateFullInsertData(keyGenerateAlgorithm,
parameterized.getDatabaseType(), 3000);
+ jdbcTemplate.batchUpdate(getExtraSQLCommand().getFullInsertOrder(),
dataPair.getLeft());
+
jdbcTemplate.batchUpdate(getExtraSQLCommand().getFullInsertOrderItem(),
dataPair.getRight());
startMigrationOrderCopy(false);
startMigrationOrderItem(false);
startIncrementTask(new MySQLIncrementTask(jdbcTemplate,
keyGenerateAlgorithm, 20));
@@ -104,8 +101,8 @@ public final class MySQLMigrationGeneralIT extends
AbstractMigrationITCase {
assertGreaterThanOrderTableInitRows(TABLE_INIT_ROW_COUNT, "");
}
- private void assertMigrationSuccessById(final String jobId) throws
SQLException {
- waitMigrationFinished(jobId);
+ private void assertMigrationSuccessById(final String jobId) throws
SQLException, InterruptedException {
+ waitJobFinished(String.format("SHOW MIGRATION STATUS '%s'", jobId));
assertCheckMigrationSuccess(jobId);
stopMigrationByJobId(jobId);
}
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/PostgreSQLMigrationGeneralIT.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/migration/general/PostgreSQLMigrationGeneralIT.java
similarity index 85%
rename from
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/PostgreSQLMigrationGeneralIT.java
rename to
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/migration/general/PostgreSQLMigrationGeneralIT.java
index eb2a6c49c2b..81b5bed2ba9 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/PostgreSQLMigrationGeneralIT.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/migration/general/PostgreSQLMigrationGeneralIT.java
@@ -15,19 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipeline.cases.general;
+package
org.apache.shardingsphere.integration.data.pipeline.cases.migration.general;
-import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.Pair;
import
org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
import
org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
-import
org.apache.shardingsphere.integration.data.pipeline.cases.base.AbstractMigrationITCase;
+import
org.apache.shardingsphere.integration.data.pipeline.cases.migration.AbstractMigrationITCase;
import
org.apache.shardingsphere.integration.data.pipeline.cases.task.PostgreSQLIncrementTask;
import
org.apache.shardingsphere.integration.data.pipeline.env.enums.ITEnvTypeEnum;
import
org.apache.shardingsphere.integration.data.pipeline.framework.helper.ScalingCaseHelper;
import
org.apache.shardingsphere.integration.data.pipeline.framework.param.ScalingParameterized;
-import
org.apache.shardingsphere.sharding.algorithm.keygen.SnowflakeKeyGenerateAlgorithm;
+import
org.apache.shardingsphere.integration.data.pipeline.util.AutoIncrementKeyGenerateAlgorithm;
+import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -49,7 +49,7 @@ import static org.junit.Assert.assertThat;
@RunWith(Parameterized.class)
public final class PostgreSQLMigrationGeneralIT extends
AbstractMigrationITCase {
- private static final SnowflakeKeyGenerateAlgorithm KEY_GENERATE_ALGORITHM
= new SnowflakeKeyGenerateAlgorithm();
+ private static final KeyGenerateAlgorithm KEY_GENERATE_ALGORITHM = new
AutoIncrementKeyGenerateAlgorithm();
private final ScalingParameterized parameterized;
@@ -75,8 +75,7 @@ public final class PostgreSQLMigrationGeneralIT extends
AbstractMigrationITCase
}
@Test
- @SneakyThrows
- public void assertMigrationSuccess() {
+ public void assertMigrationSuccess() throws SQLException,
InterruptedException {
addMigrationProcessConfig();
createSourceSchema(SCHEMA_NAME);
createSourceOrderTable();
@@ -103,23 +102,23 @@ public final class PostgreSQLMigrationGeneralIT extends
AbstractMigrationITCase
assertGreaterThanOrderTableInitRows(TABLE_INIT_ROW_COUNT, SCHEMA_NAME);
}
- private void checkOrderMigration(final JdbcTemplate jdbcTemplate) throws
SQLException {
+ private void checkOrderMigration(final JdbcTemplate jdbcTemplate) throws
SQLException, InterruptedException {
startMigrationOrderCopy(true);
startIncrementTask(new PostgreSQLIncrementTask(jdbcTemplate,
SCHEMA_NAME, false, 20));
String jobId = getJobIdByTableName("t_order_copy");
- waitMigrationFinished(jobId);
+ waitJobFinished(String.format("SHOW MIGRATION STATUS '%s'", jobId));
stopMigrationByJobId(jobId);
- sourceExecuteWithLog(String.format("INSERT INTO %s.t_order_copy
(id,order_id,user_id,status) VALUES (%s, %s, %s, '%s')", SCHEMA_NAME,
KEY_GENERATE_ALGORITHM.generateKey(),
- System.currentTimeMillis(), 1, "afterStop"));
+ sourceExecuteWithLog(String.format("INSERT INTO %s.t_order_copy
(order_id,user_id,status) VALUES (%s, %s, '%s')", SCHEMA_NAME,
KEY_GENERATE_ALGORITHM.generateKey(),
+ 1, "afterStop"));
startMigrationByJobId(jobId);
assertCheckMigrationSuccess(jobId);
stopMigrationByJobId(jobId);
}
- private void checkOrderItemMigration() throws SQLException {
+ private void checkOrderItemMigration() throws SQLException,
InterruptedException {
startMigrationOrderItem(true);
String jobId = getJobIdByTableName("t_order_item");
- waitMigrationFinished(jobId);
+ waitJobFinished(String.format("SHOW MIGRATION STATUS '%s'", jobId));
assertCheckMigrationSuccess(jobId);
stopMigrationByJobId(jobId);
}
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/primarykey/TextPrimaryKeyMigrationIT.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/migration/primarykey/TextPrimaryKeyMigrationIT.java
similarity index 88%
rename from
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/primarykey/TextPrimaryKeyMigrationIT.java
rename to
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/migration/primarykey/TextPrimaryKeyMigrationIT.java
index c800bcd3cff..d9d681514d2 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/primarykey/TextPrimaryKeyMigrationIT.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/migration/primarykey/TextPrimaryKeyMigrationIT.java
@@ -15,13 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipeline.cases.primarykey;
+package
org.apache.shardingsphere.integration.data.pipeline.cases.migration.primarykey;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import
org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
import
org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
-import
org.apache.shardingsphere.integration.data.pipeline.cases.base.AbstractMigrationITCase;
+import
org.apache.shardingsphere.integration.data.pipeline.cases.migration.AbstractMigrationITCase;
import
org.apache.shardingsphere.integration.data.pipeline.env.enums.ITEnvTypeEnum;
import
org.apache.shardingsphere.integration.data.pipeline.framework.param.ScalingParameterized;
import
org.apache.shardingsphere.sharding.algorithm.keygen.UUIDKeyGenerateAlgorithm;
@@ -57,19 +57,19 @@ public class TextPrimaryKeyMigrationIT extends
AbstractMigrationITCase {
return result;
}
for (String version : ENV.listDatabaseDockerImageNames(new
MySQLDatabaseType())) {
- result.add(new ScalingParameterized(new MySQLDatabaseType(),
version, "env/scenario/primarykey/text_primary_key/mysql.xml"));
+ result.add(new ScalingParameterized(new MySQLDatabaseType(),
version, "env/scenario/primary_key/text_primary_key/mysql.xml"));
}
for (String version : ENV.listDatabaseDockerImageNames(new
PostgreSQLDatabaseType())) {
- result.add(new ScalingParameterized(new PostgreSQLDatabaseType(),
version, "env/scenario/primarykey/text_primary_key/postgresql.xml"));
+ result.add(new ScalingParameterized(new PostgreSQLDatabaseType(),
version, "env/scenario/primary_key/text_primary_key/postgresql.xml"));
}
for (String version : ENV.listDatabaseDockerImageNames(new
OpenGaussDatabaseType())) {
- result.add(new ScalingParameterized(new OpenGaussDatabaseType(),
version, "env/scenario/primarykey/text_primary_key/postgresql.xml"));
+ result.add(new ScalingParameterized(new OpenGaussDatabaseType(),
version, "env/scenario/primary_key/text_primary_key/postgresql.xml"));
}
return result;
}
@Test
- public void assertTextPrimaryMigrationSuccess() throws SQLException {
+ public void assertTextPrimaryMigrationSuccess() throws SQLException,
InterruptedException {
createSourceOrderTable();
batchInsertOrder();
addMigrationProcessConfig();
@@ -78,7 +78,7 @@ public class TextPrimaryKeyMigrationIT extends
AbstractMigrationITCase {
createTargetOrderTableRule();
startMigrationOrder();
String jobId = listJobId().get(0);
- waitMigrationFinished(jobId);
+ waitJobFinished(String.format("SHOW MIGRATION STATUS '%s'", jobId));
stopMigrationByJobId(jobId);
assertCheckMigrationSuccess(jobId);
if (ENV.getItEnvType() == ITEnvTypeEnum.DOCKER) {
@@ -91,12 +91,11 @@ public class TextPrimaryKeyMigrationIT extends
AbstractMigrationITCase {
private void batchInsertOrder() throws SQLException {
UUIDKeyGenerateAlgorithm keyGenerateAlgorithm = new
UUIDKeyGenerateAlgorithm();
try (Connection connection = getSourceDataSource().getConnection()) {
- PreparedStatement preparedStatement =
connection.prepareStatement("INSERT INTO t_order (id,order_id,user_id,status)
VALUES (?,?,?,?)");
+ PreparedStatement preparedStatement =
connection.prepareStatement("INSERT INTO t_order (order_id,user_id,status)
VALUES (?,?,?)");
for (int i = 0; i < TABLE_INIT_ROW_COUNT; i++) {
preparedStatement.setObject(1,
keyGenerateAlgorithm.generateKey());
preparedStatement.setObject(2,
ThreadLocalRandom.current().nextInt(0, 6));
- preparedStatement.setObject(3,
ThreadLocalRandom.current().nextInt(0, 6));
- preparedStatement.setObject(4, "OK");
+ preparedStatement.setObject(3, "OK");
preparedStatement.addBatch();
}
preparedStatement.executeBatch();
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/task/MySQLIncrementTask.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/task/MySQLIncrementTask.java
index 7cd5035d412..4c6e466aaf6 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/task/MySQLIncrementTask.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/task/MySQLIncrementTask.java
@@ -44,7 +44,7 @@ public final class MySQLIncrementTask extends
BaseIncrementTask {
while (executeCount < executeCountLimit &&
!Thread.currentThread().isInterrupted()) {
Object orderPrimaryKey = insertOrder();
if (executeCount % 2 == 0) {
- jdbcTemplate.update("DELETE FROM t_order_copy WHERE id = ?",
orderPrimaryKey);
+ jdbcTemplate.update("DELETE FROM t_order_copy WHERE order_id =
?", orderPrimaryKey);
} else {
setNullToOrderFields(orderPrimaryKey);
updateOrderByPrimaryKey(orderPrimaryKey);
@@ -58,9 +58,9 @@ public final class MySQLIncrementTask extends
BaseIncrementTask {
private Object insertOrder() {
ThreadLocalRandom random = ThreadLocalRandom.current();
- Object[] orderInsertDate = new
Object[]{primaryKeyGenerateAlgorithm.generateKey(),
ScalingCaseHelper.generateSnowflakeKey(), random.nextInt(0, 6),
+ Object[] orderInsertDate = new
Object[]{primaryKeyGenerateAlgorithm.generateKey(), random.nextInt(0, 6),
random.nextInt(1, 99), RandomStringUtils.randomAlphabetic(10)};
- jdbcTemplate.update("INSERT INTO t_order_copy
(id,order_id,user_id,t_unsigned_int,status) VALUES (?, ?, ?, ?, ?)",
orderInsertDate);
+ jdbcTemplate.update("INSERT INTO t_order_copy
(order_id,user_id,t_unsigned_int,status) VALUES (?, ?, ?, ?)", orderInsertDate);
return orderInsertDate[0];
}
@@ -68,17 +68,17 @@ public final class MySQLIncrementTask extends
BaseIncrementTask {
ThreadLocalRandom random = ThreadLocalRandom.current();
String status = random.nextInt() % 2 == 0 ? null : "NOT-NULL";
Object[] orderInsertItemDate = new
Object[]{primaryKeyGenerateAlgorithm.generateKey(),
ScalingCaseHelper.generateSnowflakeKey(), random.nextInt(0, 6), status};
- jdbcTemplate.update("INSERT INTO
t_order_item(item_id,order_id,user_id,status) VALUES(?,?,?,?)",
orderInsertItemDate);
+ jdbcTemplate.update("INSERT INTO
t_order_item(item_id,order_id,user_id,status) VALUES(?, ?, ?, ?)",
orderInsertItemDate);
return orderInsertItemDate[0];
}
private void updateOrderByPrimaryKey(final Object primaryKey) {
Object[] updateData = {"updated" + Instant.now().getEpochSecond(),
ThreadLocalRandom.current().nextInt(0, 100), primaryKey};
- jdbcTemplate.update("UPDATE t_order_copy SET t_char = ?,t_unsigned_int
= ? WHERE id = ?", updateData);
- jdbcTemplate.update("UPDATE t_order_copy SET t_char =
null,t_unsigned_int = 299,t_datetime='0000-00-00 00:00:00' WHERE id = ?",
primaryKey);
+ jdbcTemplate.update("UPDATE t_order_copy SET t_char = ?,t_unsigned_int
= ? WHERE order_id = ?", updateData);
+ jdbcTemplate.update("UPDATE t_order_copy SET t_char =
null,t_unsigned_int = 299,t_datetime='0000-00-00 00:00:00' WHERE order_id = ?",
primaryKey);
}
private void setNullToOrderFields(final Object primaryKey) {
- jdbcTemplate.update("UPDATE t_order_copy SET t_char = null,
t_unsigned_int = null WHERE id = ?", primaryKey);
+ jdbcTemplate.update("UPDATE t_order_copy SET t_char = null,
t_unsigned_int = null WHERE order_id = ?", primaryKey);
}
}
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/task/PostgreSQLIncrementTask.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/task/PostgreSQLIncrementTask.java
index 25bc7ddb446..e4e4c24a9fc 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/task/PostgreSQLIncrementTask.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/task/PostgreSQLIncrementTask.java
@@ -54,11 +54,11 @@ public final class PostgreSQLIncrementTask extends
BaseIncrementTask {
public void run() {
int executeCount = 0;
while (executeCount < executeCountLimit &&
!Thread.currentThread().isInterrupted()) {
- Object orderPrimaryKey = insertOrder();
+ Object orderId = insertOrder();
if (executeCount % 2 == 0) {
- jdbcTemplate.update(prefixSchema("DELETE FROM
${schema}t_order_copy WHERE id = ?", schema), orderPrimaryKey);
+ jdbcTemplate.update(prefixSchema("DELETE FROM
${schema}t_order_copy WHERE order_id = ?", schema), orderId);
} else {
- updateOrderByPrimaryKey(orderPrimaryKey);
+ updateOrderByPrimaryKey(orderId);
}
if (incrementOrderItemTogether) {
Object orderItemPrimaryKey = insertOrderItem();
@@ -73,8 +73,8 @@ public final class PostgreSQLIncrementTask extends
BaseIncrementTask {
private Object insertOrder() {
ThreadLocalRandom random = ThreadLocalRandom.current();
String status = random.nextInt() % 2 == 0 ? null : "NOT-NULL";
- Object[] orderInsertDate = new
Object[]{KEY_GENERATE_ALGORITHM.generateKey(),
ScalingCaseHelper.generateSnowflakeKey(), random.nextInt(0, 6), status};
- jdbcTemplate.update(prefixSchema("INSERT INTO ${schema}t_order_copy
(id,order_id,user_id,status) VALUES (?, ?, ?, ?)", schema), orderInsertDate);
+ Object[] orderInsertDate = new
Object[]{KEY_GENERATE_ALGORITHM.generateKey(), random.nextInt(0, 6), status};
+ jdbcTemplate.update(prefixSchema("INSERT INTO ${schema}t_order_copy
(order_id,user_id,status) VALUES (?, ?, ?)", schema), orderInsertDate);
return orderInsertDate[0];
}
@@ -88,7 +88,7 @@ public final class PostgreSQLIncrementTask extends
BaseIncrementTask {
private void updateOrderByPrimaryKey(final Object primaryKey) {
Object[] updateData = {"updated" + Instant.now().getEpochSecond(),
primaryKey};
- jdbcTemplate.update(prefixSchema("UPDATE ${schema}t_order_copy SET
status = ? WHERE id = ?", schema), updateData);
+ jdbcTemplate.update(prefixSchema("UPDATE ${schema}t_order_copy SET
status = ? WHERE order_id = ?", schema), updateData);
}
private String prefixSchema(final String sql, final String schema) {
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/command/ExtraSQLCommand.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/command/ExtraSQLCommand.java
similarity index 95%
rename from
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/command/ExtraSQLCommand.java
rename to
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/command/ExtraSQLCommand.java
index 1b3788ca445..f1cfe64e08f 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/command/ExtraSQLCommand.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/command/ExtraSQLCommand.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipeline.cases.command;
+package org.apache.shardingsphere.integration.data.pipeline.command;
import lombok.Data;
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/command/MigrationDistSQLCommand.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/command/MigrationDistSQLCommand.java
similarity index 97%
rename from
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/command/MigrationDistSQLCommand.java
rename to
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/command/MigrationDistSQLCommand.java
index 30b7a9c0b9e..726a7d2eaed 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/command/MigrationDistSQLCommand.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/command/MigrationDistSQLCommand.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipeline.cases.command;
+package org.apache.shardingsphere.integration.data.pipeline.command;
import lombok.Data;
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/entity/CreateTableSQLGeneratorAssertionEntity.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/entity/CreateTableSQLGeneratorAssertionEntity.java
similarity index 95%
rename from
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/entity/CreateTableSQLGeneratorAssertionEntity.java
rename to
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/entity/CreateTableSQLGeneratorAssertionEntity.java
index 16bea459f69..c9005565909 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/entity/CreateTableSQLGeneratorAssertionEntity.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/entity/CreateTableSQLGeneratorAssertionEntity.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipeline.cases.entity;
+package org.apache.shardingsphere.integration.data.pipeline.entity;
import lombok.Getter;
import lombok.Setter;
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/entity/CreateTableSQLGeneratorAssertionsRootEntity.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/entity/CreateTableSQLGeneratorAssertionsRootEntity.java
similarity index 94%
rename from
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/entity/CreateTableSQLGeneratorAssertionsRootEntity.java
rename to
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/entity/CreateTableSQLGeneratorAssertionsRootEntity.java
index 2e1f460b1ed..beeec456f50 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/entity/CreateTableSQLGeneratorAssertionsRootEntity.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/entity/CreateTableSQLGeneratorAssertionsRootEntity.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipeline.cases.entity;
+package org.apache.shardingsphere.integration.data.pipeline.entity;
import lombok.Getter;
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/entity/CreateTableSQLGeneratorInputEntity.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/entity/CreateTableSQLGeneratorInputEntity.java
similarity index 94%
copy from
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/entity/CreateTableSQLGeneratorInputEntity.java
copy to
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/entity/CreateTableSQLGeneratorInputEntity.java
index 02e4d0084c9..f0c2cbb13c9 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/entity/CreateTableSQLGeneratorInputEntity.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/entity/CreateTableSQLGeneratorInputEntity.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipeline.cases.entity;
+package org.apache.shardingsphere.integration.data.pipeline.entity;
import lombok.Getter;
import lombok.Setter;
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/entity/CreateTableSQLGeneratorOutputEntity.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/entity/CreateTableSQLGeneratorOutputEntity.java
similarity index 94%
rename from
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/entity/CreateTableSQLGeneratorOutputEntity.java
rename to
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/entity/CreateTableSQLGeneratorOutputEntity.java
index c366fecd57d..33167ce1cbf 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/entity/CreateTableSQLGeneratorOutputEntity.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/entity/CreateTableSQLGeneratorOutputEntity.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipeline.cases.entity;
+package org.apache.shardingsphere.integration.data.pipeline.entity;
import lombok.Getter;
import lombok.Setter;
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/helper/ScalingCaseHelper.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/helper/ScalingCaseHelper.java
index b0531fb2503..bfd06c3a973 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/helper/ScalingCaseHelper.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/helper/ScalingCaseHelper.java
@@ -51,35 +51,35 @@ public final class ScalingCaseHelper {
/**
* Generate MySQL insert data, contains full fields.
*
- * @param keyGenerateAlgorithm key generate algorithm
+ * @param orderIdGenerate order id generate algorithm
* @param databaseType database type
* @param insertRows insert rows
* @return insert data list
*/
- public static Pair<List<Object[]>, List<Object[]>>
generateFullInsertData(final KeyGenerateAlgorithm keyGenerateAlgorithm, final
DatabaseType databaseType, final int insertRows) {
+ public static Pair<List<Object[]>, List<Object[]>>
generateFullInsertData(final KeyGenerateAlgorithm orderIdGenerate, final
DatabaseType databaseType, final int insertRows) {
if (insertRows < 0) {
return Pair.of(null, null);
}
List<Object[]> orderData = new ArrayList<>(insertRows);
List<Object[]> orderItemData = new ArrayList<>(insertRows);
for (int i = 0; i < insertRows; i++) {
- long orderId = generateSnowflakeKey();
+ Comparable<?> orderId = orderIdGenerate.generateKey();
int userId = generateInt(0, 6);
LocalDateTime now = LocalDateTime.now();
int randomInt = generateInt(-100, 100);
int randomUnsignedInt = generateInt(0, 100);
if (databaseType instanceof MySQLDatabaseType) {
- Object[] addObjs = {keyGenerateAlgorithm.generateKey(),
orderId, userId, generateString(6), randomInt, randomInt, randomInt,
+ Object[] addObjs = {orderId, userId, generateString(6),
randomInt, randomInt, randomInt,
randomUnsignedInt, randomUnsignedInt,
randomUnsignedInt, randomUnsignedInt, generateFloat(), generateDouble(-1000,
100000),
BigDecimal.valueOf(generateDouble(1, 100)), now, now,
now.toLocalDate(), now.toLocalTime(), Year.now().getValue(), "1", "t", "e",
"s", "t", generateString(2),
- generateString(1), generateString(1), "1", "2",
generateJsonString(1024)};
+ generateString(1), generateString(1), "1", "2",
generateJsonString(32)};
orderData.add(addObjs);
} else {
- orderData.add(new Object[]{keyGenerateAlgorithm.generateKey(),
orderId, userId, generateString(6), randomInt,
+ orderData.add(new Object[]{orderId, userId, generateString(6),
randomInt,
BigDecimal.valueOf(generateDouble(1, 100)), true,
generateString(2), generateString(2), generateFloat(),
generateDouble(0, 1000), LocalDateTime.now(),
OffsetDateTime.now()});
}
- orderItemData.add(new Object[]{keyGenerateAlgorithm.generateKey(),
orderId, userId, "SUCCESS"});
+ orderItemData.add(new
Object[]{SNOWFLAKE_KEY_GENERATE_ALGORITHM.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/pipeline/cases/entity/CreateTableSQLGeneratorInputEntity.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/AutoIncrementKeyGenerateAlgorithm.java
similarity index 57%
rename from
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/entity/CreateTableSQLGeneratorInputEntity.java
rename to
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/AutoIncrementKeyGenerateAlgorithm.java
index 02e4d0084c9..9fba5b1d037 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/entity/CreateTableSQLGeneratorInputEntity.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/AutoIncrementKeyGenerateAlgorithm.java
@@ -15,27 +15,28 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.integration.data.pipeline.cases.entity;
+package org.apache.shardingsphere.integration.data.pipeline.util;
-import lombok.Getter;
-import lombok.Setter;
+import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicLong;
-/**
- * Create table sql generator input entity for JAXB.
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@Getter
-@Setter
-public final class CreateTableSQLGeneratorInputEntity {
+public final class AutoIncrementKeyGenerateAlgorithm implements
KeyGenerateAlgorithm {
+
+ private final AtomicLong idGen = new AtomicLong(1);
+
+ @Override
+ public Comparable<?> generateKey() {
+ return idGen.getAndIncrement();
+ }
- @XmlAttribute
- private String table;
+ @Override
+ public Properties getProps() {
+ return null;
+ }
- @XmlElement
- private String sql;
+ @Override
+ public void init(final Properties props) {
+ }
}
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/general/mysql.xml
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/general/mysql.xml
index 3c57a1f9d53..faf322509e3 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/general/mysql.xml
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/general/mysql.xml
@@ -17,7 +17,6 @@
<command>
<create-table-order>
CREATE TABLE `t_order_copy` (
- `id` bigint NOT NULL COMMENT 'pk id',
`order_id` bigint NOT NULL,
`user_id` int NOT NULL,
`status` varchar ( 255 ) NULL,
@@ -47,8 +46,8 @@
`t_enum` enum ('1', '2', '3') NULL,
`t_set` set ('1', '2', '3') NULL,
`t_json` json NULL COMMENT 'json test',
- PRIMARY KEY ( `id` ),
- UNIQUE KEY `unique_key_order_id` (`order_id`)
+ PRIMARY KEY ( `order_id` ),
+ KEY `idx_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
</create-table-order>
@@ -64,11 +63,11 @@
<full-insert-order>
INSERT INTO
-
t_order_copy(id,order_id,user_id,status,t_mediumint,t_smallint,t_tinyint,t_unsigned_int,t_unsigned_mediumint,
+
t_order_copy(order_id,user_id,status,t_mediumint,t_smallint,t_tinyint,t_unsigned_int,t_unsigned_mediumint,
t_unsigned_smallint,t_unsigned_tinyint,t_float,t_double,t_decimal,
t_timestamp,t_datetime,t_date,t_time,t_year,
t_bit,t_binary,t_varbinary,t_blob,t_mediumblob,t_char,t_text,t_mediumtext,t_enum,t_set,
t_json)
VALUES
- (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
+ (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
</full-insert-order>
<full-insert-order-item>
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/general/postgresql.xml
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/general/postgresql.xml
index 668d493f96e..6750229124a 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/general/postgresql.xml
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/general/postgresql.xml
@@ -17,7 +17,6 @@
<command>
<create-table-order>
CREATE TABLE test.t_order_copy (
- id int8 NOT NULL,
order_id int8 NOT NULL,
user_id int4 NOT NULL,
status varchar ( 50 ) NULL,
@@ -36,7 +35,7 @@
t_time TIME NULL,
t_timestmap timestamp NULL,
t_timestamptz timestamptz NULL,
- PRIMARY KEY ( id )
+ PRIMARY KEY ( order_id )
)
</create-table-order>
@@ -56,8 +55,8 @@
<full-insert-order>
INSERT INTO
-
test.t_order_copy(id,order_id,user_id,status,t_int2,t_numeric,t_bool,t_char,t_varchar,t_float,t_double,t_timestmap,t_timestamptz)
- VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)
+
test.t_order_copy(order_id,user_id,status,t_int2,t_numeric,t_bool,t_char,t_varchar,t_float,t_double,t_timestmap,t_timestamptz)
+ VALUES (?,?,?,?,?,?,?,?,?,?,?,?)
</full-insert-order>
<full-insert-order-item>
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/primarykey/text_primary_key/mysql.xml
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/primary_key/text_primary_key/mysql.xml
similarity index 90%
rename from
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/primarykey/text_primary_key/mysql.xml
rename to
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/primary_key/text_primary_key/mysql.xml
index e4842f66c09..2f11d6c54d8 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/primarykey/text_primary_key/mysql.xml
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/primary_key/text_primary_key/mysql.xml
@@ -17,13 +17,12 @@
<command>
<create-table-order>
CREATE TABLE `T_ORDER` (
- `id` varchar(255) NOT NULL COMMENT 'pk id',
- `order_id` INT NOT NULL,
+ `order_id` varchar(255) NOT NULL COMMENT 'pk id',
`user_id` INT NOT NULL,
`status` varchar(255) NULL,
`t_unsigned_int` int UNSIGNED NULL,
- PRIMARY KEY ( `id` ),
- INDEX ( `order_id` )
+ PRIMARY KEY ( `order_id` ),
+ INDEX ( `user_id` )
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
</create-table-order>
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/primarykey/text_primary_key/postgresql.xml
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/primary_key/text_primary_key/postgresql.xml
similarity index 84%
rename from
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/primarykey/text_primary_key/postgresql.xml
rename to
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/primary_key/text_primary_key/postgresql.xml
index 12a3a67eb70..15407f049f2 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/primarykey/text_primary_key/postgresql.xml
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/primary_key/text_primary_key/postgresql.xml
@@ -17,19 +17,18 @@
<command>
<create-table-order>
CREATE TABLE t_order (
- id varchar(255) NOT NULL,
- order_id int4 NOT NULL,
+ order_id varchar(255) NOT NULL,
user_id int NOT NULL,
status varchar(255) NULL,
- PRIMARY KEY (id)
+ PRIMARY KEY (order_id)
)
</create-table-order>
<update-table-order-status>
- UPDATE test.t_order SET status= 'unlock'
+ UPDATE t_order SET status= 'unlock'
</update-table-order-status>
<create-index-status>
- CREATE INDEX "idx_user_status" ON test.t_order ( status )
+ CREATE INDEX "idx_user_status" ON t_order ( status )
</create-index-status>
</command>