This is an automated email from the ASF dual-hosted git repository.

zhangliang 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 9eddd40  Refactor scaling integration test (#10705)
9eddd40 is described below

commit 9eddd40474e33bf75b9c79418a44cdd2b6f51317
Author: avalon5666 <[email protected]>
AuthorDate: Mon Jun 7 22:53:45 2021 +0800

    Refactor scaling integration test (#10705)
    
    * Refactor scaling it
    
    * For checkstyle
    
    * Fix ci
---
 .../integration/scaling/test/mysql/ScalingIT.java  |  26 ++---
 .../test/mysql/env/ITEnvironmentContext.java       |  89 +++++++++++++++++
 .../scaling/test/mysql/env/cases/DataSet.java      |  37 +++++++
 .../scaling/test/mysql/env/cases/Type.java         |  72 ++++++++++++++
 .../config/SourceConfiguration.java}               |  57 +++++------
 .../config/TargetConfiguration.java}               |  52 ++++++----
 .../scaling/test/mysql/fixture/DataImporter.java   |  78 +++++++++++++++
 .../test/mysql/fixture/FixtureWriteThread.java     | 109 ---------------------
 .../scaling/test/mysql/util/ScalingUtil.java       |  13 ++-
 .../src/test/resources/cases/mysql/types.xml       |  32 ++++++
 .../src/test/resources/env/mysql/init.sql          |   2 -
 11 files changed, 392 insertions(+), 175 deletions(-)

diff --git 
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/ScalingIT.java
 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/ScalingIT.java
index e32234c..3461776 100644
--- 
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/ScalingIT.java
+++ 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/ScalingIT.java
@@ -20,14 +20,15 @@ package 
org.apache.shardingsphere.integration.scaling.test.mysql;
 import groovy.lang.Tuple2;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
+import 
org.apache.shardingsphere.integration.scaling.test.mysql.env.ITEnvironmentContext;
 import 
org.apache.shardingsphere.integration.scaling.test.mysql.env.IntegrationTestEnvironment;
-import 
org.apache.shardingsphere.integration.scaling.test.mysql.fixture.FixtureWriteThread;
+import 
org.apache.shardingsphere.integration.scaling.test.mysql.fixture.DataImporter;
 import 
org.apache.shardingsphere.integration.scaling.test.mysql.util.ExecuteUtil;
 import 
org.apache.shardingsphere.integration.scaling.test.mysql.util.ScalingUtil;
-import 
org.apache.shardingsphere.integration.scaling.test.mysql.util.TargetDataSourceUtil;
 import org.junit.Test;
 
 import java.io.IOException;
+import java.util.Map;
 
 import static org.junit.Assert.assertTrue;
 
