You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by wu...@apache.org on 2021/01/04 13:39:45 UTC

[shardingsphere] branch master updated: Add replica_query scenario for docker test (#8885)

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

wuweijie 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 27c4d25  Add replica_query scenario for docker test (#8885)
27c4d25 is described below

commit 27c4d25748d85e7f12dbcefd47d52ac3bcbe227d
Author: Liang Zhang <te...@163.com>
AuthorDate: Mon Jan 4 21:39:22 2021 +0800

    Add replica_query scenario for docker test (#8885)
---
 .../shardingsphere-test-suite/pom.xml              | 24 +++++++++
 .../docker/replica_query/docker-compose.yml        | 52 +++++++++++++++++++
 .../resources/docker/replica_query/mysql/init.sql  | 30 +++++++++++
 .../proxy/conf/config-replica-query.yaml           | 60 ++++++++++++++++++++++
 .../docker/replica_query/proxy/conf/logback.xml    | 33 ++++++++++++
 .../replica_query/proxy/conf/server.yaml}          | 52 +++++++++----------
 .../test/resources/integrate/env-docker.properties |  7 ++-
 .../test/resources/integrate/env-native.properties |  5 ++
 8 files changed, 235 insertions(+), 28 deletions(-)

diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/pom.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/pom.xml
index c3f8fe4..2d29c69 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/pom.xml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/pom.xml
@@ -138,6 +138,30 @@
                                     <!--                                    <removeImages>true</removeImages>-->
                                 </configuration>
                             </execution>
+                            
+                            <execution>
+                                <id>replica-query-up</id>
+                                <phase>pre-integration-test</phase>
+                                <goals>
+                                    <goal>up</goal>
+                                </goals>
+                                <configuration>
+                                    <composeFile>${project.basedir}/src/test/resources/docker/replica_query/docker-compose.yml</composeFile>
+                                    <detachedMode>true</detachedMode>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>replica-query-down</id>
+                                <phase>post-integration-test</phase>
+                                <goals>
+                                    <goal>down</goal>
+                                </goals>
+                                <configuration>
+                                    <composeFile>${project.basedir}/src/test/resources/docker/replica_query/docker-compose.yml</composeFile>
+                                    <removeVolumes>true</removeVolumes>
+                                    <!--                                    <removeImages>true</removeImages>-->
+                                </configuration>
+                            </execution>
                         </executions>
                     </plugin>
                 </plugins>
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/replica_query/docker-compose.yml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/replica_query/docker-compose.yml
new file mode 100644
index 0000000..5d85c6e
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/replica_query/docker-compose.yml
@@ -0,0 +1,52 @@
+#
+# 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: replica-query-mysql
+    command: --default-authentication-plugin=mysql_native_password
+    volumes:
+      - ./mysql:/docker-entrypoint-initdb.d/
+    ports:
+      - "33260:3306"
+  
+#  zookeeper:
+#    image: "zookeeper:3.6.2"
+#    container_name: replica-query-register-center
+#    ports:
+#      - "2181:23810"
+  
+  shardingsphere-proxy:
+    image: apache/shardingsphere-proxy-test
+    container_name: replica-query-shardingsphere-proxy
+    ports:
+      - "33090:3307"
+    links:
+      - "mysql:replica-query.mysql"
+#      - "zookeeper:zk"
+    volumes:
+      - ./proxy/conf:/opt/shardingsphere-proxy/conf
+    depends_on:
+      - mysql
+    environment:
+      - WAIT_HOSTS=mysql:3306
+      - WAIT_HOSTS_TIMEOUT=300
+      - WAIT_SLEEP_INTERVAL=5
+      - WAIT_HOST_CONNECT_TIMEOUT=30
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/replica_query/mysql/init.sql b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/replica_query/mysql/init.sql
new file mode 100644
index 0000000..19a2ecb
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/replica_query/mysql/init.sql
@@ -0,0 +1,30 @@
+#
+# 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 'root'@'%' IDENTIFIED BY '';
+GRANT All privileges ON *.* TO 'root'@'%';
+
+CREATE DATABASE primary_ds;
+CREATE DATABASE replica_0;
+CREATE DATABASE replica_1;
+
+CREATE TABLE primary_ds.t_order_ (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
+CREATE TABLE primary_ds.t_order_item_ (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, creation_date DATE, PRIMARY KEY (item_id));
+CREATE TABLE replica_0.t_order_ (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
+CREATE TABLE replica_0.t_order_item_ (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, creation_date DATE, PRIMARY KEY (item_id));
+CREATE TABLE replica_1.t_order_ (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
+CREATE TABLE replica_1.t_order_item_ (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, creation_date DATE, PRIMARY KEY (item_id));
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/replica_query/proxy/conf/config-replica-query.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/replica_query/proxy/conf/config-replica-query.yaml
new file mode 100644
index 0000000..4509b5b
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/replica_query/proxy/conf/config-replica-query.yaml
@@ -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.
+#
+
+schemaName: replica_query
+
+dataSources:
+  primary_ds:
+    url: jdbc:mysql://replica-query.mysql:3306/primary_ds?serverTimezone=UTC&useSSL=false
+    username: root
+    password:
+    connectionTimeoutMilliseconds: 30000
+    idleTimeoutMilliseconds: 60000
+    maxLifetimeMilliseconds: 1800000
+    maxPoolSize: 2
+    minPoolSize: 2
+    maintenanceIntervalMilliseconds: 30000
+  replica_0:
+    url: jdbc:mysql://replica-query.mysql:3306/replica_0?serverTimezone=UTC&useSSL=false
+    username: root
+    password:
+    connectionTimeoutMilliseconds: 30000
+    idleTimeoutMilliseconds: 60000
+    maxLifetimeMilliseconds: 1800000
+    maxPoolSize: 2
+    minPoolSize: 2
+    maintenanceIntervalMilliseconds: 30000
+  replica_1:
+    url: jdbc:mysql://replica-query.mysql:3306/replica_1?serverTimezone=UTC&useSSL=false
+    username: root
+    password:
+    connectionTimeoutMilliseconds: 30000
+    idleTimeoutMilliseconds: 60000
+    maxLifetimeMilliseconds: 1800000
+    maxPoolSize: 2
+    minPoolSize: 2
+    maintenanceIntervalMilliseconds: 30000
+
+rules:
+  - !REPLICA_QUERY
+    dataSources:
+      primary-replica-ds:
+        name: primary-replica-ds
+        primaryDataSourceName: primary_ds
+        replicaDataSourceNames:
+          - replica_0
+          - replica_1
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/replica_query/proxy/conf/logback.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/replica_query/proxy/conf/logback.xml
new file mode 100644
index 0000000..1494746
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/replica_query/proxy/conf/logback.xml
@@ -0,0 +1,33 @@
+<?xml version="1.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.
+  -->
+
+<configuration>
+    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %logger{36} - %msg%n</pattern>
+        </encoder>
+    </appender>
+    <logger name="org.apache.shardingsphere" level="info" additivity="false">
+        <appender-ref ref="console" />
+    </logger>
+    
+    <root>
+        <level value="info" />
+        <appender-ref ref="console" />
+    </root>
+</configuration> 
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env-docker.properties b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/replica_query/proxy/conf/server.yaml
similarity index 53%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env-docker.properties
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/replica_query/proxy/conf/server.yaml
index 77cb9de..dacea52 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env-docker.properties
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/replica_query/proxy/conf/server.yaml
@@ -15,32 +15,30 @@
 # limitations under the License.
 #
 
-it.adapters=proxy
-#it.adapters=jdbc,proxy
+#governance:
+#  name: governance_ds
+#  registryCenter:
+#    type: ZooKeeper
+#    serverLists: zk:2181
+#    props:
+#      retryIntervalMilliseconds: 500
+#      timeToLiveSeconds: 60
+#      maxRetries: 3
+#      operationTimeoutMilliseconds: 500
+#  overwrite: true
 
-it.run.additional.cases=false
-#it.scenarios=db,tbl,dbtbl_with_masterslave,masterslave,shadow
-it.scenarios=db,tbl
+authentication:
+  users:
+    root:
+      password: root
 
-#it.databases=H2,MySQL,Oracle,SQLServer,PostgreSQL
-it.databases=MySQL
-
-it.mysql.host=127.0.0.1
-it.mysql.port=33060
-it.mysql.username=root
-it.mysql.password=
-
-it.postgresql.host=127.0.0.1
-it.postgresql.port=57320
-it.postgresql.username=postgres
-it.postgresql.password=postgres
-
-it.proxy.db.host=127.0.0.1
-it.proxy.db.port=33070
-it.proxy.db.username=root
-it.proxy.db.password=root
-
-it.proxy.tbl.host=127.0.0.1
-it.proxy.tbl.port=33080
-it.proxy.tbl.username=root
-it.proxy.tbl.password=root
+props:
+  max-connections-size-per-query: 1
+  acceptor-size: 16  # The default value is available processors count * 2.
+  executor-size: 16  # Infinite by default.
+  proxy-frontend-flush-threshold: 128  # The default value is 128.
+  proxy-transaction-type: LOCAL
+  proxy-opentracing-enabled: false
+  proxy-hint-enabled: false
+  query-with-cipher-column: true
+  sql-show: false
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env-docker.properties b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env-docker.properties
index 77cb9de..37fe1e4 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env-docker.properties
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env-docker.properties
@@ -20,7 +20,7 @@ it.adapters=proxy
 
 it.run.additional.cases=false
 #it.scenarios=db,tbl,dbtbl_with_masterslave,masterslave,shadow
-it.scenarios=db,tbl
+it.scenarios=db,tbl,replica_query
 
 #it.databases=H2,MySQL,Oracle,SQLServer,PostgreSQL
 it.databases=MySQL
@@ -44,3 +44,8 @@ it.proxy.tbl.host=127.0.0.1
 it.proxy.tbl.port=33080
 it.proxy.tbl.username=root
 it.proxy.tbl.password=root
+
+it.proxy.replica_query.host=127.0.0.1
+it.proxy.replica_query.port=33090
+it.proxy.replica_query.username=root
+it.proxy.replica_query.password=root
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env-native.properties b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env-native.properties
index 0f3bf52..a926408 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env-native.properties
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/integrate/env-native.properties
@@ -53,3 +53,8 @@ it.proxy.tbl.host=127.0.0.1
 it.proxy.tbl.port=33080
 it.proxy.tbl.username=root
 it.proxy.tbl.password=root
+
+it.proxy.replica_query.host=127.0.0.1
+it.proxy.replica_query.port=33090
+it.proxy.replica_query.username=root
+it.proxy.replica_query.password=root