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 a36962be657 Improve migration IT table name (#21071)
a36962be657 is described below
commit a36962be657176867d57195b8ea3951455fe3fbc
Author: Xinze Guo <[email protected]>
AuthorDate: Tue Sep 20 19:33:42 2022 +0800
Improve migration IT table name (#21071)
* Improve migration IT table name
* Fix codestyle
* Fix codestyle
---
.../data/pipeline/cases/base/BaseITCase.java | 14 +++++--
.../cases/migration/AbstractMigrationITCase.java | 24 ++++-------
.../migration/general/MySQLMigrationGeneralIT.java | 15 ++++---
.../general/PostgreSQLMigrationGeneralIT.java | 17 +++++---
.../primarykey/TextPrimaryKeyMigrationIT.java | 14 +++++--
.../pipeline/cases/task/MySQLIncrementTask.java | 12 +++---
.../cases/task/PostgreSQLIncrementTask.java | 8 ++--
.../data/pipeline/command/ExtraSQLCommand.java | 27 ++++++++++++-
.../pipeline/command/MigrationDistSQLCommand.java | 46 ++++++++++++++++------
.../common/{command.xml => migration-command.xml} | 24 +++--------
.../test/resources/env/scenario/general/mysql.xml | 4 +-
.../resources/env/scenario/general/postgresql.xml | 4 +-
.../primary_key/text_primary_key/mysql.xml | 2 +-
.../primary_key/text_primary_key/postgresql.xml | 2 +-
14 files changed, 131 insertions(+), 82 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 1b19f43cd99..bc6af3f4258 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
@@ -189,20 +189,26 @@ public abstract class BaseITCase {
return DataSourceEnvironment.getURL(getDatabaseType(), "127.0.0.1",
ENV.getActualDataSourceDefaultPort(databaseType), databaseName);
}
+ protected abstract String getSourceTableOrderName();
+
+ protected String getTargetTableOrderName() {
+ return "t_order";
+ }
+
protected void createSourceOrderTable() throws SQLException {
- sourceExecuteWithLog(extraSQLCommand.getCreateTableOrder());
+
sourceExecuteWithLog(getExtraSQLCommand().getCreateTableOrder(getSourceTableOrderName()));
}
protected void createSourceTableIndexList(final String schema) throws
SQLException {
if (DatabaseTypeUtil.isPostgreSQL(getDatabaseType())) {
- sourceExecuteWithLog(String.format("CREATE INDEX IF NOT EXISTS
idx_user_id ON %s.t_order_copy ( user_id )", schema));
+ sourceExecuteWithLog(String.format("CREATE INDEX IF NOT EXISTS
idx_user_id ON %s.%s ( user_id )", schema, getSourceTableOrderName()));
} else if (DatabaseTypeUtil.isOpenGauss(getDatabaseType())) {
- sourceExecuteWithLog(String.format("CREATE INDEX idx_user_id ON
%s.t_order_copy ( user_id )", schema));
+ sourceExecuteWithLog(String.format("CREATE INDEX idx_user_id ON
%s.%s ( user_id )", schema, getSourceTableOrderName()));
}
}
protected void createSourceCommentOnList(final String schema) throws
SQLException {
- sourceExecuteWithLog(String.format("COMMENT ON COLUMN
%s.t_order_copy.user_id IS 'user id'", schema));
+ sourceExecuteWithLog(String.format("COMMENT ON COLUMN %s.%s.user_id IS
'user id'", schema, getSourceTableOrderName()));
}
protected void createSourceOrderItemTable() throws SQLException {
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/migration/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
index 4020697b47c..157131a2b2f 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/migration/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
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.integration.data.pipeline.cases.migration;
+import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.data.pipeline.api.job.JobStatus;
import org.apache.shardingsphere.data.pipeline.core.util.ThreadUtil;
@@ -42,11 +43,12 @@ import static org.junit.Assert.assertTrue;
@Slf4j
public abstract class AbstractMigrationITCase extends BaseITCase {
+ @Getter
private final MigrationDistSQLCommand migrationDistSQLCommand;
public AbstractMigrationITCase(final ScalingParameterized parameterized) {
super(parameterized);
- migrationDistSQLCommand =
JAXB.unmarshal(Objects.requireNonNull(BaseITCase.class.getClassLoader().getResource("env/common/command.xml")),
MigrationDistSQLCommand.class);
+ migrationDistSQLCommand =
JAXB.unmarshal(Objects.requireNonNull(BaseITCase.class.getClassLoader().getResource("env/common/migration-command.xml")),
MigrationDistSQLCommand.class);
}
protected void addMigrationSourceResource() throws SQLException {
@@ -105,24 +107,12 @@ public abstract class AbstractMigrationITCase extends
BaseITCase {
proxyExecuteWithLog(migrationDistSQLCommand.getCreateTargetOrderItemTableRule(),
2);
}
- protected void startMigrationOrderCopy(final boolean withSchema) throws
SQLException {
- if (withSchema) {
-
proxyExecuteWithLog(migrationDistSQLCommand.getMigrationOrderCopySingleTableWithSchema(),
4);
- } else {
-
proxyExecuteWithLog(migrationDistSQLCommand.getMigrationOrderCopySingleTable(),
4);
- }
- }
-
- protected void startMigrationOrder() throws SQLException {
-
proxyExecuteWithLog(migrationDistSQLCommand.getMigrationOrderSingleTable(), 1);
+ protected void startMigration(final String sourceTableName, final String
targetTableName) throws SQLException {
+
proxyExecuteWithLog(migrationDistSQLCommand.getMigrationSingleTable(sourceTableName,
targetTableName), 1);
}
- protected void startMigrationOrderItem(final boolean withSchema) throws
SQLException {
- if (withSchema) {
-
proxyExecuteWithLog(migrationDistSQLCommand.getMigrationOrderItemSingleTableWithSchema(),
1);
- } else {
-
proxyExecuteWithLog(migrationDistSQLCommand.getMigrationOrderItemSingleTable(),
1);
- }
+ protected void startMigrationWithSchema(final String sourceTableName,
final String targetTableName) throws SQLException {
+
proxyExecuteWithLog(migrationDistSQLCommand.getMigrationSingleTableWithSchema(sourceTableName,
targetTableName), 1);
}
protected void addMigrationProcessConfig() throws SQLException {
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/migration/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
index aa6c80cf62b..e817099770b 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/migration/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
@@ -72,6 +72,11 @@ public final class MySQLMigrationGeneralIT extends
AbstractMigrationITCase {
return result;
}
+ @Override
+ protected String getSourceTableOrderName() {
+ return "t_order_copy";
+ }
+
@Test
public void assertMigrationSuccess() throws SQLException,
InterruptedException {
addMigrationProcessConfig();
@@ -86,13 +91,13 @@ public final class MySQLMigrationGeneralIT extends
AbstractMigrationITCase {
JdbcTemplate jdbcTemplate = new JdbcTemplate(getSourceDataSource());
Pair<List<Object[]>, List<Object[]>> dataPair =
ScalingCaseHelper.generateFullInsertData(keyGenerateAlgorithm,
parameterized.getDatabaseType(), 3000);
log.info("init data begin: {}", LocalDateTime.now());
- jdbcTemplate.batchUpdate(getExtraSQLCommand().getFullInsertOrder(),
dataPair.getLeft());
+
jdbcTemplate.batchUpdate(getExtraSQLCommand().getFullInsertOrder(getSourceTableOrderName()),
dataPair.getLeft());
jdbcTemplate.batchUpdate(getExtraSQLCommand().getFullInsertOrderItem(),
dataPair.getRight());
log.info("init data end: {}", LocalDateTime.now());
- startMigrationOrderCopy(false);
- startMigrationOrderItem(false);
- startIncrementTask(new MySQLIncrementTask(jdbcTemplate,
keyGenerateAlgorithm, 30));
- String orderJobId = getJobIdByTableName("t_order_copy");
+ startMigration(getSourceTableOrderName(), getTargetTableOrderName());
+ startMigration("t_order_item", "t_order_item");
+ startIncrementTask(new MySQLIncrementTask(jdbcTemplate,
getSourceTableOrderName(), keyGenerateAlgorithm, 30));
+ String orderJobId = getJobIdByTableName(getSourceTableOrderName());
String orderItemJobId = getJobIdByTableName("t_order_item");
assertMigrationSuccessById(orderJobId);
assertMigrationSuccessById(orderItemJobId);
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/migration/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
index 5733d614f5b..8c89cdf0628 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/migration/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
@@ -59,6 +59,11 @@ public final class PostgreSQLMigrationGeneralIT extends
AbstractMigrationITCase
log.info("parameterized:{}", parameterized);
}
+ @Override
+ protected String getSourceTableOrderName() {
+ return "t_order_copy";
+ }
+
@Parameters(name = "{0}")
public static Collection<ScalingParameterized> getParameters() {
Collection<ScalingParameterized> result = new LinkedList<>();
@@ -88,7 +93,7 @@ public final class PostgreSQLMigrationGeneralIT extends
AbstractMigrationITCase
createTargetOrderItemTableRule();
Pair<List<Object[]>, List<Object[]>> dataPair =
ScalingCaseHelper.generateFullInsertData(KEY_GENERATE_ALGORITHM,
parameterized.getDatabaseType(), TABLE_INIT_ROW_COUNT);
JdbcTemplate jdbcTemplate = new JdbcTemplate(getSourceDataSource());
- jdbcTemplate.batchUpdate(getExtraSQLCommand().getFullInsertOrder(),
dataPair.getLeft());
+
jdbcTemplate.batchUpdate(getExtraSQLCommand().getFullInsertOrder(getSourceTableOrderName()),
dataPair.getLeft());
jdbcTemplate.batchUpdate(getExtraSQLCommand().getFullInsertOrderItem(),
dataPair.getRight());
checkOrderMigration(jdbcTemplate);
checkOrderItemMigration();
@@ -103,12 +108,12 @@ public final class PostgreSQLMigrationGeneralIT extends
AbstractMigrationITCase
}
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");
+ startMigrationWithSchema(getSourceTableOrderName(), "t_order");
+ startIncrementTask(new PostgreSQLIncrementTask(jdbcTemplate,
SCHEMA_NAME, getSourceTableOrderName(), false, 20));
+ String jobId = getJobIdByTableName(getSourceTableOrderName());
waitJobFinished(String.format("SHOW MIGRATION STATUS '%s'", jobId));
stopMigrationByJobId(jobId);
- sourceExecuteWithLog(String.format("INSERT INTO %s.t_order_copy
(order_id,user_id,status) VALUES (%s, %s, '%s')", SCHEMA_NAME,
KEY_GENERATE_ALGORITHM.generateKey(),
+ sourceExecuteWithLog(String.format("INSERT INTO %s.%s
(order_id,user_id,status) VALUES (%s, %s, '%s')", SCHEMA_NAME,
getSourceTableOrderName(), KEY_GENERATE_ALGORITHM.generateKey(),
1, "afterStop"));
startMigrationByJobId(jobId);
assertCheckMigrationSuccess(jobId, "DATA_MATCH");
@@ -116,7 +121,7 @@ public final class PostgreSQLMigrationGeneralIT extends
AbstractMigrationITCase
}
private void checkOrderItemMigration() throws SQLException,
InterruptedException {
- startMigrationOrderItem(true);
+ startMigrationWithSchema("t_order_item", "t_order_item");
String jobId = getJobIdByTableName("t_order_item");
waitJobFinished(String.format("SHOW MIGRATION STATUS '%s'", jobId));
assertCheckMigrationSuccess(jobId, "DATA_MATCH");
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/migration/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
index d1ee2aad484..f06b4624061 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/migration/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
@@ -51,6 +51,14 @@ public class TextPrimaryKeyMigrationIT extends
AbstractMigrationITCase {
log.info("parameterized:{}", parameterized);
}
+ @Override
+ protected String getSourceTableOrderName() {
+ if (DatabaseTypeUtil.isMySQL(getDatabaseType())) {
+ return "T_ORDER";
+ }
+ return "t_order";
+ }
+
@Parameters(name = "{0}")
public static Collection<ScalingParameterized> getParameters() {
Collection<ScalingParameterized> result = new LinkedList<>();
@@ -78,10 +86,10 @@ public class TextPrimaryKeyMigrationIT extends
AbstractMigrationITCase {
addMigrationSourceResource();
addMigrationTargetResource();
createTargetOrderTableRule();
- startMigrationOrder();
+ startMigration(getSourceTableOrderName(), getTargetTableOrderName());
String jobId = listJobId().get(0);
waitJobFinished(String.format("SHOW MIGRATION STATUS '%s'", jobId));
- sourceExecuteWithLog(String.format("INSERT INTO t_order
(order_id,user_id,status) VALUES (%s, %s, '%s')", "1000000000", 1,
"afterStop"));
+ sourceExecuteWithLog(String.format("INSERT INTO %s
(order_id,user_id,status) VALUES (%s, %s, '%s')", getSourceTableOrderName(),
"1000000000", 1, "afterStop"));
// TODO The ordering of primary or unique keys for text types is
different, but can't reproduce now
if (DatabaseTypeUtil.isMySQL(getDatabaseType())) {
assertCheckMigrationSuccess(jobId, "DATA_MATCH");
@@ -99,7 +107,7 @@ 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 (order_id,user_id,status)
VALUES (?,?,?)");
+ PreparedStatement preparedStatement =
connection.prepareStatement(String.format("INSERT INTO %s
(order_id,user_id,status) VALUES (?,?,?)", getSourceTableOrderName()));
for (int i = 0; i < TABLE_INIT_ROW_COUNT * 2; i++) {
preparedStatement.setObject(1,
keyGenerateAlgorithm.generateKey());
preparedStatement.setObject(2,
ThreadLocalRandom.current().nextInt(0, 6));
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 706945a4df3..0992b1c5f97 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
@@ -34,6 +34,8 @@ public final class MySQLIncrementTask extends
BaseIncrementTask {
private final JdbcTemplate jdbcTemplate;
+ private final String orderTableName;
+
private final KeyGenerateAlgorithm primaryKeyGenerateAlgorithm;
private final int executeCountLimit;
@@ -44,7 +46,7 @@ public final class MySQLIncrementTask extends
BaseIncrementTask {
while (executeCount < executeCountLimit &&
!Thread.currentThread().isInterrupted()) {
Object orderPrimaryKey = insertOrder();
if (0 == executeCount % 2) {
- jdbcTemplate.update("DELETE FROM t_order_copy WHERE order_id =
?", orderPrimaryKey);
+ jdbcTemplate.update(String.format("DELETE FROM %s WHERE
order_id = ?", orderTableName), orderPrimaryKey);
} else {
setNullToOrderFields(orderPrimaryKey);
updateOrderByPrimaryKey(orderPrimaryKey);
@@ -60,7 +62,7 @@ public final class MySQLIncrementTask extends
BaseIncrementTask {
ThreadLocalRandom random = ThreadLocalRandom.current();
Object[] orderInsertDate = new
Object[]{primaryKeyGenerateAlgorithm.generateKey(), random.nextInt(0, 6),
random.nextInt(1, 99), RandomStringUtils.randomAlphabetic(10)};
- jdbcTemplate.update("INSERT INTO t_order_copy
(order_id,user_id,t_unsigned_int,status) VALUES (?, ?, ?, ?)", orderInsertDate);
+ jdbcTemplate.update(String.format("INSERT INTO %s
(order_id,user_id,t_unsigned_int,status) VALUES (?, ?, ?, ?)", orderTableName),
orderInsertDate);
return orderInsertDate[0];
}
@@ -74,11 +76,11 @@ public final class MySQLIncrementTask extends
BaseIncrementTask {
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 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);
+ jdbcTemplate.update(String.format("UPDATE %s SET t_char =
?,t_unsigned_int = ? WHERE order_id = ?", orderTableName), updateData);
+ jdbcTemplate.update(String.format("UPDATE %s SET t_char =
null,t_unsigned_int = 299,t_datetime='0000-00-00 00:00:00' WHERE order_id = ?",
orderTableName), primaryKey);
}
private void setNullToOrderFields(final Object primaryKey) {
- jdbcTemplate.update("UPDATE t_order_copy SET t_char = null,
t_unsigned_int = null WHERE order_id = ?", primaryKey);
+ jdbcTemplate.update(String.format("UPDATE %s SET t_char = null,
t_unsigned_int = null WHERE order_id = ?", orderTableName), 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 2836e84ff6e..a30ea237fef 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
@@ -40,6 +40,8 @@ public final class PostgreSQLIncrementTask extends
BaseIncrementTask {
private final String schema;
+ private final String orderTableName;
+
private final boolean incrementOrderItemTogether;
private final int executeCountLimit;
@@ -56,7 +58,7 @@ public final class PostgreSQLIncrementTask extends
BaseIncrementTask {
while (executeCount < executeCountLimit &&
!Thread.currentThread().isInterrupted()) {
Object orderId = insertOrder();
if (0 == executeCount % 2) {
- jdbcTemplate.update(prefixSchema("DELETE FROM
${schema}t_order_copy WHERE order_id = ?", schema), orderId);
+ jdbcTemplate.update(String.format(prefixSchema("DELETE FROM
${schema}%s WHERE order_id = ?", schema), orderTableName), orderId);
} else {
updateOrderByPrimaryKey(orderId);
}
@@ -74,7 +76,7 @@ public final class PostgreSQLIncrementTask extends
BaseIncrementTask {
ThreadLocalRandom random = ThreadLocalRandom.current();
String status = 0 == random.nextInt() % 2 ? null : "NOT-NULL";
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);
+ jdbcTemplate.update(String.format(prefixSchema("INSERT INTO
${schema}%s (order_id,user_id,status) VALUES (?, ?, ?)", schema),
orderTableName), orderInsertDate);
return orderInsertDate[0];
}
@@ -88,7 +90,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 order_id = ?", schema), updateData);
+ jdbcTemplate.update(String.format(prefixSchema("UPDATE ${schema}%s 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/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
index f1cfe64e08f..53c233e8161 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/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
@@ -17,14 +17,15 @@
package org.apache.shardingsphere.integration.data.pipeline.command;
-import lombok.Data;
+import lombok.Getter;
+import lombok.Setter;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-@Data
+@Setter
@XmlRootElement(name = "command")
@XmlAccessorType(XmlAccessType.FIELD)
public final class ExtraSQLCommand {
@@ -33,11 +34,33 @@ public final class ExtraSQLCommand {
private String createTableOrder;
@XmlElement(name = "create-table-order-item")
+ @Getter
private String createTableOrderItem;
@XmlElement(name = "full-insert-order")
private String fullInsertOrder;
@XmlElement(name = "full-insert-order-item")
+ @Getter
private String fullInsertOrderItem;
+
+ /**
+ * Get full insert order sql.
+ *
+ * @param orderTableName order table name
+ * @return migration single table DistSQL
+ */
+ public String getFullInsertOrder(final String orderTableName) {
+ return String.format(fullInsertOrder, orderTableName);
+ }
+
+ /**
+ * Get create table order.
+ *
+ * @param orderTableName order table name
+ * @return Get create table order sql
+ */
+ public String getCreateTableOrder(final String orderTableName) {
+ return String.format(createTableOrder, orderTableName);
+ }
}
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/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
index 726a7d2eaed..009aaa9de15 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/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
@@ -17,48 +17,68 @@
package org.apache.shardingsphere.integration.data.pipeline.command;
-import lombok.Data;
+import lombok.Getter;
+import lombok.Setter;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-@Data
+@Setter
@XmlRootElement(name = "command")
@XmlAccessorType(XmlAccessType.FIELD)
public final class MigrationDistSQLCommand {
@XmlElement(name = "add-migration-process-config")
+ @Getter
private String addMigrationProcessConfig;
@XmlElement(name = "create-target-order-table-encrypt-rule")
+ @Getter
private String createTargetOrderTableEncryptRule;
@XmlElement(name = "create-target-order-table-rule")
+ @Getter
private String createTargetOrderTableRule;
@XmlElement(name = "create-target-order-item-table-rule")
+ @Getter
private String createTargetOrderItemTableRule;
@XmlElement(name = "add-migration-source-resource-template")
+ @Getter
private String addMigrationSourceResourceTemplate;
@XmlElement(name = "add-migration-target-resource-template")
+ @Getter
private String addMigrationTargetResourceTemplate;
- @XmlElement(name = "migration-order-single-table")
- private String migrationOrderSingleTable;
+ @XmlElement(name = "migration-single-table")
+ private String migrationSingleTable;
- @XmlElement(name = "migration-order-copy-single-table")
- private String migrationOrderCopySingleTable;
+ @XmlElement(name = "migration-single-table-with-schema")
+ private String migrationSingleTableWithSchema;
- @XmlElement(name = "migration-order-copy-single-table-with-schema")
- private String migrationOrderCopySingleTableWithSchema;
+ /**
+ * Get migration single table DistSQL.
+ *
+ * @param sourceTableName source table name
+ * @param targetTableName target table name
+ * @return migration single table DistSQL
+ */
+ public String getMigrationSingleTable(final String sourceTableName, final
String targetTableName) {
+ return String.format(migrationSingleTable, sourceTableName,
targetTableName);
+ }
- @XmlElement(name = "migration-order-item-single-table")
- private String migrationOrderItemSingleTable;
-
- @XmlElement(name = "migration-order-item-single-table-with-schema")
- private String migrationOrderItemSingleTableWithSchema;
+ /**
+ * Get migration single table DistSQL with schema.
+ *
+ * @param sourceTableName source table name
+ * @param targetTableName target table name
+ * @return migration single table DistSQL
+ */
+ public String getMigrationSingleTableWithSchema(final String
sourceTableName, final String targetTableName) {
+ return String.format(migrationSingleTableWithSchema, sourceTableName,
targetTableName);
+ }
}
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/migration-command.xml
similarity index 78%
rename from
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/common/command.xml
rename to
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/common/migration-command.xml
index 6944f9100da..d60833a6c74 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/migration-command.xml
@@ -81,23 +81,11 @@
);
</create-target-order-item-table-rule>
- <migration-order-copy-single-table>
- MIGRATE TABLE ds_0.t_order_copy INTO sharding_db.t_order;
- </migration-order-copy-single-table>
+ <migration-single-table>
+ MIGRATE TABLE ds_0.%s INTO sharding_db.%s;
+ </migration-single-table>
- <migration-order-copy-single-table-with-schema>
- MIGRATE TABLE ds_0.test.t_order_copy INTO sharding_db.t_order;
- </migration-order-copy-single-table-with-schema>
-
- <migration-order-single-table>
- MIGRATE TABLE ds_0.t_order INTO sharding_db.t_order;
- </migration-order-single-table>
-
- <migration-order-item-single-table>
- MIGRATE TABLE ds_0.t_order_item INTO sharding_db.t_order_item;
- </migration-order-item-single-table>
-
- <migration-order-item-single-table-with-schema>
- MIGRATE TABLE ds_0.test.t_order_item INTO sharding_db.t_order_item;
- </migration-order-item-single-table-with-schema>
+ <migration-single-table-with-schema>
+ MIGRATE TABLE ds_0.test.%s INTO sharding_db.%s;
+ </migration-single-table-with-schema>
</command>
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 2232e32e946..0616067201e 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
@@ -16,7 +16,7 @@
-->
<command>
<create-table-order>
- CREATE TABLE `t_order_copy` (
+ CREATE TABLE `%s` (
`order_id` bigint NOT NULL,
`user_id` int NOT NULL,
`status` varchar ( 255 ) NULL,
@@ -64,7 +64,7 @@
<full-insert-order>
INSERT INTO
-
t_order_copy(order_id,user_id,status,t_mediumint,t_smallint,t_tinyint,t_unsigned_int,t_unsigned_mediumint,
+
%s(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
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 6750229124a..0d99e0c15a5 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
@@ -16,7 +16,7 @@
-->
<command>
<create-table-order>
- CREATE TABLE test.t_order_copy (
+ CREATE TABLE test.%s (
order_id int8 NOT NULL,
user_id int4 NOT NULL,
status varchar ( 50 ) NULL,
@@ -55,7 +55,7 @@
<full-insert-order>
INSERT INTO
-
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)
+
test.%s(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>
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/primary_key/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
index 2f11d6c54d8..b1376db0482 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/primary_key/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
@@ -16,7 +16,7 @@
-->
<command>
<create-table-order>
- CREATE TABLE `T_ORDER` (
+ CREATE TABLE `%s` (
`order_id` varchar(255) NOT NULL COMMENT 'pk id',
`user_id` INT NOT NULL,
`status` varchar(255) NULL,
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/primary_key/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
index 15407f049f2..5136e364fc5 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/primary_key/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
@@ -16,7 +16,7 @@
-->
<command>
<create-table-order>
- CREATE TABLE t_order (
+ CREATE TABLE %s (
order_id varchar(255) NOT NULL,
user_id int NOT NULL,
status varchar(255) NULL,