You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/09/26 11:09:25 UTC

[shardingsphere] branch master updated: Add more assertions to CREATE/ALTER/DROP SHARDING TABLE RULE (#21199)

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

duanzhengqiang 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 4a63b3f6eb9 Add more assertions to CREATE/ALTER/DROP SHARDING TABLE RULE (#21199)
4a63b3f6eb9 is described below

commit 4a63b3f6eb9fd7820387df8c5aafaac61a48690e
Author: zhaojinchao <zh...@apache.org>
AuthorDate: Mon Sep 26 19:09:17 2022 +0800

    Add more assertions to CREATE/ALTER/DROP SHARDING TABLE RULE (#21199)
    
    * Add more assertions to CREATE/ALTER/DROP SHARDING TABLE RULE
    
    * add new line
---
 .../alter_sharding_rules_show_tables.xml           | 25 +++++++++++++++++++
 .../create_sharding_rules_show_tables.xml          | 27 +++++++++++++++++++++
 .../drop_sharding_rules_show_tables.xml            | 28 ++++++++++++++++++++++
 .../cases/rdl/rdl-integration-test-cases.xml       | 19 ++++++++++++---
 .../data/actual/init-sql/mysql/01-actual-init.sql  | 12 +++++++---
 5 files changed, 105 insertions(+), 6 deletions(-)

diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rdl/dataset/rdl_empty_rules/alter_sharding_rules_show_tables.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rdl/dataset/rdl_empty_rules/alter_sharding_rules_show_tables.xml
new file mode 100644
index 00000000000..0d0c6d5a217
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rdl/dataset/rdl_empty_rules/alter_sharding_rules_show_tables.xml
@@ -0,0 +1,25 @@
+<!--
+  ~ 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>
+    <metadata>
+        <column name="Tables_in_rdl_empty_rules" />
+        <column name="Table_type" />
+    </metadata>
+    <row values="t_user_4| BASE TABLE" />
+    <row values="t_user| BASE TABLE" />
+</dataset>
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rdl/dataset/rdl_empty_rules/create_sharding_rules_show_tables.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rdl/dataset/rdl_empty_rules/create_sharding_rules_show_tables.xml
new file mode 100644
index 00000000000..d1e48d75112
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rdl/dataset/rdl_empty_rules/create_sharding_rules_show_tables.xml
@@ -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.
+  -->
+
+<dataset>
+    <metadata>
+        <column name="Tables_in_rdl_empty_rules" />
+        <column name="Table_type" />
+    </metadata>
+    <row values="t_user_4| BASE TABLE" />
+    <row values="t_user_3| BASE TABLE" />
+    <row values="t_user_2| BASE TABLE" />
+    <row values="t_user| BASE TABLE" />
+</dataset>
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rdl/dataset/rdl_empty_rules/drop_sharding_rules_show_tables.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rdl/dataset/rdl_empty_rules/drop_sharding_rules_show_tables.xml
new file mode 100644
index 00000000000..5b41447eb1d
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rdl/dataset/rdl_empty_rules/drop_sharding_rules_show_tables.xml
@@ -0,0 +1,28 @@
+<!--
+  ~ 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>
+    <metadata>
+        <column name="Tables_in_rdl_empty_rules" />
+        <column name="Table_type" />
+    </metadata>
+    <row values="t_user_4| BASE TABLE" />
+    <row values="t_user_3| BASE TABLE" />
+    <row values="t_user_2| BASE TABLE" />
+    <row values="t_user_1| BASE TABLE" />
+    <row values="t_user_0| BASE TABLE" />
+</dataset>
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rdl/rdl-integration-test-cases.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rdl/rdl-integration-test-cases.xml
index 2fa19f96280..70d03da84c6 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rdl/rdl-integration-test-cases.xml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/rdl/rdl-integration-test-cases.xml
@@ -31,20 +31,33 @@
 <!--            <assertion-sql sql="SHOW DATABASE RESOURCES" />-->
 <!--        </assertion>-->
 <!--    </test-case>-->
-    <test-case sql="CREATE SHARDING TABLE RULE t_user (DATANODES('ds_0.t_user_${0..1}'),TABLE_STRATEGY(TYPE='standard',SHARDING_COLUMN=user_id,SHARDING_ALGORITHM(TYPE(NAME='inline',PROPERTIES('algorithm-expression'='t_user_${user_id % 2}')))))" db-types="MySQL, PostgreSQL">
+    <test-case sql="CREATE SHARDING TABLE RULE t_user (DATANODES('ds_0.t_user_${0..1}'),TABLE_STRATEGY(TYPE='standard',SHARDING_COLUMN=user_id,SHARDING_ALGORITHM(TYPE(NAME='inline',PROPERTIES('algorithm-expression'='t_user_${user_id % 2}')))))" db-types="MySQL">
         <assertion expected-data-file="create_sharding_rules.xml">
             <assertion-sql sql="SHOW SHARDING TABLE RULES;" />
+            <destroy-sql sql="DROP SHARDING TABLE RULE t_user"/>
+        </assertion>
+        <assertion expected-data-file="create_sharding_rules_show_tables.xml">
+            <assertion-sql sql="SHOW TABLES;" />
         </assertion>
     </test-case>
-    <test-case sql="ALTER SHARDING TABLE RULE t_user (DATANODES('ds_0.t_user_${0..3}'),TABLE_STRATEGY(TYPE='standard',SHARDING_COLUMN=user_id,SHARDING_ALGORITHM(TYPE(NAME='inline',PROPERTIES('algorithm-expression'='t_user_${user_id % 4}')))))" db-types="MySQL, PostgreSQL">
+    <test-case sql="ALTER SHARDING TABLE RULE t_user (DATANODES('ds_0.t_user_${0..3}'),TABLE_STRATEGY(TYPE='standard',SHARDING_COLUMN=user_id,SHARDING_ALGORITHM(TYPE(NAME='inline',PROPERTIES('algorithm-expression'='t_user_${user_id % 4}')))))" db-types="MySQL">
         <assertion expected-data-file="alter_sharding_rules.xml">
             <assertion-sql sql="SHOW SHARDING TABLE RULES;" />
+            <destroy-sql sql="DROP SHARDING TABLE RULE t_user"/>
+        </assertion>
+        <assertion expected-data-file="alter_sharding_rules_show_tables.xml">
+            <initial-sql sql="CREATE SHARDING TABLE RULE t_user (DATANODES('ds_0.t_user_${0..1}'),TABLE_STRATEGY(TYPE='standard',SHARDING_COLUMN=user_id,SHARDING_ALGORITHM(TYPE(NAME='inline',PROPERTIES('algorithm-expression'='t_user_${user_id % 2}')))))" />
+            <assertion-sql sql="SHOW TABLES;" />
         </assertion>
     </test-case>
-    <test-case sql="DROP SHARDING TABLE RULE t_user" db-types="MySQL, PostgreSQL">
+    <test-case sql="DROP SHARDING TABLE RULE t_user" db-types="MySQL">
         <assertion expected-data-file="drop_sharding_rules.xml">
             <assertion-sql sql="SHOW SHARDING TABLE RULES;" />
         </assertion>
+        <assertion expected-data-file="drop_sharding_rules_show_tables.xml">
+            <initial-sql sql="CREATE SHARDING TABLE RULE t_user (DATANODES('ds_0.t_user_${0..1}'),TABLE_STRATEGY(TYPE='standard',SHARDING_COLUMN=user_id,SHARDING_ALGORITHM(TYPE(NAME='inline',PROPERTIES('algorithm-expression'='t_user_${user_id % 2}')))))" />
+            <assertion-sql sql="SHOW TABLES;" />
+        </assertion>
     </test-case>
     <test-case sql="CREATE READWRITE_SPLITTING RULE readwrite_ds (WRITE_RESOURCE=ds_0,READ_RESOURCES(ds_1),TYPE(NAME='RANDOM'));" db-types="MySQL, PostgreSQL">
         <assertion expected-data-file="create_readwrite_splitting_rules.xml">
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/scenario/rdl_empty_rules/data/actual/init-sql/mysql/01-actual-init.sql b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/scenario/rdl_empty_rules/data/actual/init-sql/mysql/01-actual-init.sql
index ad0e63f2532..1f8522d7006 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/scenario/rdl_empty_rules/data/actual/init-sql/mysql/01-actual-init.sql
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/env/scenario/rdl_empty_rules/data/actual/init-sql/mysql/01-actual-init.sql
@@ -27,7 +27,13 @@ CREATE DATABASE rdl_ds_1;
 CREATE DATABASE rdl_ds_2;
 
 DROP TABLE IF EXISTS rdl_ds_0.t_user_0;
-DROP TABLE IF EXISTS rdl_ds_1.t_user_1;
+DROP TABLE IF EXISTS rdl_ds_0.t_user_1;
+DROP TABLE IF EXISTS rdl_ds_0.t_user_2;
+DROP TABLE IF EXISTS rdl_ds_0.t_user_3;
+DROP TABLE IF EXISTS rdl_ds_0.t_user_4;
 
-CREATE TABLE rdl_ds_0.t_user_0 (user_id INT NOT NULL, username(20) VARCHAR NOT NULL, phone VARCHAR(20) NULL, PRIMARY KEY (user_id));
-CREATE TABLE rdl_ds_0.t_user_1 (user_id INT NOT NULL, username(20) VARCHAR NOT NULL, phone VARCHAR(20) NULL, PRIMARY KEY (user_id));
\ No newline at end of file
+CREATE TABLE rdl_ds_0.t_user_0 (user_id INT NOT NULL, username VARCHAR(20) NOT NULL, phone VARCHAR(20) NULL, PRIMARY KEY (user_id));
+CREATE TABLE rdl_ds_0.t_user_1 (user_id INT NOT NULL, username VARCHAR(20) NOT NULL, phone VARCHAR(20) NULL, PRIMARY KEY (user_id));
+CREATE TABLE rdl_ds_0.t_user_2 (user_id INT NOT NULL, username VARCHAR(20) NOT NULL, phone VARCHAR(20) NULL, PRIMARY KEY (user_id));
+CREATE TABLE rdl_ds_0.t_user_3 (user_id INT NOT NULL, username VARCHAR(20) NOT NULL, phone VARCHAR(20) NULL, PRIMARY KEY (user_id));
+CREATE TABLE rdl_ds_0.t_user_4 (user_id INT NOT NULL, username VARCHAR(20) NOT NULL, phone VARCHAR(20) NULL, PRIMARY KEY (user_id));