You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/04/25 03:17:06 UTC

[shardingsphere] branch master updated: Add scaling increment task at IT Scaling (#17056)

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 0b649b60a7e Add scaling increment task at IT Scaling (#17056)
0b649b60a7e is described below

commit 0b649b60a7e1a94f7804d8a8e4c4f8565f1032dd
Author: azexcy <10...@users.noreply.github.com>
AuthorDate: Mon Apr 25 11:17:02 2022 +0800

    Add scaling increment task at IT Scaling (#17056)
    
    * Add scaling increment task at IT Scaling
    
    * Remove ending symbol
    
    * Use JDBCTemplate simplify code
    
    * Fix checkstyle
---
 .../pom.xml                                        |   8 +-
 .../integration/data/pipline/ScalingIT.java        |  18 ---
 .../data/pipline/cases/BaseScalingITCase.java      |  76 ++++++-------
 .../data/pipline/cases/IncrementTaskRunnable.java  |  76 +++++++++++++
 .../pipline/cases/command/CommonSQLCommand.java    |  24 ++++
 .../pipline/cases/command/mysql/MySQLCommand.java  |   8 +-
 .../pipline/cases/mysql/BaseMySQLScalingCase.java  |  47 ++++++++
 .../cases/mysql/MySQLManualScalingCase.java        | 126 ---------------------
 .../cases/mysql/MySQLManualScalingTest.java        |  61 ++++++++++
 .../container/compose/BaseComposedContainer.java   |   8 +-
 .../container/compose/DockerComposedContainer.java |  19 +++-
 .../container/compose/LocalComposedContainer.java  |  18 ++-
 .../pipline/env/IntegrationTestEnvironment.java    |  37 ++----
 .../data/pipline/util/TableCrudUtil.java           |  69 +++++++++++
 .../src/test/resources/env/common/command.xml      |  73 ++++++++++--
 .../src/test/resources/env/mysql/sql.xml           |  32 +-----
 .../src/test/resources/logback-test.xml            |   4 +-
 17 files changed, 426 insertions(+), 278 deletions(-)

diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/pom.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/pom.xml
index 5eabcfe76df..2174e35d7f9 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/pom.xml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/pom.xml
@@ -57,6 +57,12 @@
             <version>${project.version}</version>
             <type>test-jar</type>
         </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-jdbc</artifactId>
+            <version>${springframework.version}</version>
+            <scope>test</scope>
+        </dependency>
         
         <dependency>
             <groupId>org.apache.commons</groupId>
@@ -67,7 +73,7 @@
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
         </dependency>
-    
+        
         <dependency>
             <groupId>org.testcontainers</groupId>
             <artifactId>testcontainers</artifactId>
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/ScalingIT.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/ScalingIT.java
index eca5f7927ac..cf2ff119f21 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/ScalingIT.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/ScalingIT.java
@@ -19,12 +19,9 @@ package org.apache.shardingsphere.integration.data.pipline;
 
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.integration.data.pipline.env.ITEnvironmentContext;
-import org.apache.shardingsphere.integration.data.pipline.env.IntegrationTestEnvironment;
-import org.apache.shardingsphere.integration.data.pipline.fixture.DataImporter;
 import org.apache.shardingsphere.integration.data.pipline.util.ExecuteUtil;
 import org.apache.shardingsphere.integration.data.pipline.util.ScalingUtil;
 import org.junit.Ignore;
-import org.junit.Test;
 
 import java.util.Map;
 import java.util.Map.Entry;
@@ -41,21 +38,6 @@ public final class ScalingIT {
     
     private static final long WAIT_MS_BEFORE_CHECK_JOB = 15 * 1000;
     
-    @Test
-    public void assertScaling() throws InterruptedException {
-        if (IntegrationTestEnvironment.getInstance().isEnvironmentPrepared()) {
-            IntegrationTestEnvironment.getInstance().waitForEnvironmentReady();
-            DataImporter dataImporter = new DataImporter();
-            dataImporter.createTables();
-            dataImporter.importData();
-            String jobId = assertStartJob();
-            waitInventoryFinish(jobId);
-            dataImporter.importData();
-            Thread.sleep(WAIT_MS_BEFORE_CHECK_JOB);
-            assertJobCheck(jobId);
-        }
-    }
-    
     private String assertStartJob() {
         String configuration = ITEnvironmentContext.INSTANCE.getScalingConfiguration();
         return ScalingUtil.startJob(configuration);
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/BaseScalingITCase.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/BaseScalingITCase.java
index 7517b3bc22f..fb635cf9f95 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/BaseScalingITCase.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/BaseScalingITCase.java
@@ -18,7 +18,8 @@
 package org.apache.shardingsphere.integration.data.pipline.cases;
 
 import com.google.common.base.Joiner;
-import com.google.common.collect.Lists;
+import com.google.common.base.Splitter;
+import com.google.common.collect.Sets;
 import lombok.AccessLevel;
 import lombok.Getter;
 import lombok.SneakyThrows;
@@ -31,17 +32,17 @@ import org.apache.shardingsphere.integration.data.pipline.container.compose.Dock
 import org.apache.shardingsphere.integration.data.pipline.container.compose.LocalComposedContainer;
 import org.apache.shardingsphere.integration.data.pipline.env.IntegrationTestEnvironment;
 import org.apache.shardingsphere.integration.data.pipline.env.enums.ITEnvTypeEnum;
-import org.junit.Before;
-import org.testcontainers.shaded.com.google.common.base.Splitter;
+import org.springframework.jdbc.core.JdbcTemplate;
 
+import javax.sql.DataSource;
 import javax.xml.bind.JAXB;
 import java.sql.Connection;
-import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.HashMap;
 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;
 
@@ -50,7 +51,6 @@ import static org.hamcrest.CoreMatchers.not;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 
-@Getter(AccessLevel.PROTECTED)
 public abstract class BaseScalingITCase {
     
     @Getter(AccessLevel.NONE)
@@ -59,24 +59,23 @@ public abstract class BaseScalingITCase {
     @Getter(AccessLevel.PROTECTED)
     private CommonSQLCommand commonSQLCommand;
     
+    @Getter(AccessLevel.PROTECTED)
+    private JdbcTemplate jdbcTemplate;
+    
     public BaseScalingITCase(final DatabaseType databaseType) {
         if (StringUtils.equalsIgnoreCase(IntegrationTestEnvironment.getInstance().getItEnvType(), ITEnvTypeEnum.DOCKER.name())) {
             composedContainer = new DockerComposedContainer(databaseType);
         } else {
             composedContainer = new LocalComposedContainer(databaseType);
         }
-    }
-    
-    @Before
-    public void init() throws SQLException {
         composedContainer.start();
-        commonSQLCommand = JAXB.unmarshal(BaseScalingITCase.class.getClassLoader().getResource("env/common/command.xml"), CommonSQLCommand.class);
         initScalingEnvironment();
     }
     
     @SneakyThrows
     protected void initScalingEnvironment() {
-        try (Connection connection = getProxyConnection("")) {
+        commonSQLCommand = JAXB.unmarshal(BaseScalingITCase.class.getClassLoader().getResource("env/common/command.xml"), CommonSQLCommand.class);
+        try (Connection connection = getProxyDataSource("").getConnection()) {
             connection.createStatement().execute(commonSQLCommand.getCreateDatabase());
             connection.createStatement().execute(commonSQLCommand.getUseDatabase());
             int dbIndex = 0;
@@ -88,26 +87,26 @@ public abstract class BaseScalingITCase {
                 connection.createStatement().execute(String.format(commonSQLCommand.getAddResource(), dbIndex, getDatabaseUrl(), value));
                 dbIndex++;
             }
-            for (String sql : Splitter.on(";").splitToList(commonSQLCommand.getCreateShardingAlgorithm())) {
+            for (String sql : Splitter.on(";").splitToList(commonSQLCommand.getCreateShardingAlgorithm()).stream().filter(StringUtils::isNotBlank).collect(Collectors.toList())) {
                 connection.createStatement().execute(sql);
             }
             // TODO sleep to wait for sharding algorithm table created,otherwise, the next sql will fail.
-            TimeUnit.SECONDS.sleep(1);
+            TimeUnit.SECONDS.sleep(2);
             connection.createStatement().execute(commonSQLCommand.getCreateShardingTable());
             connection.createStatement().execute(commonSQLCommand.getCreateShardingBinding());
             connection.createStatement().execute(commonSQLCommand.getCreateShardingScalingRule());
         }
+        jdbcTemplate = new JdbcTemplate(composedContainer.getProxyDataSource("sharding_db"));
     }
     
     /**
-     * Get proxy database connection.
+     * Get proxy database data source.
      *
      * @param dataSourceName data source names
      * @return proxy database connection
      */
-    @SneakyThrows(SQLException.class)
-    public Connection getProxyConnection(final String dataSourceName) {
-        return composedContainer.getProxyConnection(dataSourceName);
+    public DataSource getProxyDataSource(final String dataSourceName) {
+        return composedContainer.getProxyDataSource(dataSourceName);
     }
     
     /**
@@ -143,23 +142,24 @@ public abstract class BaseScalingITCase {
     
     /**
      * Check data match consistency.
-     * @param connection proxy database connection
+     *
+     * @param jdbcTemplate jdbc template
      * @param jobId job id
      * @throws InterruptedException if interrupted
      * @throws SQLException if any SQL exception
      */
-    protected void checkMatchConsistency(final Connection connection, final String jobId) throws InterruptedException, SQLException {
+    protected void checkMatchConsistency(final JdbcTemplate jdbcTemplate, final String jobId) throws InterruptedException, SQLException {
         Map<String, String> actualStatusMap = new HashMap<>(2, 1);
         for (int i = 0; i < 100; i++) {
-            ResultSet statusResult = connection.createStatement().executeQuery(String.format(commonSQLCommand.getShowScalingStatus(), jobId));
+            List<Map<String, Object>> showScalingStatusResMap = jdbcTemplate.queryForList(String.format(commonSQLCommand.getShowScalingStatus(), jobId));
             boolean finished = true;
-            while (statusResult.next()) {
-                String datasourceName = statusResult.getString(2);
-                String status = statusResult.getString(3);
-                actualStatusMap.put(datasourceName, status);
+            for (Map<String, Object> entry : showScalingStatusResMap) {
+                String status = entry.get("status").toString();
                 assertThat(status, not(JobStatus.PREPARING_FAILURE.name()));
                 assertThat(status, not(JobStatus.EXECUTE_INVENTORY_TASK_FAILURE.name()));
                 assertThat(status, not(JobStatus.EXECUTE_INCREMENTAL_TASK_FAILURE.name()));
+                String datasourceName = entry.get("data_source").toString();
+                actualStatusMap.put(datasourceName, status);
                 if (!Objects.equals(status, JobStatus.EXECUTE_INCREMENTAL_TASK.name())) {
                     finished = false;
                     break;
@@ -172,26 +172,14 @@ public abstract class BaseScalingITCase {
             }
         }
         assertThat(actualStatusMap.values().stream().filter(StringUtils::isNotBlank).collect(Collectors.toSet()).size(), is(1));
-        connection.createStatement().execute(String.format(getCommonSQLCommand().getStopScalingSourceWriting(), jobId));
-        ResultSet checkScalingResult = connection.createStatement().executeQuery(String.format(commonSQLCommand.getCheckScalingDataMatch(), jobId));
-        while (checkScalingResult.next()) {
-            assertTrue(checkScalingResult.getBoolean(5));
+        jdbcTemplate.execute(String.format(getCommonSQLCommand().getStopScalingSourceWriting(), jobId));
+        List<Map<String, Object>> checkScalingResList = jdbcTemplate.queryForList(String.format(commonSQLCommand.getCheckScalingDataMatch(), jobId));
+        for (Map<String, Object> entry : checkScalingResList) {
+            assertTrue(Boolean.parseBoolean(entry.get("records_content_matched").toString()));
         }
-        connection.createStatement().execute(String.format(getCommonSQLCommand().getApplyScaling(), jobId));
-        ResultSet previewResult = connection.createStatement().executeQuery(getCommonSQLCommand().getPreviewSelectOrder());
-        List<String> actualTargetNodes = Lists.newLinkedList();
-        while (previewResult.next()) {
-            actualTargetNodes.add(previewResult.getString(1));
-        }
-        assertThat(actualTargetNodes, is(Lists.newArrayList("ds_2", "ds_3", "ds_4")));
+        jdbcTemplate.execute(String.format(getCommonSQLCommand().getApplyScaling(), jobId));
+        List<Map<String, Object>> previewResList = jdbcTemplate.queryForList(getCommonSQLCommand().getPreviewSelectOrder());
+        Set<Object> originalSourceList = previewResList.stream().map(result -> result.get("data_source_name")).collect(Collectors.toSet());
+        assertThat(originalSourceList, is(Sets.newHashSet("ds_2", "ds_3", "ds_4")));
     }
-    
-    /**
-     * Initialize table data.
-     * @param connection proxy database connection
-     * @param insertOrderSQL insert order sql
-     * @param insertOrderItemSQL insert order item sql
-     * @throws SQLException if any SQL exception
-     */
-    protected abstract void initTableData(Connection connection, String insertOrderSQL, String insertOrderItemSQL) throws SQLException;
 }
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/IncrementTaskRunnable.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/IncrementTaskRunnable.java
new file mode 100644
index 00000000000..eb567aa2cfd
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/IncrementTaskRunnable.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.integration.data.pipline.cases;
+
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.shardingsphere.integration.data.pipline.cases.command.CommonSQLCommand;
+import org.apache.shardingsphere.integration.data.pipline.util.TableCrudUtil;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+import java.sql.SQLException;
+import java.util.LinkedList;
+import java.util.List;
+
+@Slf4j
+@AllArgsConstructor
+public final class IncrementTaskRunnable implements Runnable {
+    
+    private final JdbcTemplate jdbcTemplate;
+    
+    private final CommonSQLCommand commonSQLCommand;
+    
+    @Override
+    public void run() {
+        int executeCount = 0;
+        List<Long> newPrimaryKeys = new LinkedList<>();
+        try {
+            while (!Thread.currentThread().isInterrupted() && executeCount < 20) {
+                newPrimaryKeys.add(insertOrderAndOrderItem());
+                if (newPrimaryKeys.size() % 2 == 0) {
+                    deleteOrderAndOrderItem(newPrimaryKeys.get(newPrimaryKeys.size() - 1));
+                } else {
+                    updateOrderAndOrderItem(newPrimaryKeys.get(newPrimaryKeys.size() - 1));
+                }
+                executeCount++;
+                log.info("Increment task runnable execute successfully.");
+            }
+        } catch (final SQLException ex) {
+            log.error("IncrementTaskThread error", ex);
+            throw new RuntimeException(ex);
+        }
+    }
+    
+    private long insertOrderAndOrderItem() throws SQLException {
+        Pair<Object[], Object[]> dataPair = TableCrudUtil.generateSimpleInsertData();
+        jdbcTemplate.update(commonSQLCommand.getSimpleInsertOrder(), dataPair.getLeft());
+        jdbcTemplate.update(commonSQLCommand.getInsertOrderItem(), dataPair.getRight());
+        return Long.parseLong(dataPair.getLeft()[0].toString());
+    }
+    
+    private void updateOrderAndOrderItem(final long primaryKey) throws SQLException {
+        jdbcTemplate.execute(String.format(commonSQLCommand.getUpdateOrder(), primaryKey));
+        jdbcTemplate.execute(String.format(commonSQLCommand.getUpdateOrderItem(), primaryKey));
+    }
+    
+    private void deleteOrderAndOrderItem(final long primaryKey) throws SQLException {
+        jdbcTemplate.execute(String.format(commonSQLCommand.getDeleteOrder(), primaryKey));
+        jdbcTemplate.execute(String.format(commonSQLCommand.getDeleteOrderItem(), primaryKey));
+    }
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/command/CommonSQLCommand.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/command/CommonSQLCommand.java
index 641c8a57513..ef181aadee0 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/command/CommonSQLCommand.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/command/CommonSQLCommand.java
@@ -73,4 +73,28 @@ public final class CommonSQLCommand {
     
     @XmlElement(name = "apply-scaling")
     private String applyScaling;
+    
+    @XmlElement(name = "auto-alter-table-rule")
+    private String autoAlterTableRule;
+    
+    @XmlElement(name = "insert-order")
+    private String insertOrder;
+    
+    @XmlElement(name = "insert-order-item")
+    private String insertOrderItem;
+    
+    @XmlElement(name = "simple-insert-order")
+    private String simpleInsertOrder;
+    
+    @XmlElement(name = "update-order")
+    private String updateOrder;
+    
+    @XmlElement(name = "update-order-item")
+    private String updateOrderItem;
+    
+    @XmlElement(name = "delete-order")
+    private String deleteOrder;
+    
+    @XmlElement(name = "delete-order-item")
+    private String deleteOrderItem;
 }
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/command/mysql/MySQLCommand.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/command/mysql/MySQLCommand.java
index f2b5f36cd40..e14b72d5545 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/command/mysql/MySQLCommand.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/command/mysql/MySQLCommand.java
@@ -32,12 +32,6 @@ public final class MySQLCommand {
     @XmlElement(name = "create-table-order")
     private String createTableOrder;
     
-    @XmlElement(name = "create-table-orderitem")
+    @XmlElement(name = "create-table-order-item")
     private String createTableOrderItem;
-    
-    @XmlElement(name = "insert-order")
-    private String insertOrder;
-    
-    @XmlElement(name = "insert-order-item")
-    private String insertOrderItem;
 }
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/mysql/BaseMySQLScalingCase.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/mysql/BaseMySQLScalingCase.java
new file mode 100644
index 00000000000..a4593c6feee
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/mysql/BaseMySQLScalingCase.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.integration.data.pipline.cases.mysql;
+
+import lombok.Getter;
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
+import org.apache.shardingsphere.integration.data.pipline.cases.BaseScalingITCase;
+import org.apache.shardingsphere.integration.data.pipline.cases.command.mysql.MySQLCommand;
+import org.apache.shardingsphere.integration.data.pipline.util.TableCrudUtil;
+
+import javax.xml.bind.JAXB;
+import java.util.List;
+
+public abstract class BaseMySQLScalingCase extends BaseScalingITCase {
+    
+    @Getter
+    private final MySQLCommand mySQLCommand;
+    
+    public BaseMySQLScalingCase() {
+        super(new MySQLDatabaseType());
+        mySQLCommand = JAXB.unmarshal(BaseMySQLScalingCase.class.getClassLoader().getResource("env/mysql/sql.xml"), MySQLCommand.class);
+    }
+    
+    protected void initTableAndData() {
+        getJdbcTemplate().execute(mySQLCommand.getCreateTableOrder());
+        getJdbcTemplate().execute(mySQLCommand.getCreateTableOrderItem());
+        Pair<List<Object[]>, List<Object[]>> dataPair = TableCrudUtil.generateInsertDataList(3000);
+        getJdbcTemplate().batchUpdate(getCommonSQLCommand().getInsertOrder(), dataPair.getLeft());
+        getJdbcTemplate().batchUpdate(getCommonSQLCommand().getInsertOrderItem(), dataPair.getRight());
+    }
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/mysql/MySQLManualScalingCase.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/mysql/MySQLManualScalingCase.java
deleted file mode 100644
index 85c8b7c2a19..00000000000
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/mysql/MySQLManualScalingCase.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.integration.data.pipline.cases.mysql;
-
-import com.google.common.collect.Lists;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
-import org.apache.shardingsphere.integration.data.pipline.cases.BaseScalingITCase;
-import org.apache.shardingsphere.integration.data.pipline.cases.command.mysql.MySQLCommand;
-import org.apache.shardingsphere.sharding.algorithm.keygen.SnowflakeKeyGenerateAlgorithm;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import javax.xml.bind.JAXB;
-import java.math.BigDecimal;
-import java.nio.charset.StandardCharsets;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Timestamp;
-import java.util.List;
-import java.util.concurrent.ThreadLocalRandom;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-/**
- * MySQL auto rule scaling test case.
- */
-@Slf4j
-public final class MySQLManualScalingCase extends BaseScalingITCase {
-    
-    private static final SnowflakeKeyGenerateAlgorithm SNOWFLAKE_GENERATE = new SnowflakeKeyGenerateAlgorithm();
-    
-    private static final ThreadLocalRandom RANDOM = ThreadLocalRandom.current();
-    
-    private static MySQLCommand mySQLCommand;
-    
-    public MySQLManualScalingCase() {
-        super(new MySQLDatabaseType());
-    }
-    
-    @BeforeClass
-    public static void beforeClass() {
-        mySQLCommand = JAXB.unmarshal(MySQLManualScalingCase.class.getClassLoader().getResource("env/mysql/sql.xml"), MySQLCommand.class);
-    }
-    
-    @Before
-    public void init() throws SQLException {
-        super.init();
-        try (Connection connection = getProxyConnection("sharding_db")) {
-            connection.createStatement().execute(mySQLCommand.getCreateTableOrder());
-            connection.createStatement().execute(mySQLCommand.getCreateTableOrderItem());
-            // init date, need more than 3000 rows, in order to test certain conditions
-            initTableData(connection, mySQLCommand.getInsertOrder(), mySQLCommand.getInsertOrderItem());
-        }
-    }
-    
-    @Override
-    protected void initTableData(final Connection connection, final String insertOrderSQL, final String insertOrderItemSQL) throws SQLException {
-        PreparedStatement orderStatement = connection.prepareStatement(insertOrderSQL);
-        PreparedStatement itemStatement = connection.prepareStatement(insertOrderItemSQL);
-        for (int i = 1; i <= 3000; i++) {
-            orderStatement.setLong(1, (Long) SNOWFLAKE_GENERATE.generateKey());
-            int orderId = RANDOM.nextInt(0, 5);
-            orderStatement.setInt(2, orderId);
-            int userId = RANDOM.nextInt(0, 5);
-            orderStatement.setInt(3, userId);
-            orderStatement.setString(4, "varchar" + i);
-            orderStatement.setByte(5, (byte) 1);
-            Timestamp timestamp = new Timestamp(System.currentTimeMillis());
-            orderStatement.setTimestamp(6, timestamp);
-            orderStatement.setTimestamp(7, timestamp);
-            orderStatement.setBytes(8, "hello".getBytes(StandardCharsets.UTF_8));
-            orderStatement.setBinaryStream(9, null);
-            orderStatement.setBigDecimal(10, new BigDecimal("100.00"));
-            orderStatement.setString(11, "test");
-            orderStatement.setDouble(12, Math.random());
-            orderStatement.setString(13, "{}");
-            orderStatement.addBatch();
-            itemStatement.setLong(1, (Long) SNOWFLAKE_GENERATE.generateKey());
-            itemStatement.setInt(2, orderId);
-            itemStatement.setInt(3, userId);
-            itemStatement.setString(4, "SUCCESS");
-            itemStatement.addBatch();
-        }
-        orderStatement.executeBatch();
-        itemStatement.executeBatch();
-    }
-    
-    @Test
-    public void test() throws SQLException, InterruptedException {
-        try (Connection connection = getProxyConnection("sharding_db")) {
-            ResultSet previewResult = connection.createStatement().executeQuery(getCommonSQLCommand().getPreviewSelectOrder());
-            List<String> actualSourceNodes = Lists.newLinkedList();
-            while (previewResult.next()) {
-                actualSourceNodes.add(previewResult.getString(1));
-            }
-            assertThat(actualSourceNodes, is(Lists.newArrayList("ds_0", "ds_1")));
-            connection.createStatement().execute(getCommonSQLCommand().getAlterShardingAlgorithm());
-            connection.createStatement().execute(getCommonSQLCommand().getAlterShardingTableRule());
-            ResultSet scalingList = connection.createStatement().executeQuery(getCommonSQLCommand().getShowScalingList());
-            assertTrue(scalingList.next());
-            String jobId = scalingList.getString(1);
-            checkMatchConsistency(connection, jobId);
-        }
-    }
-}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/mysql/MySQLManualScalingTest.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/mysql/MySQLManualScalingTest.java
new file mode 100644
index 00000000000..a5fe339188d
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/cases/mysql/MySQLManualScalingTest.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.integration.data.pipline.cases.mysql;
+
+import com.google.common.collect.Sets;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.integration.data.pipline.cases.IncrementTaskRunnable;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.sql.SQLException;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * MySQL manual scaling test case.
+ */
+@Slf4j
+public final class MySQLManualScalingTest extends BaseMySQLScalingCase {
+    
+    private Thread increaseTaskThread;
+    
+    @Before
+    public void initEnv() {
+        super.initTableAndData();
+        increaseTaskThread = new Thread(new IncrementTaskRunnable(getJdbcTemplate(), getCommonSQLCommand()));
+        increaseTaskThread.start();
+    }
+    
+    @Test
+    public void assertManualScalingSuccess() throws InterruptedException, SQLException {
+        List<Map<String, Object>> previewResList = getJdbcTemplate().queryForList(getCommonSQLCommand().getPreviewSelectOrder());
+        Set<Object> originalSourceList = previewResList.stream().map(result -> result.get("data_source_name")).collect(Collectors.toSet());
+        assertThat(originalSourceList, is(Sets.newHashSet("ds_0", "ds_1")));
+        getJdbcTemplate().execute(getCommonSQLCommand().getAutoAlterTableRule());
+        Map<String, Object> showScalingResMap = getJdbcTemplate().queryForMap(getCommonSQLCommand().getShowScalingList());
+        String jobId = showScalingResMap.get("id").toString();
+        increaseTaskThread.join(60 * 1000);
+        checkMatchConsistency(getJdbcTemplate(), jobId);
+    }
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/BaseComposedContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/BaseComposedContainer.java
index bee6137569d..ead65583d82 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/BaseComposedContainer.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/BaseComposedContainer.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.test.integration.framework.container.atomic.gov
 import org.apache.shardingsphere.test.integration.util.NetworkAliasUtil;
 import org.testcontainers.lifecycle.Startable;
 
-import java.sql.Connection;
+import javax.sql.DataSource;
 import java.sql.SQLException;
 
 @Getter
@@ -46,13 +46,13 @@ public abstract class BaseComposedContainer implements Startable {
     }
     
     /**
-     * Get proxy connection.
-     * 
+     * Get proxy data source.
+     *
      * @param databaseName database name
      * @return sql connection.
      * @throws SQLException sql exception
      */
-    public abstract Connection getProxyConnection(String databaseName) throws SQLException;
+    public abstract DataSource getProxyDataSource(String databaseName);
     
     @Override
     public void start() {
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/DockerComposedContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/DockerComposedContainer.java
index b3259fa1af8..dad0c3e3618 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/DockerComposedContainer.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/DockerComposedContainer.java
@@ -17,15 +17,15 @@
 
 package org.apache.shardingsphere.integration.data.pipline.container.compose;
 
+import com.zaxxer.hikari.HikariDataSource;
 import lombok.Getter;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.integration.data.pipline.container.proxy.ShardingSphereProxyDockerContainer;
 import org.apache.shardingsphere.test.integration.env.DataSourceEnvironment;
 import org.apache.shardingsphere.test.integration.util.NetworkAliasUtil;
 
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
+import javax.sql.DataSource;
 
 /**
  * Composed container, include governance container and database container.
@@ -50,8 +50,15 @@ public final class DockerComposedContainer extends BaseComposedContainer {
     }
     
     @Override
-    public Connection getProxyConnection(final String databaseName) throws SQLException {
-        return DriverManager.getConnection(DataSourceEnvironment.getURL(getDatabaseContainer().getDatabaseType(),
-                getProxyContainer().getHost(), getProxyContainer().getFirstMappedPort(), databaseName), "root", "root");
+    public DataSource getProxyDataSource(final String databaseName) {
+        HikariDataSource result = new HikariDataSource();
+        result.setDriverClassName(DataSourceEnvironment.getDriverClassName(getDatabaseContainer().getDatabaseType()));
+        String jdbcUrl = StringUtils.appendIfMissing(DataSourceEnvironment.getURL(getDatabaseContainer().getDatabaseType(), getProxyContainer().getHost(), getProxyContainer().getFirstMappedPort(), databaseName), "&rewriteBatchedStatements=true");
+        result.setJdbcUrl(jdbcUrl);
+        result.setUsername("root");
+        result.setPassword("root");
+        result.setMaximumPoolSize(2);
+        result.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
+        return result;
     }
 }
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/LocalComposedContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/LocalComposedContainer.java
index 851d64098fa..15a064997aa 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/LocalComposedContainer.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/container/compose/LocalComposedContainer.java
@@ -17,14 +17,14 @@
 
 package org.apache.shardingsphere.integration.data.pipline.container.compose;
 
+import com.zaxxer.hikari.HikariDataSource;
 import lombok.SneakyThrows;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.integration.data.pipline.container.proxy.ShardingSphereProxyLocalContainer;
 import org.apache.shardingsphere.test.integration.env.DataSourceEnvironment;
 
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
+import javax.sql.DataSource;
 
 /**
  * Local composed container.
@@ -46,7 +46,15 @@ public final class LocalComposedContainer extends BaseComposedContainer {
     }
     
     @Override
-    public Connection getProxyConnection(final String databaseName) throws SQLException {
-        return DriverManager.getConnection(DataSourceEnvironment.getURL(getDatabaseContainer().getDatabaseType(), "localhost", 3307, databaseName), "root", "root");
+    public DataSource getProxyDataSource(final String databaseName) {
+        HikariDataSource result = new HikariDataSource();
+        result.setDriverClassName(DataSourceEnvironment.getDriverClassName(getDatabaseContainer().getDatabaseType()));
+        String jdbcUrl = StringUtils.appendIfMissing(DataSourceEnvironment.getURL(getDatabaseContainer().getDatabaseType(), "localhost", 3307, databaseName), "&rewriteBatchedStatements=true");
+        result.setJdbcUrl(jdbcUrl);
+        result.setUsername("root");
+        result.setPassword("root");
+        result.setMaximumPoolSize(2);
+        result.setTransactionIsolation("TRANSACTION_READ_COMMITTED");
+        return result;
     }
 }
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/IntegrationTestEnvironment.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/IntegrationTestEnvironment.java
index 90dab938dd3..6218197a0e0 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/IntegrationTestEnvironment.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/env/IntegrationTestEnvironment.java
@@ -18,10 +18,7 @@
 package org.apache.shardingsphere.integration.data.pipline.env;
 
 import lombok.Getter;
-import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.shardingsphere.integration.data.pipline.util.ExecuteUtil;
-import org.apache.shardingsphere.integration.data.pipline.util.ScalingUtil;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -33,44 +30,26 @@ public final class IntegrationTestEnvironment {
     
     private static final IntegrationTestEnvironment INSTANCE = new IntegrationTestEnvironment();
     
-    private final boolean isEnvironmentPrepared;
-    
     private final Properties props;
     
     private final String itEnvType;
     
     private IntegrationTestEnvironment() {
-        props = loadProperties("env/it-env.properties");
+        props = loadProperties();
         itEnvType = props.getProperty("it.env.type");
-        isEnvironmentPrepared = false;
     }
     
-    @SneakyThrows
-    private Properties loadProperties(final String propsFileName) {
+    private Properties loadProperties() {
         Properties result = new Properties();
-        try (InputStream inputStream = IntegrationTestEnvironment.class.getClassLoader().getResourceAsStream(propsFileName)) {
+        try (InputStream inputStream = IntegrationTestEnvironment.class.getClassLoader().getResourceAsStream("env/it-env.properties")) {
             result.load(inputStream);
+        } catch (final IOException ex) {
+            throw new RuntimeException(ex);
         }
-        return result;
-    }
-    
-    /**
-     * Wait for environment ready.
-     */
-    public void waitForEnvironmentReady() {
-        log.info("wait begin scaling environment");
-        new ExecuteUtil(this::isScalingReady, Integer.parseInt(props.getProperty("scaling.retry", "30")),
-                Long.parseLong(props.getProperty("scaling.waitMs", "1000"))).execute();
-    }
-    
-    private boolean isScalingReady() {
-        try {
-            ScalingUtil.getJobList();
-        } catch (final IOException ignore) {
-            return false;
+        for (String each : System.getProperties().stringPropertyNames()) {
+            result.setProperty(each, System.getProperty(each));
         }
-        log.info("it scaling environment success");
-        return true;
+        return result;
     }
     
     /**
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/util/TableCrudUtil.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/util/TableCrudUtil.java
new file mode 100644
index 00000000000..d0479014354
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipline/util/TableCrudUtil.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.integration.data.pipline.util;
+
+import org.apache.commons.lang3.tuple.Pair;
+import org.apache.shardingsphere.sharding.algorithm.keygen.SnowflakeKeyGenerateAlgorithm;
+
+import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ThreadLocalRandom;
+
+public final class TableCrudUtil {
+    
+    private static final SnowflakeKeyGenerateAlgorithm SNOWFLAKE_GENERATE = new SnowflakeKeyGenerateAlgorithm();
+    
+    private static final ThreadLocalRandom RANDOM = ThreadLocalRandom.current();
+    
+    /**
+     * Generate insert data.
+     *
+     * @param insertRows insert rows
+     * @return insert data list
+     */
+    public static Pair<List<Object[]>, List<Object[]>> generateInsertDataList(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 = 1; i <= insertRows; i++) {
+            int orderId = RANDOM.nextInt(0, 5);
+            int userId = RANDOM.nextInt(0, 5);
+            orderData.add(new Object[]{SNOWFLAKE_GENERATE.generateKey(), orderId, userId, "varchar" + i, (byte) 1, new Timestamp(System.currentTimeMillis()), new Timestamp(System.currentTimeMillis()),
+                    "hello".getBytes(StandardCharsets.UTF_8), null, new BigDecimal("100.00"), "test", Math.random(), "{}"});
+            orderItemData.add(new Object[]{SNOWFLAKE_GENERATE.generateKey(), orderId, userId, "SUCCESS"});
+        }
+        return Pair.of(orderData, orderItemData);
+    }
+    
+    /**
+     * Generate simple insert data.
+     *
+     * @return insert data
+     */
+    public static Pair<Object[], Object[]> generateSimpleInsertData() {
+        long uniqueKey = (Long) SNOWFLAKE_GENERATE.generateKey();
+        int orderId = RANDOM.nextInt(0, 5);
+        int userId = RANDOM.nextInt(0, 5);
+        return Pair.of(new Object[]{uniqueKey, orderId, userId}, new Object[]{uniqueKey, orderId, userId, "OK"});
+    }
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/common/command.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/common/command.xml
index 42928ed29db..9f5682a410b 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/common/command.xml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/common/command.xml
@@ -55,12 +55,12 @@
     </create-sharding-binding>
     
     <create-sharding-scaling-rule>
-        CREATE SHARDING SCALING RULE scaling_manual (DATA_CONSISTENCY_CHECKER(TYPE(NAME=CRC32_MATCH)))
+        CREATE SHARDING SCALING RULE scaling_manual (DATA_CONSISTENCY_CHECKER(TYPE(NAME=DATA_MATCH)))
     </create-sharding-scaling-rule>
     
     <alter-sharding-algorithm>
-        ALTER SHARDING ALGORITHM database_inline (
-        TYPE(NAME=INLINE,PROPERTIES("algorithm-expression"="ds_${user_id % 3 + 2}")));
+        ALTER SHARDING ALGORITHM database_inline
+        (TYPE(NAME=INLINE,PROPERTIES("algorithm-expression"="ds_${user_id % 3 + 2}")))
     </alter-sharding-algorithm>
     
     <alter-sharding-table-rule>
@@ -73,11 +73,11 @@
         DATANODES("ds_${2..4}.t_order_item_${0..1}"),
         DATABASE_STRATEGY(TYPE=standard,SHARDING_COLUMN=user_id,SHARDING_ALGORITHM=database_inline),
         TABLE_STRATEGY(TYPE=standard,SHARDING_COLUMN=order_id,SHARDING_ALGORITHM=t_order_item_inline),
-        KEY_GENERATE_STRATEGY(COLUMN=order_item_id,TYPE(NAME=snowflake)));
+        KEY_GENERATE_STRATEGY(COLUMN=order_item_id,TYPE(NAME=snowflake)))
     </alter-sharding-table-rule>
     
     <preview-select-order>
-        PREVIEW SELECT COUNT(1) FROM t_order;
+        PREVIEW SELECT COUNT(1) FROM t_order
     </preview-select-order>
     
     <show-scaling-list>
@@ -89,14 +89,71 @@
     </show-scaling-status>
     
     <stop-scaling-source-writing>
-        STOP SCALING SOURCE WRITING %s;
+        STOP SCALING SOURCE WRITING %s
     </stop-scaling-source-writing>
     
     <check-scaling-data-match>
-        CHECK SCALING %s BY TYPE (NAME=CRC32_MATCH);
+        CHECK SCALING %s BY TYPE (NAME=CRC32_MATCH)
     </check-scaling-data-match>
     
     <apply-scaling>
-        APPLY SCALING %s;
+        APPLY SCALING %s
     </apply-scaling>
+    
+    <auto-alter-table-rule>
+        ALTER SHARDING TABLE RULE t_order(
+        RESOURCES(ds_2, ds_3, ds_4),
+        SHARDING_COLUMN=order_id,
+        TYPE(NAME=hash_mod,PROPERTIES("sharding-count"=6)),
+        KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME=snowflake))
+        ),t_order_item(
+        RESOURCES(ds_2, ds_3, ds_4),
+        SHARDING_COLUMN=order_id,
+        TYPE(NAME=hash_mod,PROPERTIES("sharding-count"=6)),
+        KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME=snowflake))
+        )
+    </auto-alter-table-rule>
+    
+    <insert-order>
+        INSERT INTO t_order (
+        id,
+        order_id,
+        user_id,
+        t_varchar,
+        t_tinyint,
+        t_timestamp,
+        t_datetime,
+        t_binary,
+        t_blob,
+        t_decimal,
+        t_char,
+        t_double,
+        t_json
+        )
+        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)
+    </insert-order>
+    
+    <simple-insert-order>
+        INSERT INTO t_order ( id, order_id, user_id) VALUES (?, ?, ?)
+    </simple-insert-order>
+    
+    <insert-order-item>
+        INSERT INTO t_order_item(item_id, order_id, user_id, status) VALUES(?,?,?,?)
+    </insert-order-item>
+    
+    <update-order>
+        UPDATE t_order SET t_varchar = 'update' WHERE id = %s
+    </update-order>
+    
+    <update-order-item>
+        UPDATE t_order_item SET status = 'changed' WHERE item_id = %s
+    </update-order-item>
+    
+    <delete-order>
+        DELETE FROM t_order WHERE id = %s
+    </delete-order>
+    
+    <delete-order-item>
+        DELETE FROM t_order_item WHERE item_id = %s
+    </delete-order-item>
 </command>
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/sql.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/sql.xml
index b78cd9be48c..3692ac35dbf 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/sql.xml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/sql.xml
@@ -20,10 +20,10 @@
         `id` BIGINT NOT NULL COMMENT 'pk id',
         `order_id` INT NOT NULL,
         `user_id` INT NOT NULL,
-        `t_varchar` VARCHAR ( 255 ) NOT NULL,
+        `t_varchar` VARCHAR ( 255 ) NULL,
         `t_tinyint` TINYINT ( 1 ) NULL,
         `t_timestamp` TIMESTAMP NULL,
-        `t_datetime` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP,
+        `t_datetime` datetime NULL ON UPDATE CURRENT_TIMESTAMP,
         `t_binary` BINARY(255) NULL,
         `t_blob` BLOB NULL,
         `t_decimal` DECIMAL ( 10, 2 ) NULL,
@@ -31,31 +31,11 @@
         `t_double` DOUBLE NULL,
         `t_json` json NULL COMMENT 'json test',
         PRIMARY KEY ( `id` ),
-        UNIQUE INDEX ( `t_varchar` ),
         INDEX ( `order_id` )
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
     </create-table-order>
     
-    <insert-order>
-        INSERT INTO `t_order` (
-        `id`,
-        `order_id`,
-        `user_id`,
-        `t_varchar`,
-        `t_tinyint`,
-        `t_timestamp`,
-        `t_datetime`,
-        `t_binary`,
-        `t_blob`,
-        `t_decimal`,
-        `t_char`,
-        `t_double`,
-        `t_json`
-        )
-        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?);
-    </insert-order>
-    
-    <create-table-orderitem>
+    <create-table-order-item>
         CREATE TABLE t_order_item (
         item_id bigint NOT NULL,
         order_id int NOT NULL,
@@ -63,9 +43,5 @@
         status varchar(50) DEFAULT NULL,
         PRIMARY KEY (item_id)
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-    </create-table-orderitem>
-    
-    <insert-order-item>
-        INSERT INTO t_order_item(item_id, order_id, user_id, status) VALUES(?,?,?,?);
-    </insert-order-item>
+    </create-table-order-item>
 </command>
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/logback-test.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/logback-test.xml
index d80d16d1513..2faa5a56af4 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/logback-test.xml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/logback-test.xml
@@ -22,12 +22,12 @@
             <pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %logger{36} - %msg%n</pattern>
         </encoder>
     </appender>
-    <logger name="org.apache.shardingsphere" level="warn" additivity="true">
+    <logger name="org.apache.shardingsphere" level="info" additivity="true">
         <appender-ref ref="console" />
     </logger>
     <logger name="com.zaxxer.hikari.pool.ProxyConnection" level="off" />
     <root>
-        <level value="warn" />
+        <level value="info" />
         <appender-ref ref="console" />
     </root>
 </configuration>