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

[shardingsphere] branch master updated: Add tbl scenario test for docker env (#8884)

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

panjuan 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 1fe4438  Add tbl scenario test for docker env (#8884)
1fe4438 is described below

commit 1fe4438187007240d6e2cc71f908d933770d0bd3
Author: Liang Zhang <te...@163.com>
AuthorDate: Mon Jan 4 20:26:20 2021 +0800

    Add tbl scenario test for docker env (#8884)
    
    * Add tbl scenario test for docker env
    
    * Unify interal proxy port
---
 .../shardingsphere-test-suite/pom.xml              | 24 ++++++++
 .../resources/docker/db/proxy/conf/server.yaml     |  3 -
 .../test/resources/docker/tbl/docker-compose.yml   | 52 +++++++++++++++++
 .../src/test/resources/docker/tbl/mysql/init.sql   | 42 ++++++++++++++
 .../docker/tbl/proxy/conf/config-tbl.yaml          | 65 ++++++++++++++++++++++
 .../resources/docker/tbl/proxy/conf/logback.xml    | 33 +++++++++++
 .../docker/{db => tbl}/proxy/conf/server.yaml      |  3 -
 .../test/resources/integrate/env-docker.properties |  7 ++-
 .../test/resources/integrate/env-native.properties |  5 ++
 9 files changed, 227 insertions(+), 7 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 43c6a62..c3f8fe4 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/pom.xml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/pom.xml
@@ -114,6 +114,30 @@
 <!--                                    <removeImages>true</removeImages>-->
                                 </configuration>
                             </execution>
+                            
+                            <execution>
+                                <id>tbl-up</id>
+                                <phase>pre-integration-test</phase>
+                                <goals>
+                                    <goal>up</goal>
+                                </goals>
+                                <configuration>
+                                    <composeFile>${project.basedir}/src/test/resources/docker/tbl/docker-compose.yml</composeFile>
+                                    <detachedMode>true</detachedMode>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>tbl-down</id>
+                                <phase>post-integration-test</phase>
+                                <goals>
+                                    <goal>down</goal>
+                                </goals>
+                                <configuration>
+                                    <composeFile>${project.basedir}/src/test/resources/docker/tbl/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/db/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/db/proxy/conf/server.yaml
index e4c6fed..dacea52 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/db/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/db/proxy/conf/server.yaml
@@ -31,9 +31,6 @@ authentication:
   users:
     root:
       password: root
-    sharding:
-      password: sharding
-      authorizedSchemas: sharding_db
 
 props:
   max-connections-size-per-query: 1
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/tbl/docker-compose.yml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/tbl/docker-compose.yml
new file mode 100644
index 0000000..3365839
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/tbl/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: tbl-mysql
+    command: --default-authentication-plugin=mysql_native_password
+    volumes:
+      - ./mysql:/docker-entrypoint-initdb.d/
+    ports:
+      - "33160:3306"
+  
+#  zookeeper:
+#    image: "zookeeper:3.6.2"
+#    container_name: tbl-register-center
+#    ports:
+#      - "2181:22810"
+  
+  shardingsphere-proxy:
+    image: apache/shardingsphere-proxy-test
+    container_name: tbl-shardingsphere-proxy
+    ports:
+      - "33080:3307"
+    links:
+      - "mysql:tbl.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/tbl/mysql/init.sql b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/tbl/mysql/init.sql
new file mode 100644
index 0000000..de8f640
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/tbl/mysql/init.sql
@@ -0,0 +1,42 @@
+#
+# 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 tbl;
+
+CREATE TABLE tbl.t_order_0 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
+CREATE TABLE tbl.t_order_item_0 (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 tbl.t_order_1 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
+CREATE TABLE tbl.t_order_item_1 (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 tbl.t_order_2 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
+CREATE TABLE tbl.t_order_item_2 (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 tbl.t_order_3 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
+CREATE TABLE tbl.t_order_item_3 (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 tbl.t_order_4 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
+CREATE TABLE tbl.t_order_item_4 (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 tbl.t_order_5 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
+CREATE TABLE tbl.t_order_item_5 (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 tbl.t_order_6 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
+CREATE TABLE tbl.t_order_item_6 (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 tbl.t_order_7 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
+CREATE TABLE tbl.t_order_item_7 (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 tbl.t_order_8 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
+CREATE TABLE tbl.t_order_item_8 (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 tbl.t_order_9 (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
+CREATE TABLE tbl.t_order_item_9 (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/tbl/proxy/conf/config-tbl.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/tbl/proxy/conf/config-tbl.yaml
new file mode 100644
index 0000000..655ed02
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/tbl/proxy/conf/config-tbl.yaml
@@ -0,0 +1,65 @@
+#
+# 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: tbl
+
+dataSources:
+  tbl:
+    url: jdbc:mysql://tbl.mysql:3306/tbl?serverTimezone=UTC&useSSL=false
+    username: root
+    password:
+    connectionTimeoutMilliseconds: 30000
+    idleTimeoutMilliseconds: 60000
+    maxLifetimeMilliseconds: 1800000
+    maxPoolSize: 2
+    minPoolSize: 2
+    maintenanceIntervalMilliseconds: 30000
+
+rules:
+  - !SHARDING
+    tables:
+      t_order:
+        actualDataNodes: tbl.t_order_${0..9}
+        tableStrategy:
+          standard:
+            shardingColumn: order_id
+            shardingAlgorithmName: standard_test
+      t_order_item:
+        actualDataNodes: tbl.t_order_item_${0..9}
+        tableStrategy:
+          standard:
+            shardingColumn: order_id
+            shardingAlgorithmName: standard_test
+        keyGenerateStrategy:
+          column: item_id
+          keyGeneratorName: constant
+      t_order_details:
+        actualDataNodes: tbl.t_order_details_${0..9}
+        tableStrategy:
+          standard:
+            shardingColumn: order_id
+            shardingAlgorithmName: standard_test
+    bindingTables:
+      - t_order,t_order_item
+    
+    shardingAlgorithms:
+      standard_test:
+        type: STANDARD_TEST
+    
+    keyGenerators:
+      constant:
+        type: Constant
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/tbl/proxy/conf/logback.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/tbl/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/tbl/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/docker/db/proxy/conf/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/tbl/proxy/conf/server.yaml
similarity index 95%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/db/proxy/conf/server.yaml
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/tbl/proxy/conf/server.yaml
index e4c6fed..dacea52 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/db/proxy/conf/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-test-suite/src/test/resources/docker/tbl/proxy/conf/server.yaml
@@ -31,9 +31,6 @@ authentication:
   users:
     root:
       password: root
-    sharding:
-      password: sharding
-      authorizedSchemas: sharding_db
 
 props:
   max-connections-size-per-query: 1
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 cfad73c..77cb9de 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
+it.scenarios=db,tbl
 
 #it.databases=H2,MySQL,Oracle,SQLServer,PostgreSQL
 it.databases=MySQL
@@ -39,3 +39,8 @@ 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
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 e8157a1..0f3bf52 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
@@ -48,3 +48,8 @@ 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