@@ -40,18 +41,17 @@ public final class ScalingIT {
     
     private static final long WAIT_MS_BEFORE_CHECK_JOB = 15 * 1000;
     
-    private final FixtureWriteThread fixtureWriteThread = new 
FixtureWriteThread(TIMEOUT_MS, 1000);
-    
     @SneakyThrows(InterruptedException.class)
     @Test
     public void assertScaling() {
         if (IntegrationTestEnvironment.getInstance().isEnvironmentPrepared()) {
             IntegrationTestEnvironment.getInstance().waitForEnvironmentReady();
-            fixtureWriteThread.start();
-            Thread.sleep(WAIT_MS_BEFORE_START_JOB);
+            DataImporter dataImporter = new DataImporter();
+            dataImporter.createTables();
+            dataImporter.importData();
             String jobId = assertStartJob();
             waitInventoryFinish(jobId);
-            fixtureWriteThread.stop();
+            dataImporter.importData();
             Thread.sleep(WAIT_MS_BEFORE_CHECK_JOB);
             assertJobCheck(jobId);
         }
@@ -59,8 +59,8 @@ public final class ScalingIT {
     
     @SneakyThrows(IOException.class)
     private String assertStartJob() {
-        String configurations = 
TargetDataSourceUtil.createDockerConfigurations();
-        Tuple2<Boolean, String> response = 
ScalingUtil.getInstance().startJob(configurations);
+        String configuration = 
ITEnvironmentContext.INSTANCE.getScalingConfiguration();
+        Tuple2<Boolean, String> response = 
ScalingUtil.getInstance().startJob(configuration);
         assertTrue(response.getFirst());
         return response.getSecond();
     }
@@ -73,8 +73,10 @@ public final class ScalingIT {
     
     @SneakyThrows(IOException.class)
     private void assertJobCheck(final String jobId) {
-        Tuple2<Boolean, Boolean> checkResult = 
ScalingUtil.getInstance().getJobCheckResult(jobId);
-        assertTrue(checkResult.getFirst());
-        assertTrue(checkResult.getSecond());
+        Map<String, Tuple2<Boolean, Boolean>> checkResult = 
ScalingUtil.getInstance().getJobCheckResult(jobId);
+        for (Map.Entry<String, Tuple2<Boolean, Boolean>> entry : 
checkResult.entrySet()) {
+            assertTrue(entry.getValue().getFirst());
+            assertTrue(entry.getValue().getSecond());
+        }
     }
 }
diff --git 
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/ITEnvironmentContext.java
 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/ITEnvironmentContext.java
new file mode 100644
index 0000000..c8678e3
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/ITEnvironmentContext.java
@@ -0,0 +1,89 @@
+/*
+ * 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.scaling.test.mysql.env;
+
+import com.google.gson.Gson;
+import lombok.Getter;
+import lombok.SneakyThrows;
+import 
org.apache.shardingsphere.integration.scaling.test.mysql.env.cases.DataSet;
+import org.apache.shardingsphere.integration.scaling.test.mysql.env.cases.Type;
+import 
org.apache.shardingsphere.integration.scaling.test.mysql.env.config.SourceConfiguration;
+import 
org.apache.shardingsphere.integration.scaling.test.mysql.env.config.TargetConfiguration;
+import org.apache.shardingsphere.scaling.core.config.JobConfiguration;
+import org.apache.shardingsphere.scaling.core.config.RuleConfiguration;
+import 
org.apache.shardingsphere.sharding.yaml.config.rule.YamlTableRuleConfiguration;
+
+import javax.sql.DataSource;
+import javax.xml.bind.JAXBContext;
+import java.io.FileReader;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Integration test environment context.
+ */
+@Getter
+public final class ITEnvironmentContext {
+    
+    public static final ITEnvironmentContext INSTANCE = new 
ITEnvironmentContext();
+    
+    private static final String TYPE_TEST_XML = "/cases/mysql/types.xml";
+    
+    private final DataSet testCases;
+    
+    private final DataSource sourceDataSource;
+    
+    private final DataSource targetDataSource;
+    
+    private final String scalingConfiguration;
+    
+    public ITEnvironmentContext() {
+        testCases = loadTestCases();
+        Map<String, YamlTableRuleConfiguration> sourceTableRules = 
createSourceTableRules(testCases);
+        scalingConfiguration = createScalingConfiguration(sourceTableRules);
+        sourceDataSource = 
SourceConfiguration.createHostDataSource(sourceTableRules);
+        targetDataSource = TargetConfiguration.createHostDataSource();
+    }
+    
+    @SneakyThrows
+    private DataSet loadTestCases() {
+        try (FileReader reader = new 
FileReader(ITEnvironmentContext.class.getResource(TYPE_TEST_XML).getPath())) {
+            return (DataSet) 
JAXBContext.newInstance(DataSet.class).createUnmarshaller().unmarshal(reader);
+        }
+    }
+    
+    private Map<String, YamlTableRuleConfiguration> 
createSourceTableRules(final DataSet dataSet) {
+        Map<String, YamlTableRuleConfiguration> result = new HashMap<>();
+        for (Type type : testCases.getTypes()) {
+            YamlTableRuleConfiguration tableRule = new 
YamlTableRuleConfiguration();
+            tableRule.setLogicTable(type.getTableName());
+            tableRule.setActualDataNodes("ds_src." + type.getTableName());
+            result.put(type.getTableName(), tableRule);
+        }
+        return result;
+    }
+    
+    private static String createScalingConfiguration(final Map<String, 
YamlTableRuleConfiguration> tableRules) {
+        JobConfiguration jobConfiguration = new JobConfiguration();
+        RuleConfiguration ruleConfiguration = new RuleConfiguration();
+        
ruleConfiguration.setSource(SourceConfiguration.getDockerConfiguration(tableRules).wrap());
+        
ruleConfiguration.setTarget(TargetConfiguration.getDockerConfiguration().wrap());
+        jobConfiguration.setRuleConfig(ruleConfiguration);
+        return new Gson().toJson(jobConfiguration);
+    }
+}
diff --git 
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/cases/DataSet.java
 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/cases/DataSet.java
new file mode 100644
index 0000000..2dff881
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/cases/DataSet.java
@@ -0,0 +1,37 @@
+/*
+ * 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.scaling.test.mysql.env.cases;
+
+import lombok.Getter;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Data set.
+ */
+@Getter
+@XmlRootElement(name = "dataset")
+public final class DataSet {
+    
+    @XmlElement(name = "type")
+    private final List<Type> types = new LinkedList<>();
+}
+
diff --git 
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/cases/Type.java
 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/cases/Type.java
new file mode 100644
index 0000000..d7a7b7c
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/cases/Type.java
@@ -0,0 +1,72 @@
+/*
+ * 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.scaling.test.mysql.env.cases;
+
+import lombok.Getter;
+
+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.LinkedList;
+import java.util.List;
+
+/**
+ * Type.
+ */
+@Getter
+@XmlAccessorType(XmlAccessType.FIELD)
+public final class Type {
+    
+    private static final String TABLE_NAME_PREFIX = "type_it_";
+    
+    private static final String COLUMN_NAME = "c1";
+    
+    @XmlAttribute(required = true)
+    private String name;
+    
+    @XmlElement(name = "value")
+    private final List<String> values = new LinkedList<>();
+    
+    /**
+     * Get table name.
+     *
+     * @return table name
+     */
+    public String getTableName() {
+        return TABLE_NAME_PREFIX + name.replaceAll("[^\\w]", "_");
+    }
+    
+    /**
+     * Get column name.
+     *
+     * @return column name
+     */
+    public String getColumnName() {
+        return COLUMN_NAME;
+    }
+    
+    /**
+     * Get column type.
+     *
+     * @return column type
+     */
+    public String getColumnType() {
+        return name;
+    }
+}
diff --git 
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/util/SourceShardingSphereUtil.java
 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/config/SourceConfiguration.java
similarity index 57%
rename from 
shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/util/SourceShardingSphereUtil.java
rename to 
shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/config/SourceConfiguration.java
index 7374744..fa4a11d 100644
--- 
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/util/SourceShardingSphereUtil.java
+++ 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/config/SourceConfiguration.java
@@ -15,52 +15,61 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.integration.scaling.test.mysql.util;
+package org.apache.shardingsphere.integration.scaling.test.mysql.env.config;
 
 import com.google.common.collect.ImmutableMap;
 import lombok.SneakyThrows;
 import 
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
 import org.apache.shardingsphere.infra.yaml.config.YamlRootRuleConfigurations;
+import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
 import 
org.apache.shardingsphere.infra.yaml.swapper.YamlDataSourceConfigurationSwapper;
 import 
org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
 import 
org.apache.shardingsphere.integration.scaling.test.mysql.env.IntegrationTestEnvironment;
+import 
org.apache.shardingsphere.scaling.core.config.datasource.ShardingSphereJDBCDataSourceConfiguration;
 import 
org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.yaml.config.rule.YamlTableRuleConfiguration;
 
 import javax.sql.DataSource;
+import java.sql.SQLException;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
 
 /**
- * Source sharding sphere util.
+ * Source sharding jdbc configuration.
  */
-public final class SourceShardingSphereUtil {
+public final class SourceConfiguration {
     
     private static final String SOURCE_JDBC_URL = 
"jdbc:mysql://%s/ds_src?useSSL=false";
     
     private static final Properties ENGINE_ENV_PROPS = 
IntegrationTestEnvironment.getInstance().getEngineEnvProps();
     
     /**
-     * Create docker sharding jdbc configurations.
+     * Get docker sharding jdbc configuration.
      *
-     * @return yaml root rule configurations
+     * @param tableRules table rules
+     * @return sharding jdbc configuration
      */
-    public static YamlRootRuleConfigurations createDockerConfigurations() {
-        return createConfigurations(String.format(SOURCE_JDBC_URL, 
ENGINE_ENV_PROPS.getProperty("db.host.docker")));
+    public static ShardingSphereJDBCDataSourceConfiguration 
getDockerConfiguration(final Map<String, YamlTableRuleConfiguration> 
tableRules) {
+        return getConfiguration(String.format(SOURCE_JDBC_URL, 
ENGINE_ENV_PROPS.getProperty("db.host.docker")), tableRules);
     }
     
     /**
-     * Create host sharding jdbc configurations.
+     * Get host sharding jdbc configuration.
      *
-     * @return yaml root rule configurations
+     * @param tableRules table rules
+     * @return sharding jdbc configuration
      */
-    public static YamlRootRuleConfigurations createHostConfigurations() {
-        return createConfigurations(String.format(SOURCE_JDBC_URL, 
ENGINE_ENV_PROPS.getProperty("db.host.host")));
+    public static ShardingSphereJDBCDataSourceConfiguration 
getHostConfiguration(final Map<String, YamlTableRuleConfiguration> tableRules) {
+        return getConfiguration(String.format(SOURCE_JDBC_URL, 
ENGINE_ENV_PROPS.getProperty("db.host.host")), tableRules);
     }
     
-    private static YamlRootRuleConfigurations createConfigurations(final 
String jdbcUrl) {
+    private static ShardingSphereJDBCDataSourceConfiguration 
getConfiguration(final String jdbcUrl, final Map<String, 
YamlTableRuleConfiguration> tableRules) {
+        YamlRootRuleConfigurations shardingSphereConfigurations = 
getShardingJdbcConfiguration(jdbcUrl, tableRules);
+        return new 
ShardingSphereJDBCDataSourceConfiguration(YamlEngine.marshal(shardingSphereConfigurations));
+    }
+    
+    private static YamlRootRuleConfigurations 
getShardingJdbcConfiguration(final String jdbcUrl, final Map<String, 
YamlTableRuleConfiguration> tableRules) {
         YamlRootRuleConfigurations result = new YamlRootRuleConfigurations();
         Map dataSources = ImmutableMap.builder().put("ds_src", 
ImmutableMap.builder()
                 .put("dataSourceClassName", 
"com.zaxxer.hikari.HikariDataSource")
@@ -70,29 +79,21 @@ public final class SourceShardingSphereUtil {
                 .build()).build();
         result.setDataSources(dataSources);
         YamlShardingRuleConfiguration shardingRuleConfiguration = new 
YamlShardingRuleConfiguration();
-        shardingRuleConfiguration.setTables(createTableRules());
+        shardingRuleConfiguration.setTables(tableRules);
         result.setRules(Collections.singleton(shardingRuleConfiguration));
         return result;
     }
     
-    private static Map<String, YamlTableRuleConfiguration> createTableRules() {
-        Map<String, YamlTableRuleConfiguration> result = new HashMap<>();
-        YamlTableRuleConfiguration t1TableRule = new 
YamlTableRuleConfiguration();
-        t1TableRule.setLogicTable("t1");
-        t1TableRule.setActualDataNodes("ds_src.t1");
-        result.put("t1", t1TableRule);
-        return result;
-    }
-    
     /**
      * Create host sharding jdbc data source.
      *
+     * @param tableRules table rules
      * @return data source
      */
-    @SneakyThrows
-    public static DataSource createHostDataSource() {
-        YamlRootRuleConfigurations configurations = createHostConfigurations();
-        return new ShardingSphereDataSource(new 
YamlDataSourceConfigurationSwapper().swapToDataSources(configurations.getDataSources()),
-                new 
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(configurations.getRules()),
 null);
+    @SneakyThrows(SQLException.class)
+    public static DataSource createHostDataSource(final Map<String, 
YamlTableRuleConfiguration> tableRules) {
+        ShardingSphereJDBCDataSourceConfiguration configuration = 
getHostConfiguration(tableRules);
+        return new ShardingSphereDataSource(new 
YamlDataSourceConfigurationSwapper().swapToDataSources(configuration.getRootRuleConfigs().getDataSources()),
+                new 
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(configuration.getRootRuleConfigs().getRules()),
 null);
     }
 }
diff --git 
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/util/TargetDataSourceUtil.java
 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/config/TargetConfiguration.java
similarity index 53%
rename from 
shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/util/TargetDataSourceUtil.java
rename to 
shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/config/TargetConfiguration.java
index 030758a..5c75984 100644
--- 
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/util/TargetDataSourceUtil.java
+++ 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/config/TargetConfiguration.java
@@ -15,46 +15,56 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.integration.scaling.test.mysql.util;
+package org.apache.shardingsphere.integration.scaling.test.mysql.env.config;
 
-import com.google.gson.Gson;
-import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
+import com.zaxxer.hikari.HikariDataSource;
 import 
org.apache.shardingsphere.integration.scaling.test.mysql.env.IntegrationTestEnvironment;
-import org.apache.shardingsphere.scaling.core.config.JobConfiguration;
-import org.apache.shardingsphere.scaling.core.config.RuleConfiguration;
-import 
org.apache.shardingsphere.scaling.core.config.datasource.ScalingDataSourceConfigurationWrap;
-import 
org.apache.shardingsphere.scaling.core.config.datasource.ShardingSphereJDBCDataSourceConfiguration;
 import 
org.apache.shardingsphere.scaling.core.config.datasource.StandardJDBCDataSourceConfiguration;
 
+import javax.sql.DataSource;
 import java.util.Properties;
 
 /**
- * Target data source util.
+ * Target standard jdbc configuration.
  */
-public final class TargetDataSourceUtil {
+public final class TargetConfiguration {
     
     private static final String TARGET_JDBC_URL = 
"jdbc:mysql://%s/ds_dst?useSSL=false";
     
     private static final Properties ENGINE_ENV_PROPS = 
IntegrationTestEnvironment.getInstance().getEngineEnvProps();
     
     /**
-     * Create docker scaling job configurations.
+     * Get docker standard jdbc configuration.
      *
-     * @return scaling job configurations
+     * @return standard jdbc configuration
      */
-    public static String createDockerConfigurations() {
-        JobConfiguration jobConfiguration = new JobConfiguration();
-        RuleConfiguration ruleConfiguration = new RuleConfiguration();
-        ruleConfiguration.setSource(new 
ShardingSphereJDBCDataSourceConfiguration(YamlEngine.marshal(SourceShardingSphereUtil.createDockerConfigurations())).wrap());
-        ruleConfiguration.setTarget(createDockerTarget());
-        jobConfiguration.setRuleConfig(ruleConfiguration);
-        return new Gson().toJson(jobConfiguration);
+    public static StandardJDBCDataSourceConfiguration getDockerConfiguration() 
{
+        return 
getConfiguration(ENGINE_ENV_PROPS.getProperty("db.host.docker"));
     }
     
-    private static ScalingDataSourceConfigurationWrap createDockerTarget() {
+    /**
+     * Get host standard jdbc configuration.
+     *
+     * @return standard jdbc configuration
+     */
+    public static StandardJDBCDataSourceConfiguration getHostConfiguration() {
+        return getConfiguration(ENGINE_ENV_PROPS.getProperty("db.host.host"));
+    }
+    
+    private static StandardJDBCDataSourceConfiguration getConfiguration(final 
String host) {
         StandardJDBCDataSourceConfiguration configuration = new 
StandardJDBCDataSourceConfiguration(
-                String.format(TARGET_JDBC_URL, 
ENGINE_ENV_PROPS.getProperty("db.host.docker")),
+                String.format(TARGET_JDBC_URL, host),
                 ENGINE_ENV_PROPS.getProperty("db.username"), 
ENGINE_ENV_PROPS.getProperty("db.password"));
-        return configuration.wrap();
+        return configuration;
+    }
+    
+    /**
+     * Create host standard jdbc data source.
+     *
+     * @return data source
+     */
+    public static DataSource createHostDataSource() {
+        StandardJDBCDataSourceConfiguration configuration = 
TargetConfiguration.getHostConfiguration();
+        return new HikariDataSource(configuration.getHikariConfig());
     }
 }
diff --git 
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/fixture/DataImporter.java
 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/fixture/DataImporter.java
new file mode 100644
index 0000000..e132a6d
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/fixture/DataImporter.java
@@ -0,0 +1,78 @@
+/*
+ * 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.scaling.test.mysql.fixture;
+
+import lombok.SneakyThrows;
+import 
org.apache.shardingsphere.integration.scaling.test.mysql.env.ITEnvironmentContext;
+import 
org.apache.shardingsphere.integration.scaling.test.mysql.env.cases.DataSet;
+import org.apache.shardingsphere.integration.scaling.test.mysql.env.cases.Type;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+/**
+ * Data importer.
+ */
+public final class DataImporter {
+    
+    private static final String CREATE_SQL = "CREATE TABLE IF NOT EXISTS %s(id 
INT PRIMARY KEY AUTO_INCREMENT, %s %s)";
+    
+    private static final String INSERT_SQL = "INSERT INTO %s(%s) VALUES(?)";
+    
+    private final DataSet testCases = 
ITEnvironmentContext.INSTANCE.getTestCases();
+    
+    private final DataSource sourceDataSource = 
ITEnvironmentContext.INSTANCE.getSourceDataSource();
+    
+    private final DataSource targetDataSource = 
ITEnvironmentContext.INSTANCE.getTargetDataSource();
+    
+    /**
+     * Create tables.
+     */
+    public void createTables() {
+        DataSet testCases = ITEnvironmentContext.INSTANCE.getTestCases();
+        for (Type type : testCases.getTypes()) {
+            createTable(sourceDataSource, type.getTableName(), 
type.getColumnName(), type.getColumnType());
+            createTable(targetDataSource, type.getTableName(), 
type.getColumnName(), type.getColumnType());
+        }
+    }
+    
+    @SneakyThrows(SQLException.class)
+    private void createTable(final DataSource dataSource, final String 
tableName, final String columnName, final String columnType) {
+        try (Connection connection = dataSource.getConnection()) {
+            connection.prepareStatement(String.format(CREATE_SQL, tableName, 
columnName, columnType)).execute();
+        }
+    }
+    
+    /**
+     * Import data.
+     */
+    @SneakyThrows(SQLException.class)
+    public void importData() {
+        for (Type type : testCases.getTypes()) {
+            for (String value : type.getValues()) {
+                try (Connection connection = sourceDataSource.getConnection()) 
{
+                    PreparedStatement ps = 
connection.prepareStatement(String.format(INSERT_SQL, type.getTableName(), 
type.getColumnName()));
+                    ps.setString(1, value);
+                    ps.execute();
+                }
+            }
+        }
+    }
+}
diff --git 
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/fixture/FixtureWriteThread.java
 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/fixture/FixtureWriteThread.java
deleted file mode 100644
index 946fc1d..0000000
--- 
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/fixture/FixtureWriteThread.java
+++ /dev/null
@@ -1,109 +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.scaling.test.mysql.fixture;
-
-import lombok.RequiredArgsConstructor;
-import lombok.SneakyThrows;
-import 
org.apache.shardingsphere.integration.scaling.test.mysql.util.SourceShardingSphereUtil;
-
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-
-@RequiredArgsConstructor
-public final class FixtureWriteThread implements Runnable {
-    
-    private static final String INSERT_SQL = "INSERT INTO t1(c1, c2) VALUES(?, 
?)";
-    
-    private static final String UPDATE_SQL = "UPDATE t1 SET c2 = ? WHERE c1 = 
?";
-    
-    private static final String DELETE_SQL = "DELETE FROM t1 WHERE c1 = ?";
-    
-    private final long writeThreadTimeout;
-    
-    private final long writeSpawn;
-    
-    private boolean running;
-    
-    private Thread thread;
-    
-    /**
-     * Start.
-     */
-    public void start() {
-        running = true;
-        thread = new Thread(this);
-        thread.start();
-    }
-    
-    /**
-     * Stop.
-     *
-     * @throws InterruptedException interrupted exception
-     */
-    public void stop() throws InterruptedException {
-        running = false;
-        thread.interrupt();
-        thread.join();
-    }
-    
-    @SneakyThrows
-    @Override
-    public void run() {
-        long startTime = System.currentTimeMillis();
-        int idGenerator = 0;
-        DataSource dataSource = 
SourceShardingSphereUtil.createHostDataSource();
-        while (running && !checkTimeout(startTime, writeThreadTimeout)) {
-            try (Connection connection = dataSource.getConnection()) {
-                insert(connection, ++idGenerator);
-                update(connection, idGenerator);
-                insert(connection, ++idGenerator);
-                delete(connection, idGenerator);
-            }
-            try {
-                Thread.sleep(writeSpawn);
-            } catch (InterruptedException ignored) {
-            }
-        }
-    }
-    
-    private boolean checkTimeout(final long startTime, final long timeout) {
-        return timeout < System.currentTimeMillis() - startTime;
-    }
-    
-    private void insert(final Connection connection, final int id) throws 
SQLException {
-        PreparedStatement ps = connection.prepareStatement(INSERT_SQL);
-        ps.setInt(1, id);
-        ps.setString(2, Integer.toString(id));
-        ps.execute();
-    }
-    
-    private void update(final Connection connection, final int id) throws 
SQLException {
-        PreparedStatement ps = connection.prepareStatement(UPDATE_SQL);
-        ps.setString(1, Integer.toString(id + 1));
-        ps.setInt(2, id);
-        ps.execute();
-    }
-    
-    private void delete(final Connection connection, final int id) throws 
SQLException {
-        PreparedStatement ps = connection.prepareStatement(DELETE_SQL);
-        ps.setInt(1, id);
-        ps.execute();
-    }
-}
diff --git 
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/util/ScalingUtil.java
 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/util/ScalingUtil.java
index 1c34494..d70661b 100644
--- 
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/util/ScalingUtil.java
+++ 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/util/ScalingUtil.java
@@ -29,7 +29,9 @@ import okhttp3.Response;
 import 
org.apache.shardingsphere.integration.scaling.test.mysql.env.IntegrationTestEnvironment;
 
 import java.io.IOException;
+import java.util.Map;
 import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
 
 import static org.junit.Assert.assertNotNull;
 
@@ -117,10 +119,15 @@ public final class ScalingUtil {
      * @return check result
      * @throws IOException io exception
      */
-    public Tuple2<Boolean, Boolean> getJobCheckResult(final String jobId) 
throws IOException {
+    public Map<String, Tuple2<Boolean, Boolean>> getJobCheckResult(final 
String jobId) throws IOException {
         JsonElement response = getInstance().get(scalingUrl + 
"/scaling/job/check/" + jobId);
-        JsonObject result = 
response.getAsJsonObject().getAsJsonObject("model").getAsJsonObject("t1");
-        return new Tuple2<>(result.get("countValid").getAsBoolean(), 
result.get("dataValid").getAsBoolean());
+        return 
response.getAsJsonObject().getAsJsonObject("model").getAsJsonObject().entrySet().stream().collect(
+                Collectors.toMap(entry -> entry.getKey(), entry -> 
createTaskResult(entry)));
+    }
+    
+    private Tuple2<Boolean, Boolean> createTaskResult(final Map.Entry<String, 
JsonElement> entry) {
+        return new 
Tuple2<>(entry.getValue().getAsJsonObject().get("countValid").getAsBoolean(),
+                
entry.getValue().getAsJsonObject().get("dataValid").getAsBoolean());
     }
     
     /**
diff --git 
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/cases/mysql/types.xml
 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/cases/mysql/types.xml
new file mode 100644
index 0000000..220926b
--- /dev/null
+++ 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/cases/mysql/types.xml
@@ -0,0 +1,32 @@
+<!--
+  ~ 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.
+  -->
+
+<dataset>
+    <type name="int">
+        <value>0</value>
+        <value>-2147483648</value>
+        <value>2147483647</value>
+    </type>
+    <type name="varchar(1)">
+        <value></value>
+        <value>1</value>
+    </type>
+    <type name="date">
+        <value>1000-01-01</value>
+        <value>9999-12-31</value>
+    </type>
+</dataset>
diff --git 
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/env/mysql/init.sql
 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/env/mysql/init.sql
index b472226..1254957 100644
--- 
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/env/mysql/init.sql
+++ 
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/env/mysql/init.sql
@@ -19,6 +19,4 @@ CREATE USER IF NOT EXISTS 'root'@'%' IDENTIFIED BY '123456';
 GRANT All privileges ON *.* TO 'root'@'%';
 
 CREATE DATABASE ds_src;
-CREATE TABLE ds_src.t1(id INT PRIMARY KEY AUTO_INCREMENT, C1 INT NOT NULL, C2 
VARCHAR(255) NOT NULL);
 CREATE DATABASE ds_dst;
-CREATE TABLE ds_dst.t1(id INT PRIMARY KEY AUTO_INCREMENT, C1 INT NOT NULL, C2 
VARCHAR(255) NOT NULL);

Reply via email to