You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/07/29 02:43:04 UTC
[shardingsphere] branch master updated: Scaling IT adapt mysql 5 and 8 (#19661)
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 20989acaa28 Scaling IT adapt mysql 5 and 8 (#19661)
20989acaa28 is described below
commit 20989acaa28fde06fbbb2a318acea11460d0aa08
Author: Xinze Guo <10...@users.noreply.github.com>
AuthorDate: Fri Jul 29 10:42:58 2022 +0800
Scaling IT adapt mysql 5 and 8 (#19661)
* Scaling IT adapt mysql 5 and 8
* it-transaction.yml exclude scaling
---
.github/workflows/it-transaction.yml | 1 +
.../container/compose/DockerComposedContainer.java | 4 ++--
.../proxy/ShardingSphereProxyDockerContainer.java | 12 ++++++++++--
.../integration/data/pipeline/util/DatabaseTypeUtil.java | 15 +++++++++++++++
.../resources/env/mysql/{server.yaml => server-5.yaml} | 1 +
.../resources/env/mysql/{server.yaml => server-8.yaml} | 1 +
6 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/it-transaction.yml b/.github/workflows/it-transaction.yml
index 27813ba95e2..a8134da2a69 100644
--- a/.github/workflows/it-transaction.yml
+++ b/.github/workflows/it-transaction.yml
@@ -28,6 +28,7 @@ on:
- '!shardingsphere-test/**'
- 'shardingsphere-test/shardingsphere-integration-test/**'
- '!shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/**'
+ - '!shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/**'
- '!*.md'
concurrency:
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/container/compose/DockerComposedContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/container/compose/DockerComposedContainer.java
index 0618151fe0d..4fb2b3e0ec7 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/container/compose/DockerComposedContainer.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/container/compose/DockerComposedContainer.java
@@ -42,9 +42,9 @@ public final class DockerComposedContainer extends BaseComposedContainer {
this.databaseType = databaseType;
GovernanceContainer governanceContainer = getContainers().registerContainer(new ZookeeperContainer());
storageContainer = getContainers().registerContainer((DockerStorageContainer) StorageContainerFactory.newInstance(databaseType, dockerImageName, "", false));
- ShardingSphereProxyDockerContainer proxyContainer = new ShardingSphereProxyDockerContainer(databaseType);
+ ShardingSphereProxyDockerContainer proxyContainer = new ShardingSphereProxyDockerContainer(databaseType, dockerImageName);
proxyContainer.dependsOn(governanceContainer, storageContainer);
- ShardingSphereProxyDockerContainer anotherProxyContainer = new ShardingSphereProxyDockerContainer(databaseType);
+ ShardingSphereProxyDockerContainer anotherProxyContainer = new ShardingSphereProxyDockerContainer(databaseType, dockerImageName);
anotherProxyContainer.dependsOn(governanceContainer, storageContainer);
this.proxyContainer = getContainers().registerContainer(proxyContainer);
getContainers().registerContainer(anotherProxyContainer);
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/container/proxy/ShardingSphereProxyDockerContainer.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/container/proxy/ShardingSphereProxyDockerContainer.java
index 48dd8cf45b8..7f2b2aacf19 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/container/proxy/ShardingSphereProxyDockerContainer.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/container/proxy/ShardingSphereProxyDockerContainer.java
@@ -35,9 +35,12 @@ public final class ShardingSphereProxyDockerContainer extends DockerITContainer
private final DatabaseType databaseType;
- public ShardingSphereProxyDockerContainer(final DatabaseType databaseType) {
+ private final String dockerImageName;
+
+ public ShardingSphereProxyDockerContainer(final DatabaseType databaseType, final String dockerImageName) {
super("Scaling-Proxy", "apache/shardingsphere-proxy-test");
this.databaseType = databaseType;
+ this.dockerImageName = dockerImageName;
}
@Override
@@ -54,7 +57,12 @@ public final class ShardingSphereProxyDockerContainer extends DockerITContainer
}
private void mapConfigurationFiles() {
- withClasspathResourceMapping(String.format("/env/%s/server.yaml", databaseType.getType().toLowerCase()), "/opt/shardingsphere-proxy/conf/server.yaml", BindMode.READ_ONLY);
+ if (DatabaseTypeUtil.isMySQL(databaseType)) {
+ String majorVersion = DatabaseTypeUtil.parseMajorVersion(dockerImageName);
+ withClasspathResourceMapping(String.format("/env/%s/server-%s.yaml", databaseType.getType().toLowerCase(), majorVersion), "/opt/shardingsphere-proxy/conf/server.yaml", BindMode.READ_ONLY);
+ } else {
+ withClasspathResourceMapping(String.format("/env/%s/server.yaml", databaseType.getType().toLowerCase()), "/opt/shardingsphere-proxy/conf/server.yaml", BindMode.READ_ONLY);
+ }
withClasspathResourceMapping("/env/logback.xml", "/opt/shardingsphere-proxy/conf/logback.xml", BindMode.READ_ONLY);
}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/DatabaseTypeUtil.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/DatabaseTypeUtil.java
index be43c4ba9f1..c1b513fb376 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/DatabaseTypeUtil.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/util/DatabaseTypeUtil.java
@@ -21,6 +21,7 @@ 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;
import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
+import org.testcontainers.shaded.org.apache.commons.lang.StringUtils;
public final class DatabaseTypeUtil {
@@ -34,6 +35,20 @@ public final class DatabaseTypeUtil {
return databaseType instanceof MySQLDatabaseType;
}
+ /**
+ * Get docker image major version.
+ *
+ * @param dockerImageName dockerImageName
+ * @return major version
+ */
+ public static String parseMajorVersion(final String dockerImageName) {
+ if (StringUtils.isBlank(dockerImageName)) {
+ return "";
+ }
+ String version = dockerImageName.split(":")[1];
+ return version.split("\\.")[0];
+ }
+
/**
* Check PostgreSQL database type.
*
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/server-5.yaml
similarity index 97%
copy from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/server.yaml
copy to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/server-5.yaml
index 227cf515338..f538cf22287 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/server-5.yaml
@@ -42,3 +42,4 @@ props:
proxy-hint-enabled: true
sql-show: true
sql-federation-enabled: true
+ proxy-mysql-default-version: 5.7.22
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/server.yaml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/server-8.yaml
similarity index 97%
rename from shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/server.yaml
rename to shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/server-8.yaml
index 227cf515338..eb988740263 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/server.yaml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/mysql/server-8.yaml
@@ -42,3 +42,4 @@ props:
proxy-hint-enabled: true
sql-show: true
sql-federation-enabled: true
+ proxy-mysql-default-version: 8.0.11