This is an automated email from the ASF dual-hosted git repository.
zhonghongsheng 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 d0f6bcf30dc Scaling IT minor optimization (#17995)
d0f6bcf30dc is described below
commit d0f6bcf30dc27c144defb1d570037bec9eb6b264
Author: azexcy <[email protected]>
AuthorDate: Fri May 27 18:17:47 2022 +0800
Scaling IT minor optimization (#17995)
---
.../data/pipeline/cases/base/BaseExtraSQLITCase.java | 8 ++++----
.../integration/data/pipeline/cases/base/BaseITCase.java | 10 +++++++---
.../data/pipeline/cases/general/MySQLGeneralScalingIT.java | 2 +-
.../pipeline/cases/general/PostgreSQLGeneralScalingIT.java | 2 +-
.../data/pipeline/framework/helper/ScalingCaseHelper.java | 5 -----
5 files changed, 13 insertions(+), 14 deletions(-)
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseExtraSQLITCase.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseExtraSQLITCase.java
index 8ea64397799..30c084bf533 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseExtraSQLITCase.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseExtraSQLITCase.java
@@ -34,15 +34,15 @@ public abstract class BaseExtraSQLITCase extends BaseITCase
{
}
protected void createNoUseTable() {
- getJdbcTemplate().execute("CREATE SHARDING TABLE RULE no_use
(RESOURCES(ds_0, ds_1), SHARDING_COLUMN=sharding_id,
TYPE(NAME=MOD,PROPERTIES('sharding-count'=4)))");
- getJdbcTemplate().execute("CREATE TABLE no_use(id int(11) NOT
NULL,sharding_id int(11) NOT NULL, PRIMARY KEY (id))");
+ executeWithLog("CREATE SHARDING TABLE RULE no_use (RESOURCES(ds_0,
ds_1), SHARDING_COLUMN=sharding_id,
TYPE(NAME=MOD,PROPERTIES('sharding-count'=4)))");
+ executeWithLog("CREATE TABLE no_use(id int(11) NOT NULL,sharding_id
int(11) NOT NULL, PRIMARY KEY (id))");
}
protected void createOrderTable() {
- getJdbcTemplate().execute(extraSQLCommand.getCreateTableOrder());
+ executeWithLog(extraSQLCommand.getCreateTableOrder());
}
protected void createOrderItemTable() {
- getJdbcTemplate().execute(extraSQLCommand.getCreateTableOrderItem());
+ executeWithLog(extraSQLCommand.getCreateTableOrderItem());
}
}
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java
index 6eb31d0a6bb..8f7b26a6150 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/base/BaseITCase.java
@@ -176,6 +176,7 @@ public abstract class BaseITCase {
executeWithLog(addTargetResource);
List<Map<String, Object>> resources = queryForListWithLog("SHOW SCHEMA
RESOURCES from sharding_db");
assertThat(resources.size(), is(5));
+ assertBeforeApplyScalingMetadataCorrectly();
}
private String getActualJdbcUrlTemplate(final String databaseName) {
@@ -195,8 +196,9 @@ public abstract class BaseITCase {
executeWithLog(getCommonSQLCommand().getCreateOrderItemShardingAlgorithm());
}
- protected void createAllSharingTableRule() {
+ protected void getCreateOrderWithItemSharingTableRule() {
executeWithLog(commonSQLCommand.getCreateOrderWithItemSharingTableRule());
+ assertBeforeApplyScalingMetadataCorrectly();
}
protected void createOrderSharingTableRule() {
@@ -233,8 +235,10 @@ public abstract class BaseITCase {
protected void assertBeforeApplyScalingMetadataCorrectly() {
List<Map<String, Object>> previewResults =
queryForListWithLog("PREVIEW SELECT COUNT(1) FROM t_order");
Set<Object> actualSources = previewResults.stream().map(each ->
each.get("actual_sql")).collect(Collectors.toSet());
- assertThat(previewResults.stream().map(each ->
each.get("data_source_name")).collect(Collectors.toSet()), is(new
HashSet<>(Arrays.asList("ds_0", "ds_1"))));
- assertThat(actualSources, is(new
HashSet<>(Collections.singletonList("SELECT COUNT(1) FROM t_order_0 UNION ALL
SELECT COUNT(1) FROM t_order_1"))));
+ assertThat("data_source_name name not correct, it's effective early,
search watcher failed get more info",
+ previewResults.stream().map(each ->
each.get("data_source_name")).collect(Collectors.toSet()), is(new
HashSet<>(Arrays.asList("ds_0", "ds_1"))));
+ assertThat("actual_sql not correct, it's effective early, search
watcher failed get more info", actualSources,
+ is(new HashSet<>(Collections.singletonList("SELECT COUNT(1)
FROM t_order_0 UNION ALL SELECT COUNT(1) FROM t_order_1"))));
}
/**
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/MySQLGeneralScalingIT.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/MySQLGeneralScalingIT.java
index 1bc0cbae853..6979bd83280 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/MySQLGeneralScalingIT.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/MySQLGeneralScalingIT.java
@@ -69,7 +69,7 @@ public final class MySQLGeneralScalingIT extends
BaseExtraSQLITCase {
initShardingAlgorithm();
assertTrue(waitShardingAlgorithmEffect(15));
createScalingRule();
- createAllSharingTableRule();
+ getCreateOrderWithItemSharingTableRule();
createNoUseTable();
createOrderTable();
createOrderItemTable();
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/PostgreSQLGeneralScalingIT.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/PostgreSQLGeneralScalingIT.java
index cba6dc767df..3c96896d05a 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/PostgreSQLGeneralScalingIT.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/cases/general/PostgreSQLGeneralScalingIT.java
@@ -74,7 +74,7 @@ public final class PostgreSQLGeneralScalingIT extends
BaseExtraSQLITCase {
assertTrue(waitShardingAlgorithmEffect(15));
createScalingRule();
createSchema("test");
- createAllSharingTableRule();
+ getCreateOrderWithItemSharingTableRule();
createOrderTable();
createOrderItemTable();
SnowflakeKeyGenerateAlgorithm keyGenerateAlgorithm = new
SnowflakeKeyGenerateAlgorithm();
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/helper/ScalingCaseHelper.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/helper/ScalingCaseHelper.java
index 532ca623a4a..60d18be056f 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/helper/ScalingCaseHelper.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/helper/ScalingCaseHelper.java
@@ -18,7 +18,6 @@
package org.apache.shardingsphere.integration.data.pipeline.framework.helper;
import org.apache.commons.lang3.tuple.Pair;
-import org.apache.shardingsphere.infra.database.metadata.url.JdbcUrlAppender;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
import
org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
@@ -38,10 +37,6 @@ import java.util.concurrent.ThreadLocalRandom;
*/
public final class ScalingCaseHelper {
- private static final JdbcUrlAppender JDBC_URL_APPENDER = new
JdbcUrlAppender();
-
- private static final String CUSTOM_SCHEMA = "test";
-
/**
* Get query properties by database type.
*