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 62be3f6 Add scaling integration test (#10542)
62be3f6 is described below
commit 62be3f63dc2dac1061c137e7c91089f257d6540e
Author: avalon5666 <[email protected]>
AuthorDate: Sat May 29 22:29:04 2021 +0800
Add scaling integration test (#10542)
---
.../StandardJDBCDataSourceConfiguration.java | 12 +-
.../pom.xml | 56 +++++++
.../Dockerfile | 27 +++
.../pom.xml | 182 +++++++++++++++++++++
.../src/test/assembly/bin/start.sh | 78 +++++++++
.../src/test/assembly/bin/stop.sh | 51 ++++++
.../assembly/shardingsphere-scaling-assembly.xml | 44 +++++
.../integration/scaling/test/mysql/ScalingIT.java | 43 +++++
.../test/mysql/env/IntegrationTestEnvironment.java | 88 ++++++++++
.../scaling/test/mysql/util/ScalingUtil.java | 108 ++++++++++++
.../test/mysql/util/SourceShardingSphereUtil.java | 98 +++++++++++
.../test/mysql/util/TargetDataSourceUtil.java | 60 +++++++
.../src/test/resources/docker/docker-compose.yml | 72 ++++++++
.../test/resources/docker/scaling/conf/server.yaml | 27 +++
.../src/test/resources/env/engine-env.properties | 27 +++
.../src/test/resources/env/mysql/init.sql | 24 +++
16 files changed, 996 insertions(+), 1 deletion(-)
diff --git
a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/StandardJDBCDataSourceConfiguration.java
b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/StandardJDBCDataSourceConfiguration.java
index b89821a..c8e042c 100644
---
a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/StandardJDBCDataSourceConfiguration.java
+++
b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/config/datasource/StandardJDBCDataSourceConfiguration.java
@@ -26,6 +26,8 @@ import
org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
import javax.sql.DataSource;
+import java.util.HashMap;
+import java.util.Map;
/**
* Standard JDBC data source configuration.
@@ -54,10 +56,18 @@ public final class StandardJDBCDataSourceConfiguration
implements ScalingDataSou
public StandardJDBCDataSourceConfiguration(final String jdbcUrl, final
String username, final String password) {
HikariConfig hikariConfig = getHikariConfig(jdbcUrl, username,
password);
this.hikariConfig = hikariConfig;
- this.parameter = YamlEngine.marshal(hikariConfig);
+ this.parameter = wrapParameter(jdbcUrl, username, password);
databaseType = DatabaseTypeRegistry.getDatabaseTypeByURL(jdbcUrl);
}
+ private String wrapParameter(final String jdbcUrl, final String username,
final String password) {
+ Map<String, String> parameter = new HashMap<>(3);
+ parameter.put("jdbcUrl", jdbcUrl);
+ parameter.put("username", username);
+ parameter.put("password", password);
+ return YamlEngine.marshal(parameter);
+ }
+
private HikariConfig getHikariConfig(final String jdbcUrl, final String
username, final String password) {
HikariConfig result = new HikariConfig();
result.setJdbcUrl(jdbcUrl);
diff --git
a/shardingsphere-test/shardingsphere-integration-scaling-test/pom.xml
b/shardingsphere-test/shardingsphere-integration-scaling-test/pom.xml
new file mode 100644
index 0000000..9fe3ab5
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-scaling-test/pom.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>shardingsphere-test</artifactId>
+ <groupId>org.apache.shardingsphere</groupId>
+ <version>5.0.0-RC1-SNAPSHOT</version>
+ </parent>
+ <artifactId>shardingsphere-integration-scaling-test</artifactId>
+ <packaging>pom</packaging>
+ <name>${project.artifactId}</name>
+
+ <modules>
+ </modules>
+
+ <properties>
+ <maven.deploy.skip>true</maven.deploy.skip>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>integration-tests</id>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/Dockerfile
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/Dockerfile
new file mode 100644
index 0000000..8f60721
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/Dockerfile
@@ -0,0 +1,27 @@
+#
+# 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.
+#
+
+FROM openjdk:8-jdk-alpine
+
+ARG APP_NAME
+ENV WAIT_VERSION 2.7.2
+
+ADD
https://github.com/ufoscout/docker-compose-wait/releases/download/$WAIT_VERSION/wait
/wait
+RUN chmod +x /wait
+ADD target/${APP_NAME}.tar.gz /opt
+RUN mv /opt/${APP_NAME} /opt/shardingsphere-scaling
+ENTRYPOINT /wait && /opt/shardingsphere-scaling/bin/start.sh && tail -f
/opt/shardingsphere-scaling/logs/stdout.log
diff --git
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/pom.xml
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/pom.xml
new file mode 100644
index 0000000..5f31764
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/pom.xml
@@ -0,0 +1,182 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-integration-scaling-test</artifactId>
+ <version>5.0.0-RC1-SNAPSHOT</version>
+ </parent>
+ <artifactId>shardingsphere-integration-scaling-test-mysql</artifactId>
+ <name>${project.artifactId}</name>
+
+ <properties>
+ <maven.deploy.skip>true</maven.deploy.skip>
+ <gson.version>2.8.0</gson.version>
+ <okhttp.version>3.7.0</okhttp.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-scaling-bootstrap</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.squareup.okhttp3</groupId>
+ <artifactId>okhttp</artifactId>
+ <version>${okhttp.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>${gson.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>it.env.scaling</id>
+ <properties>
+ <it.env>scaling</it.env>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <descriptors>
+
<descriptor>src/test/assembly/shardingsphere-scaling-assembly.xml</descriptor>
+ </descriptors>
+ </configuration>
+ <executions>
+ <execution>
+ <id>assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.spotify</groupId>
+ <artifactId>dockerfile-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>shardingsphere-scaling-bin</id>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+
<repository>apache/shardingsphere-scaling-test</repository>
+ <tag>${project.version}</tag>
+ <tag>latest</tag>
+ <buildArgs>
+ <APP_NAME>${project.build.finalName}</APP_NAME>
+ </buildArgs>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>com.dkanejs.maven.plugins</groupId>
+ <artifactId>docker-compose-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>agent-metrics-up</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>up</goal>
+ </goals>
+ <configuration>
+
<composeFile>${project.basedir}/src/test/resources/docker/docker-compose.yml</composeFile>
+ <detachedMode>true</detachedMode>
+ </configuration>
+ </execution>
+ <execution>
+ <id>agent-metrics-down</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>down</goal>
+ </goals>
+ <configuration>
+
<composeFile>${project.basedir}/src/test/resources/docker/docker-compose.yml</composeFile>
+ <removeVolumes>true</removeVolumes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>integration-tests</id>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-resources</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+
<outputDirectory>target/test-classes</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/assembly/bin/start.sh
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/assembly/bin/start.sh
new file mode 100644
index 0000000..777e490
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/assembly/bin/start.sh
@@ -0,0 +1,78 @@
+#!/bin/sh
+#
+# 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.
+#
+
+SERVER_NAME=ShardingSphere-Scaling
+
+cd `dirname $0`
+cd ..
+DEPLOY_DIR=`pwd`
+
+LOGS_DIR=${DEPLOY_DIR}/logs
+if [ ! -d ${LOGS_DIR} ]; then
+ mkdir ${LOGS_DIR}
+fi
+
+STDOUT_FILE=${LOGS_DIR}/stdout.log
+EXT_LIB=${DEPLOY_DIR}/ext-lib
+
+CLASS_PATH=.:${DEPLOY_DIR}/lib/*:${EXT_LIB}/*
+
+JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=3308"
+
+JAVA_MEM_OPTS=" -server -Xmx2g -Xms2g -Xmn1g -Xss256k -XX:+DisableExplicitGC
-XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled
-XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods
-XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
+
+if [ "server" = "${BOOTSTRAP_TYPE}" ]; then
+ MAIN_CLASS=org.apache.shardingsphere.scaling.ScalingServerBootstrap
+elif [ "worker" = "${BOOTSTRAP_TYPE}" ]; then
+ MAIN_CLASS=org.apache.shardingsphere.scaling.ScalingWorkerBootstrap
+else
+ echo 'Please set the BOOTSTRAP_TYPE(server/worker) in the environment
variable'
+ exit 1
+fi
+
+print_usage() {
+ echo "usage: start.sh [port] [config_dir]"
+ echo " port: scaling listen port, default is 8888"
+ echo " config_dir: scaling config directory, default is conf"
+ exit 0
+}
+
+if [ "$1" == "-h" ] || [ "$1" == "--help" ] ; then
+ print_usage
+fi
+
+echo "Starting the $SERVER_NAME ..."
+
+if [ $# == 1 ]; then
+ MAIN_CLASS=${MAIN_CLASS}" "$1
+ echo "The port is $1"
+ CLASS_PATH=${DEPLOY_DIR}/conf:${CLASS_PATH}
+fi
+
+if [ $# == 2 ]; then
+ MAIN_CLASS=${MAIN_CLASS}" "$1" "$2
+ echo "The port is $1"
+ echo "The configuration path is $DEPLOY_DIR/$2"
+ CLASS_PATH=${DEPLOY_DIR}/$2:${CLASS_PATH}
+fi
+
+echo "The classpath is ${CLASS_PATH}"
+
+nohup java ${JAVA_OPTS} ${JAVA_MEM_OPTS} -classpath ${CLASS_PATH}
${MAIN_CLASS} >> ${STDOUT_FILE} 2>&1 &
+sleep 1
+echo "Please check the STDOUT file: $STDOUT_FILE"
diff --git
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/assembly/bin/stop.sh
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/assembly/bin/stop.sh
new file mode 100644
index 0000000..132e2f1
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/assembly/bin/stop.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# 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.
+#
+
+SERVER_NAME=ShardingSphere-Scaling
+
+cd `dirname $0`
+cd ..
+DEPLOY_DIR=`pwd`
+
+PIDS=`ps -ef | grep java | grep "$DEPLOY_DIR" | grep -v grep |awk '{print $2}'`
+if [ -z "$PIDS" ]; then
+ echo "ERROR: The $SERVER_NAME does not started!"
+ exit 1
+fi
+
+echo -e "Stopping the $SERVER_NAME ...\c"
+for PID in ${PIDS} ; do
+ kill ${PID} > /dev/null 2>&1
+done
+
+COUNT=0
+while [ ${COUNT} -lt 1 ]; do
+ echo -e ".\c"
+ sleep 1
+ COUNT=1
+ for PID in ${PIDS} ; do
+ PID_EXIST=`ps -f -p ${PID} | grep java`
+ if [ -n "$PID_EXIST" ]; then
+ COUNT=0
+ break
+ fi
+ done
+done
+
+echo "OK!"
+echo "PID: $PIDS"
diff --git
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/assembly/shardingsphere-scaling-assembly.xml
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/assembly/shardingsphere-scaling-assembly.xml
new file mode 100644
index 0000000..6dadef1
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/assembly/shardingsphere-scaling-assembly.xml
@@ -0,0 +1,44 @@
+<!--
+ ~ 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.
+ -->
+
+<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0
http://maven.apache.org/xsd/assembly-2.0.0.xsd">
+ <id>shardingsphere-scaling-bin</id>
+ <formats>
+ <format>tar.gz</format>
+ </formats>
+ <includeBaseDirectory>true</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>src/test/assembly/bin</directory>
+ <lineEnding>unix</lineEnding>
+ <includes>
+ <include>*.sh</include>
+ </includes>
+ <outputDirectory>bin</outputDirectory>
+ <fileMode>0755</fileMode>
+ </fileSet>
+ </fileSets>
+
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>lib</outputDirectory>
+ <fileMode>0644</fileMode>
+ </dependencySet>
+ </dependencySets>
+</assembly>
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
new file mode 100644
index 0000000..0f85046
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/ScalingIT.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.integration.scaling.test.mysql;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import
org.apache.shardingsphere.integration.scaling.test.mysql.env.IntegrationTestEnvironment;
+import
org.apache.shardingsphere.integration.scaling.test.mysql.util.ScalingUtil;
+import
org.apache.shardingsphere.integration.scaling.test.mysql.util.TargetDataSourceUtil;
+import org.apache.shardingsphere.scaling.web.entity.ResponseContent;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+@Slf4j
+public final class ScalingIT {
+
+ @SneakyThrows
+ @Test
+ public void assertScaling() {
+ if (IntegrationTestEnvironment.getInstance().isEnvironmentPrepared()) {
+ IntegrationTestEnvironment.getInstance().waitForEnvironmentReady();
+ String body = TargetDataSourceUtil.createDockerConfigurations();
+ ResponseContent<String> startResponse =
ScalingUtil.getInstance().startJob(body);
+ assertTrue(startResponse.isSuccess());
+ }
+ }
+}
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/IntegrationTestEnvironment.java
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/IntegrationTestEnvironment.java
new file mode 100644
index 0000000..8cd46ec
--- /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/IntegrationTestEnvironment.java
@@ -0,0 +1,88 @@
+/*
+ * 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 lombok.Getter;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import
org.apache.shardingsphere.integration.scaling.test.mysql.util.ScalingUtil;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+@Getter
+@Slf4j
+public final class IntegrationTestEnvironment {
+
+ private static final IntegrationTestEnvironment INSTANCE = new
IntegrationTestEnvironment();
+
+ private final boolean isEnvironmentPrepared;
+
+ private Properties engineEnvProps;
+
+ @SneakyThrows
+ private IntegrationTestEnvironment() {
+ engineEnvProps = loadProperties("env/engine-env.properties");
+ isEnvironmentPrepared =
engineEnvProps.getProperty("it.env.value").equals(engineEnvProps.getProperty("it.env.type"));
+ }
+
+ private Properties loadProperties(final String propsFileName) {
+ Properties result = new Properties();
+ try (InputStream inputStream =
IntegrationTestEnvironment.class.getClassLoader().getResourceAsStream(propsFileName))
{
+ 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");
+ int retryCount = 0;
+ while (!isScalingReady(engineEnvProps) && retryCount <
Integer.parseInt(engineEnvProps.getProperty("scaling.retry", "30"))) {
+ try {
+
Thread.sleep(Long.parseLong(engineEnvProps.getProperty("scaling.waitMs",
"1000")));
+ } catch (final InterruptedException ignore) {
+ }
+ retryCount++;
+ }
+ }
+
+ private boolean isScalingReady(final Properties engineEnvProps) {
+ try {
+ ScalingUtil.getInstance().getJobList();
+ } catch (final IOException ignore) {
+ return false;
+ }
+ log.info("it scaling environment success");
+ return true;
+ }
+
+ /**
+ * Get instance.
+ *
+ * @return singleton instance
+ */
+ public static IntegrationTestEnvironment getInstance() {
+ return INSTANCE;
+ }
+}
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
new file mode 100644
index 0000000..bf4bd49
--- /dev/null
+++
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
@@ -0,0 +1,108 @@
+/*
+ * 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.util;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import okhttp3.MediaType;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+import
org.apache.shardingsphere.integration.scaling.test.mysql.env.IntegrationTestEnvironment;
+import org.apache.shardingsphere.scaling.web.entity.ResponseContent;
+
+import java.io.IOException;
+import java.lang.reflect.Type;
+import java.util.concurrent.TimeUnit;
+
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Ok http utils.
+ */
+public final class ScalingUtil {
+
+ private static final ScalingUtil OK_HTTP_UTILS = new ScalingUtil();
+
+ private static final Gson GSON = new Gson();
+
+ private final OkHttpClient client;
+
+ private final String scalingUrl;
+
+ private ScalingUtil() {
+ scalingUrl =
IntegrationTestEnvironment.getInstance().getEngineEnvProps().getProperty("scaling.url");
+ OkHttpClient.Builder builder = new OkHttpClient.Builder();
+ builder.connectTimeout(10, TimeUnit.SECONDS);
+ builder.readTimeout(10, TimeUnit.SECONDS);
+ builder.writeTimeout(10, TimeUnit.SECONDS);
+ client = builder.build();
+ }
+
+ /**
+ * Get instance.
+ *
+ * @return instance
+ */
+ public static ScalingUtil getInstance() {
+ return OK_HTTP_UTILS;
+ }
+
+ private <T> T get(final String url, final Type type) throws IOException {
+ Request request = new Request.Builder().url(url).build();
+ Response response = client.newCall(request).execute();
+ assertNotNull(response.body());
+ String result = response.body().string();
+ return GSON.fromJson(result, type);
+ }
+
+ private <T> T post(final String url, final String body, final Type type)
throws IOException {
+ RequestBody requestBody =
RequestBody.create(MediaType.parse("application/json"), body);
+ Request request = new
Request.Builder().url(url).post(requestBody).build();
+ Response response = client.newCall(request).execute();
+ assertNotNull(response.body());
+ String result = response.body().string();
+ return GSON.fromJson(result, type);
+ }
+
+ /**
+ * Start job.
+ *
+ * @param configuration configuration
+ * @return response
+ * @throws IOException io exception
+ */
+ public ResponseContent<String> startJob(final String configuration) throws
IOException {
+ return getInstance().post(scalingUrl + "/scaling/job/start",
configuration, new TypeToken<ResponseContent<String>>() {
+
+ }.getType());
+ }
+
+ /**
+ * Get job list.
+ *
+ * @return job list
+ * @throws IOException io exception
+ */
+ public ResponseContent<String> getJobList() throws IOException {
+ return getInstance().get(scalingUrl + "/scaling/job/list", new
TypeToken<ResponseContent<Object[]>>() {
+
+ }.getType());
+ }
+}
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/util/SourceShardingSphereUtil.java
new file mode 100644
index 0000000..7374744
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/util/SourceShardingSphereUtil.java
@@ -0,0 +1,98 @@
+/*
+ * 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.util;
+
+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.swapper.YamlDataSourceConfigurationSwapper;
+import
org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine;
+import
org.apache.shardingsphere.integration.scaling.test.mysql.env.IntegrationTestEnvironment;
+import
org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration;
+import
org.apache.shardingsphere.sharding.yaml.config.rule.YamlTableRuleConfiguration;
+
+import javax.sql.DataSource;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Source sharding sphere util.
+ */
+public final class SourceShardingSphereUtil {
+
+ 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.
+ *
+ * @return yaml root rule configurations
+ */
+ public static YamlRootRuleConfigurations createDockerConfigurations() {
+ return createConfigurations(String.format(SOURCE_JDBC_URL,
ENGINE_ENV_PROPS.getProperty("db.host.docker")));
+ }
+
+ /**
+ * Create host sharding jdbc configurations.
+ *
+ * @return yaml root rule configurations
+ */
+ public static YamlRootRuleConfigurations createHostConfigurations() {
+ return createConfigurations(String.format(SOURCE_JDBC_URL,
ENGINE_ENV_PROPS.getProperty("db.host.host")));
+ }
+
+ private static YamlRootRuleConfigurations createConfigurations(final
String jdbcUrl) {
+ YamlRootRuleConfigurations result = new YamlRootRuleConfigurations();
+ Map dataSources = ImmutableMap.builder().put("ds_src",
ImmutableMap.builder()
+ .put("dataSourceClassName",
"com.zaxxer.hikari.HikariDataSource")
+ .put("jdbcUrl", jdbcUrl)
+ .put("username", ENGINE_ENV_PROPS.getProperty("db.username"))
+ .put("password", ENGINE_ENV_PROPS.getProperty("db.password"))
+ .build()).build();
+ result.setDataSources(dataSources);
+ YamlShardingRuleConfiguration shardingRuleConfiguration = new
YamlShardingRuleConfiguration();
+ shardingRuleConfiguration.setTables(createTableRules());
+ 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.
+ *
+ * @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);
+ }
+}
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/util/TargetDataSourceUtil.java
new file mode 100644
index 0000000..030758a
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/util/TargetDataSourceUtil.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.integration.scaling.test.mysql.util;
+
+import com.google.gson.Gson;
+import org.apache.shardingsphere.infra.yaml.engine.YamlEngine;
+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 java.util.Properties;
+
+/**
+ * Target data source util.
+ */
+public final class TargetDataSourceUtil {
+
+ 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.
+ *
+ * @return scaling job configurations
+ */
+ 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);
+ }
+
+ private static ScalingDataSourceConfigurationWrap createDockerTarget() {
+ StandardJDBCDataSourceConfiguration configuration = new
StandardJDBCDataSourceConfiguration(
+ String.format(TARGET_JDBC_URL,
ENGINE_ENV_PROPS.getProperty("db.host.docker")),
+ ENGINE_ENV_PROPS.getProperty("db.username"),
ENGINE_ENV_PROPS.getProperty("db.password"));
+ return configuration.wrap();
+ }
+}
diff --git
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/docker/docker-compose.yml
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/docker/docker-compose.yml
new file mode 100644
index 0000000..6c6a749
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/docker/docker-compose.yml
@@ -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.
+#
+
+version: "2.1"
+
+services:
+ mysql:
+ image: "mysql/mysql-server:5.7"
+ container_name: scaling-mysql
+ command: ['--server-id=1', '--log_bin=mysql-bin']
+ volumes:
+ - ../env/mysql:/docker-entrypoint-initdb.d/
+ ports:
+ - "13306:3306"
+ environment:
+ - LANG=C.UTF-8
+
+ zookeeper:
+ image: "zookeeper:3.6.2"
+ container_name: scaling-zookeeper
+ ports:
+ - "12181:2181"
+
+ shardingsphere-scaling-server:
+ image: apache/shardingsphere-scaling-test
+ container_name: shardingsphere-scaling-server
+ ports:
+ - "18888:8888"
+ links:
+ - "mysql:scaling-mysql"
+ - "zookeeper:scaling-zookeeper"
+ volumes:
+ - ./scaling/conf:/opt/shardingsphere-scaling/conf
+ depends_on:
+ - zookeeper
+ environment:
+ - WAIT_HOSTS=mysql:3306,zookeeper:2181
+ - WAIT_HOSTS_TIMEOUT=300
+ - WAIT_SLEEP_INTERVAL=5
+ - WAIT_HOST_CONNECT_TIMEOUT=30
+ - BOOTSTRAP_TYPE=server
+
+ shardingsphere-scaling-worker:
+ image: apache/shardingsphere-scaling-test
+ container_name: shardingsphere-scaling-worker
+ links:
+ - "mysql:scaling-mysql"
+ - "zookeeper:scaling-zookeeper"
+ volumes:
+ - ./scaling/conf:/opt/shardingsphere-scaling/conf
+ depends_on:
+ - zookeeper
+ environment:
+ - WAIT_HOSTS=mysql:3306,zookeeper:2181
+ - WAIT_HOSTS_TIMEOUT=300
+ - WAIT_SLEEP_INTERVAL=5
+ - WAIT_HOST_CONNECT_TIMEOUT=30
+ - BOOTSTRAP_TYPE=worker
diff --git
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/docker/scaling/conf/server.yaml
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/docker/scaling/conf/server.yaml
new file mode 100644
index 0000000..4ec98bf
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/docker/scaling/conf/server.yaml
@@ -0,0 +1,27 @@
+#
+# 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.
+#
+
+scaling:
+ port: 8888
+ blockQueueSize: 10000
+ workerThread: 30
+
+governance:
+ name: governance_ds
+ registryCenter:
+ type: ZooKeeper
+ serverLists: zookeeper:2181
diff --git
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/env/engine-env.properties
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/env/engine-env.properties
new file mode 100644
index 0000000..5817727
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/env/engine-env.properties
@@ -0,0 +1,27 @@
+#
+# 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.
+#
+
+it.env.type=${it.env}
+it.env.value=scaling
+
+db.host.docker=mysql:3306
+db.host.host=127.0.0.1:13306
+db.username=root
+db.password=123456
+scaling.url=http://127.0.0.1:18888
+scaling.retry=30
+scaling.waitMs=1000
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
new file mode 100644
index 0000000..b472226
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/resources/env/mysql/init.sql
@@ -0,0 +1,24 @@
+--
+-- 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.
+--
+
+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);