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 10179b4 Add test cases for DDL of governance module (#11226)
10179b4 is described below
commit 10179b42c2f7165cc1090e9c679b1c9af7df1b04
Author: Jieker <[email protected]>
AuthorDate: Fri Jul 9 07:23:53 2021 +0800
Add test cases for DDL of governance module (#11226)
* add ddl cases of governance
* fix it tests
---
.../test/integration/engine/it/BaseITCase.java | 3 +++
.../ddl/dataset/sharding_governance/alter_add.xml | 24 +++++++++++++++++
.../dataset/sharding_governance/alter_change.xml | 23 +++++++++++++++++
.../ddl/dataset/sharding_governance/alter_drop.xml | 22 ++++++++++++++++
.../dataset/sharding_governance/create_index.xml | 24 +++++++++++++++++
.../dataset/sharding_governance/create_table.xml | 23 +++++++++++++++++
.../sharding_governance/create_unique_index.xml | 24 +++++++++++++++++
.../ddl/dataset/sharding_governance/drop_table.xml | 20 +++++++++++++++
.../cases/ddl/ddl-integration-test-cases.xml | 30 +++++++++++-----------
9 files changed, 178 insertions(+), 15 deletions(-)
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseITCase.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseITCase.java
index bd00ca8..81ef09d 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseITCase.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseITCase.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.test.integration.engine.it;
import lombok.AccessLevel;
import lombok.Getter;
+import
org.apache.shardingsphere.driver.governance.internal.datasource.GovernanceShardingSphereDataSource;
import
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.test.integration.cases.SQLCommandType;
@@ -86,6 +87,8 @@ public abstract class BaseITCase {
public final void tearDown() {
if (targetDataSource instanceof ShardingSphereDataSource) {
((ShardingSphereDataSource)
targetDataSource).getMetaDataContexts().getExecutorEngine().close();
+ } else if (targetDataSource instanceof
GovernanceShardingSphereDataSource) {
+ ((GovernanceShardingSphereDataSource)
targetDataSource).getMetaDataContexts().getExecutorEngine().close();
}
}
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/alter_add.xml
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/alter_add.xml
new file mode 100644
index 0000000..ff16b8b
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/alter_add.xml
@@ -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.
+ -->
+
+<dataset>
+ <metadata table-name="t_order_details"
data-nodes="governance_db.t_order_details">
+ <column name="id" type="integer" />
+ <column name="description" type="varchar" />
+ <column name="name" type="varchar" />
+ </metadata>
+</dataset>
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/alter_change.xml
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/alter_change.xml
new file mode 100644
index 0000000..25e426b
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/alter_change.xml
@@ -0,0 +1,23 @@
+<!--
+ ~ 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 table-name="t_order_details"
data-nodes="governance_db.t_order_details">
+ <column name="id" type="integer" />
+ <column name="description_new" type="varchar" />
+ </metadata>
+</dataset>
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/alter_drop.xml
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/alter_drop.xml
new file mode 100644
index 0000000..976331f
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/alter_drop.xml
@@ -0,0 +1,22 @@
+<!--
+ ~ 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 table-name="t_order_details"
data-nodes="governance_db.t_order_details">
+ <column name="id" type="integer" />
+ </metadata>
+</dataset>
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/create_index.xml
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/create_index.xml
new file mode 100644
index 0000000..13ec027
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/create_index.xml
@@ -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.
+ -->
+
+<dataset>
+ <metadata table-name="t_order_details"
data-nodes="governance_db.t_order_details">
+ <column name="id" type="integer" />
+ <column name="description" type="varchar" />
+ <index name="t_order_details_index_t_order_details" column="id"
unique="false" />
+ </metadata>
+</dataset>
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/create_table.xml
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/create_table.xml
new file mode 100644
index 0000000..802a415
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/create_table.xml
@@ -0,0 +1,23 @@
+<!--
+ ~ 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 table-name="t_order_details"
data-nodes="governance_db.t_order_details">
+ <column name="id" type="integer" />
+ <column name="description" type="varchar" />
+ </metadata>
+</dataset>
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/create_unique_index.xml
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/create_unique_index.xml
new file mode 100644
index 0000000..52c6691
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/create_unique_index.xml
@@ -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.
+ -->
+
+<dataset>
+ <metadata table-name="t_order_details"
data-nodes="governance_db.t_order_details">
+ <column name="id" type="integer" />
+ <column name="description" type="varchar" />
+ <index name="t_order_details_index_t_order_details" column="id"
unique="true" />
+ </metadata>
+</dataset>
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/drop_table.xml
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/drop_table.xml
new file mode 100644
index 0000000..19a0353
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/dataset/sharding_governance/drop_table.xml
@@ -0,0 +1,20 @@
+<!--
+ ~ 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 table-name="t_order_details"
data-nodes="governance_db.t_order_details" />
+</dataset>
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/ddl-integration-test-cases.xml
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/ddl-integration-test-cases.xml
index 616859c..a3335cd 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/ddl-integration-test-cases.xml
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/resources/cases/ddl/ddl-integration-test-cases.xml
@@ -16,55 +16,55 @@
-->
<integration-test-cases>
- <test-case sql="CREATE TABLE t_order_details(id int, description
varchar(10))"
scenario-types="db,tbl,dbtbl_with_readwrite_splitting,readwrite_splitting">
+ <test-case sql="CREATE TABLE t_order_details(id int, description
varchar(10))"
scenario-types="db,tbl,dbtbl_with_readwrite_splitting,readwrite_splitting,sharding_governance">
<assertion expected-data-file="create_table.xml">
<initial-sql affected-table="t_order_details" />
</assertion>
</test-case>
- <test-case sql="CREATE INDEX t_order_details_index ON t_order_details
(id)"
scenario-types="db,tbl,dbtbl_with_readwrite_splitting,readwrite_splitting">
+ <test-case sql="CREATE INDEX t_order_details_index ON t_order_details
(id)"
scenario-types="db,tbl,dbtbl_with_readwrite_splitting,readwrite_splitting,sharding_governance">
<assertion expected-data-file="create_index.xml">
<initial-sql sql="CREATE TABLE t_order_details(id int, description
varchar(10))" affected-table="t_order_details" />
</assertion>
</test-case>
- <test-case sql="CREATE UNIQUE INDEX t_order_details_index ON
t_order_details (id)"
scenario-types="db,tbl,dbtbl_with_readwrite_splitting,readwrite_splitting">
+ <test-case sql="CREATE UNIQUE INDEX t_order_details_index ON
t_order_details (id)"
scenario-types="db,tbl,dbtbl_with_readwrite_splitting,readwrite_splitting,sharding_governance">
<assertion expected-data-file="create_unique_index.xml">
<initial-sql sql="CREATE TABLE t_order_details(id int, description
varchar(10))" affected-table="t_order_details" />
</assertion>
</test-case>
- <test-case sql="ALTER TABLE t_order_details ADD name varchar(10)"
scenario-types="db,tbl,dbtbl_with_readwrite_splitting,readwrite_splitting">
+ <test-case sql="ALTER TABLE t_order_details ADD name varchar(10)"
scenario-types="db,tbl,dbtbl_with_readwrite_splitting,readwrite_splitting,sharding_governance">
<assertion expected-data-file="alter_add.xml">
<initial-sql sql="CREATE TABLE t_order_details(id int, description
varchar(10))" affected-table="t_order_details" />
</assertion>
</test-case>
- <test-case sql="ALTER TABLE t_order_details DROP COLUMN description"
scenario-types="db,tbl,dbtbl_with_readwrite_splitting,readwrite_splitting">
+ <test-case sql="ALTER TABLE t_order_details DROP COLUMN description"
scenario-types="db,tbl,dbtbl_with_readwrite_splitting,readwrite_splitting,sharding_governance">
<assertion expected-data-file="alter_drop.xml">
<initial-sql sql="CREATE TABLE t_order_details(id int, description
varchar(10))" affected-table="t_order_details" />
</assertion>
</test-case>
- <test-case sql="ALTER TABLE t_order_details CHANGE description
description_new varchar(10)"
scenario-types="db,tbl,dbtbl_with_readwrite_splitting,readwrite_splitting">
+ <test-case sql="ALTER TABLE t_order_details CHANGE description
description_new varchar(10)"
scenario-types="db,tbl,dbtbl_with_readwrite_splitting,readwrite_splitting,sharding_governance">
<assertion expected-data-file="alter_change.xml">
<initial-sql sql="CREATE TABLE t_order_details(id int, description
varchar(10))" affected-table="t_order_details" />
</assertion>
</test-case>
- <test-case sql="DROP TABLE t_order_details"
scenario-types="db,tbl,dbtbl_with_readwrite_splitting,readwrite_splitting">
+ <test-case sql="DROP TABLE t_order_details"
scenario-types="db,tbl,dbtbl_with_readwrite_splitting,readwrite_splitting,sharding_governance">
<assertion expected-data-file="drop_table.xml">
<initial-sql sql="CREATE TABLE t_order_details(id int, description
varchar(10))" affected-table="t_order_details" />
</assertion>
</test-case>
- <test-case sql="DROP INDEX t_order_details_index ON t_order_details"
db-types="MySQL,SQLServer,PostgreSQL,Oracle"
scenario-types="db,tbl,dbtbl_with_readwrite_splitting,readwrite_splitting">
+ <test-case sql="DROP INDEX t_order_details_index ON t_order_details"
db-types="MySQL,SQLServer,PostgreSQL,Oracle"
scenario-types="db,tbl,dbtbl_with_readwrite_splitting,readwrite_splitting,sharding_governance">
<assertion expected-data-file="unchanged_table.xml">
<initial-sql sql="CREATE TABLE t_order_details(id int, description
varchar(10));CREATE INDEX t_order_details_index ON
t_order_details(description)" affected-table="t_order_details" />
</assertion>
</test-case>
- <test-case sql="TRUNCATE TABLE t_order_details"
scenario-types="db,tbl,dbtbl_with_readwrite_splitting,readwrite_splitting">
+ <test-case sql="TRUNCATE TABLE t_order_details"
scenario-types="db,tbl,dbtbl_with_readwrite_splitting,readwrite_splitting,sharding_governance">
<assertion expected-data-file="unchanged_table.xml">
<initial-sql sql="CREATE TABLE t_order_details(id int, description
varchar(10))" affected-table="t_order_details" />
</assertion>
@@ -149,18 +149,18 @@
</test-case>
<!--FIXME #11103-->
-<!-- <test-case sql="ALTER TABLE t_user_details CHANGE number number_new
VARCHAR(50)"
scenario-types="encrypt,dbtbl_with_readwrite_splitting_and_encrypt">-->
+<!-- <test-case sql="ALTER TABLE t_user_details CHANGE number number_new
VARCHAR(50)" db-types="MySQL,SQLServer,PostgreSQL,Oracle"
scenario-types="encrypt,dbtbl_with_readwrite_splitting_and_encrypt">-->
<!-- <assertion expected-data-file="alter_change.xml">-->
<!-- <initial-sql sql="CREATE TABLE t_user_details (user_id INT NOT
NULL, address_id INT NOT NULL, number_plain VARCHAR(45) NULL, number_cipher
VARCHAR(45) NULL, description varchar(10))" affected-table="t_user_details"
/>-->
<!-- </assertion>-->
<!-- </test-case>-->
<!--FIXME #11105-->
-<!-- <test-case sql="ALTER TABLE t_user_details DROP COLUMN number"
scenario-types="encrypt,dbtbl_with_readwrite_splitting_and_encrypt">-->
-<!-- <assertion expected-data-file="alter_drop.xml">-->
-<!-- <initial-sql sql="CREATE TABLE t_user_details (user_id INT NOT
NULL, address_id INT NOT NULL, number_plain VARCHAR(45) NULL, number_cipher
VARCHAR(45) NULL, description varchar(10))" affected-table="t_user_details"/>-->
-<!-- </assertion>-->
-<!-- </test-case>-->
+ <test-case sql="ALTER TABLE t_user_details DROP COLUMN number"
db-types="MySQL,SQLServer,PostgreSQL,Oracle"
scenario-types="encrypt,dbtbl_with_readwrite_splitting_and_encrypt">
+ <assertion expected-data-file="alter_drop.xml">
+ <initial-sql sql="CREATE TABLE t_user_details (user_id INT NOT
NULL, address_id INT NOT NULL, number_plain VARCHAR(45) NULL, number_cipher
VARCHAR(45) NULL, description varchar(10))" affected-table="t_user_details"/>
+ </assertion>
+ </test-case>
<test-case sql="DROP TABLE t_user_details"
scenario-types="encrypt,dbtbl_with_readwrite_splitting_and_encrypt">
<assertion expected-data-file="drop_table.xml">