This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 235c3fb7cfb Avoid using hardcoded ports in nativeTest (#30003)
235c3fb7cfb is described below
commit 235c3fb7cfba115ba2b34c7d7149088c5a392601
Author: Ling Hengqian <[email protected]>
AuthorDate: Mon Feb 5 16:27:16 2024 +0800
Avoid using hardcoded ports in nativeTest (#30003)
---
distribution/proxy-native/pom.xml | 4 -
distribution/proxy/src/main/release-docs/LICENSE | 36 +++----
.../graalvm-native-image/_index.cn.md | 14 +--
.../graalvm-native-image/_index.en.md | 14 +--
.../shardingsphere-proxy/startup/bin.cn.md | 2 +-
.../shardingsphere-proxy/startup/bin.en.md | 2 +-
pom.xml | 12 +--
test/native/pom.xml | 11 ++
.../test/natived/jdbc/commons/FileTestUtils.java | 65 -----------
.../natived/jdbc/databases/MSSQLServerTest.java | 14 +--
.../test/natived/jdbc/databases/PostgresTest.java | 14 +--
.../test/natived/jdbc/features/EncryptTest.java | 12 ++-
.../test/natived/jdbc/features/MaskTest.java | 12 ++-
.../jdbc/features/ReadWriteSplittingTest.java | 20 ++--
.../test/natived/jdbc/features/ShadowTest.java | 12 ++-
.../test/natived/jdbc/features/ShardingTest.java | 12 ++-
.../test/natived/jdbc/mode/cluster/EtcdTest.java | 119 +++++++--------------
.../natived/jdbc/mode/cluster/ZookeeperTest.java | 46 ++++----
.../test-native/yaml/mode/cluster/etcd.yaml | 2 +-
.../test-native/yaml/mode/cluster/zookeeper.yaml | 2 +-
20 files changed, 165 insertions(+), 260 deletions(-)
diff --git a/distribution/proxy-native/pom.xml
b/distribution/proxy-native/pom.xml
index 941021baf08..08e8f051325 100644
--- a/distribution/proxy-native/pom.xml
+++ b/distribution/proxy-native/pom.xml
@@ -88,10 +88,6 @@
<arg>-J-Xmx7g</arg>
<arg>-H:+AddAllCharsets</arg>
</buildArgs>
- <metadataRepository>
- <enabled>true</enabled>
- <version>0.3.5</version>
- </metadataRepository>
</configuration>
<executions>
<execution>
diff --git a/distribution/proxy/src/main/release-docs/LICENSE
b/distribution/proxy/src/main/release-docs/LICENSE
index 43e9a15b987..d5956209fad 100644
--- a/distribution/proxy/src/main/release-docs/LICENSE
+++ b/distribution/proxy/src/main/release-docs/LICENSE
@@ -265,29 +265,29 @@ The text of each license is the standard Apache 2.0
license.
jackson-datatype-jdk8 2.16.0:
http://github.com/FasterXML/jackson-modules-java8, Apache 2.0
jackson-datatype-jsr310 2.16.0: http://github.com/FasterXML/jackson,
Apache 2.0
jcl-over-slf4j 1.7.36: https://github.com/qos-ch/slf4j, Apache 2.0
- jetcd-api 0.7.6: https://github.com/etcd-io/jetcd, Apache 2.0
- jetcd-common 0.7.6: https://github.com/etcd-io/jetcd, Apache 2.0
- jetcd-core 0.7.6: https://github.com/etcd-io/jetcd, Apache 2.0
- jetcd-grpc 0.7.6: https://github.com/etcd-io/jetcd, Apache 2.0
+ jetcd-api 0.7.7: https://github.com/etcd-io/jetcd, Apache 2.0
+ jetcd-common 0.7.7: https://github.com/etcd-io/jetcd, Apache 2.0
+ jetcd-core 0.7.7: https://github.com/etcd-io/jetcd, Apache 2.0
+ jetcd-grpc 0.7.7: https://github.com/etcd-io/jetcd, Apache 2.0
json-path 2.9.0: https://github.com/jayway/JsonPath, Apache 2.0
json-smart 2.4.10: https://www.minidev.net/, Apache 2.0
json-simple 1.1.1: https://code.google.com/archive/p/json-simple/, Apache
2.0
jsr305 3.0.2: http://findbugs.sourceforge.net/, Apache 2.0
memory 0.9.0, Apache 2.0
- netty-buffer 4.1.99.Final: https://github.com/netty, Apache 2.0
- netty-codec 4.1.99.Final: https://github.com/netty, Apache 2.0
- netty-codec-http 4.1.99.Final: https://github.com/netty, Apache 2.0
- netty-codec-http2 4.1.99.Final: https://github.com/netty, Apache 2.0
- netty-codec-socks 4.1.99.Final: https://github.com/netty, Apache 2.0
- netty-common 4.1.99.Final: https://github.com/netty, Apache 2.0
- netty-handler 4.1.99.Final: https://github.com/netty, Apache 2.0
- netty-handler-proxy 4.1.99.Final: https://github.com/netty, Apache 2.0
- netty-resolver 4.1.99.Final: https://github.com/netty, Apache 2.0
- netty-transport 4.1.99.Final: https://github.com/netty, Apache 2.0
- netty-transport-classes-epoll 4.1.99.Final: https://github.com/netty,
Apache 2.0
- netty-transport-native-epoll 4.1.99.Final-linux-aarch_64:
https://github.com/netty, Apache 2.0
- netty-transport-native-epoll 4.1.99.Final-linux-x86_64:
https://github.com/netty, Apache 2.0
- netty-transport-native-unix-common 4.1.99.Final: https://github.com/netty,
Apache 2.0
+ netty-buffer 4.1.106.Final: https://github.com/netty, Apache 2.0
+ netty-codec 4.1.106.Final: https://github.com/netty, Apache 2.0
+ netty-codec-http 4.1.106.Final: https://github.com/netty, Apache 2.0
+ netty-codec-http2 4.1.106.Final: https://github.com/netty, Apache 2.0
+ netty-codec-socks 4.1.106.Final: https://github.com/netty, Apache 2.0
+ netty-common 4.1.106.Final: https://github.com/netty, Apache 2.0
+ netty-handler 4.1.106.Final: https://github.com/netty, Apache 2.0
+ netty-handler-proxy 4.1.106.Final: https://github.com/netty, Apache 2.0
+ netty-resolver 4.1.106.Final: https://github.com/netty, Apache 2.0
+ netty-transport 4.1.106.Final: https://github.com/netty, Apache 2.0
+ netty-transport-classes-epoll 4.1.106.Final: https://github.com/netty,
Apache 2.0
+ netty-transport-native-epoll 4.1.106.Final-linux-aarch_64:
https://github.com/netty, Apache 2.0
+ netty-transport-native-epoll 4.1.106.Final-linux-x86_64:
https://github.com/netty, Apache 2.0
+ netty-transport-native-unix-common 4.1.106.Final:
https://github.com/netty, Apache 2.0
netty-tcnative-boringssl-static 2.0.59.Final:
https://github.com/netty/netty-tcnative, Apache 2.0
netty-tcnative-boringssl-static 2.0.59.Final-linux-aarch_64:
https://github.com/netty/netty-tcnative, Apache 2.0
netty-tcnative-boringssl-static 2.0.59.Final-linux-x86_64:
https://github.com/netty/netty-tcnative, Apache 2.0
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.cn.md
index 997ec74af48..f70c8a456f5 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.cn.md
@@ -37,15 +37,12 @@ ShardingSphere JDBC 要求在如下或更高版本的 `GraalVM CE` 完成构建
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
- <version>0.9.28</version>
+ <version>0.10.0</version>
<extensions>true</extensions>
<configuration>
<buildArgs>
<buildArg>-H:+AddAllCharsets</buildArg>
</buildArgs>
- <metadataRepository>
- <enabled>true</enabled>
- </metadataRepository>
</configuration>
<executions>
<execution>
@@ -76,7 +73,7 @@ ShardingSphere JDBC 要求在如下或更高版本的 `GraalVM CE` 完成构建
```groovy
plugins {
- id 'org.graalvm.buildtools.native' version '0.9.28'
+ id 'org.graalvm.buildtools.native' version '0.10.0'
}
dependencies {
@@ -92,9 +89,6 @@ graalvmNative {
buildArgs.add('-H:+AddAllCharsets')
}
}
- metadataRepository {
- enabled = true
- }
}
```
@@ -240,8 +234,8 @@ ShardingSphere 定义了 `nativeTestInShardingSphere` 的 Maven
Profile 用于
sudo apt install unzip zip curl sed -y
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
-sdk install java 21.0.1-graalce
-sdk use java 21.0.1-graalce
+sdk install java 21.0.2-graalce
+sdk use java 21.0.2-graalce
sudo apt-get install build-essential libz-dev zlib1g-dev -y
git clone [email protected]:apache/shardingsphere.git
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.en.md
index 7e797961d8b..57d083e7667 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.en.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.en.md
@@ -39,15 +39,12 @@ and the documentation of GraalVM Native Build Tools shall
prevail.
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
- <version>0.9.28</version>
+ <version>0.10.0</version>
<extensions>true</extensions>
<configuration>
<buildArgs>
<buildArg>-H:+AddAllCharsets</buildArg>
</buildArgs>
- <metadataRepository>
- <enabled>true</enabled>
- </metadataRepository>
</configuration>
<executions>
<execution>
@@ -79,7 +76,7 @@ and the documentation of GraalVM Native Build Tools shall
prevail.
```groovy
plugins {
- id 'org.graalvm.buildtools.native' version '0.9.28'
+ id 'org.graalvm.buildtools.native' version '0.10.0'
}
dependencies {
@@ -95,9 +92,6 @@ graalvmNative {
buildArgs.add('-H:+AddAllCharsets')
}
}
- metadataRepository {
- enabled = true
- }
}
```
@@ -250,8 +244,8 @@ You must install Docker Engine to execute
`testcontainers-java` related unit tes
sudo apt install unzip zip curl sed -y
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
-sdk install java 21.0.1-graalce
-sdk use java 21.0.1-graalce
+sdk install java 21.0.2-graalce
+sdk use java 21.0.2-graalce
sudo apt-get install build-essential libz-dev zlib1g-dev -y
git clone [email protected]:apache/shardingsphere.git
diff --git
a/docs/document/content/user-manual/shardingsphere-proxy/startup/bin.cn.md
b/docs/document/content/user-manual/shardingsphere-proxy/startup/bin.cn.md
index 702e1b6329a..4ec820253fc 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/startup/bin.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/startup/bin.cn.md
@@ -40,7 +40,7 @@ ShardingSphere-Proxy 支持配置多个逻辑数据源,每个以 `config-` 前
ShardingSphere-Proxy 默认集成 ZooKeeper Curator 客户端,集群模式使用 ZooKeeper 无须引入其他依赖。
-如果集群模式使用 Etcd,需要将 Etcd 依赖的 [vertx-grpc
4.4.4](https://repo1.maven.org/maven2/io/vertx/vertx-grpc/4.4.4/vertx-grpc-4.4.4.jar)
和 [vertx-core
4.4.4](https://repo1.maven.org/maven2/io/vertx/vertx-core/4.4.4/vertx-core-4.4.4.jar)
复制至目录 `ext-lib`。
+如果集群模式使用 Etcd,需要将 Etcd 依赖的 [vertx-grpc
4.5.1](https://repo1.maven.org/maven2/io/vertx/vertx-grpc/4.5.1/vertx-grpc-4.5.1.jar)
和 [vertx-core
4.5.1](https://repo1.maven.org/maven2/io/vertx/vertx-core/4.5.1/vertx-core-4.5.1.jar)
复制至目录 `ext-lib`。
6. (可选)引入分布式事务所需依赖
diff --git
a/docs/document/content/user-manual/shardingsphere-proxy/startup/bin.en.md
b/docs/document/content/user-manual/shardingsphere-proxy/startup/bin.en.md
index 970f4833083..3a2f8b38f91 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/startup/bin.en.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/startup/bin.en.md
@@ -41,7 +41,7 @@ If the backend is connected to a MySQL database, please
download [mysql-connecto
ShardingSphere-Proxy integrates the ZooKeeper Curator client by default.
ZooKeeper is used in cluster mode without introducing other dependencies.
-If the cluster mode uses Etcd, please copy [vertx-grpc
4.4.4](https://repo1.maven.org/maven2/io/vertx/vertx-grpc/4.4.4/vertx-grpc-4.4.4.jar)
and [vertx-core
4.4.4](https://repo1.maven.org/maven2/io/vertx/vertx-core/4.4.4/vertx-core-4.4.4.jar)
that Etcd depends on into the `ext-lib` directory.
+If the cluster mode uses Etcd, please copy [vertx-grpc
4.5.1](https://repo1.maven.org/maven2/io/vertx/vertx-grpc/4.5.1/vertx-grpc-4.5.1.jar)
and [vertx-core
4.5.1](https://repo1.maven.org/maven2/io/vertx/vertx-core/4.5.1/vertx-core-4.5.1.jar)
that Etcd depends on into the `ext-lib` directory.
6. Introduce dependencies required by distributed transactions (Optional)
diff --git a/pom.xml b/pom.xml
index d791f4b2264..14523adb04a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -99,14 +99,14 @@
<jboss-logging.version>3.2.1.Final</jboss-logging.version>
<seata.version>1.6.1</seata.version>
- <netty.version>4.1.99.Final</netty.version>
+ <netty.version>4.1.106.Final</netty.version>
<bouncycastle.version>1.70</bouncycastle.version>
<curator.version>5.6.0</curator.version>
<zookeeper.version>3.9.1</zookeeper.version>
<audience-annotations.version>0.12.0</audience-annotations.version>
- <jetcd.version>0.7.6</jetcd.version>
- <vertx.version>4.4.4</vertx.version>
+ <jetcd.version>0.7.7</jetcd.version>
+ <vertx.version>4.5.1</vertx.version>
<consul.api.version>1.4.5</consul.api.version>
<grpc.version>1.58.0</grpc.version>
@@ -153,7 +153,7 @@
<dockerfile-maven.version>1.4.13</dockerfile-maven.version>
<docker-compose-maven-plugin.version>4.0.0</docker-compose-maven-plugin.version>
<os-maven-plugin.version>1.6.2</os-maven-plugin.version>
- <native-maven-plugin.version>0.9.28</native-maven-plugin.version>
+ <native-maven-plugin.version>0.10.0</native-maven-plugin.version>
<!-- Compile plugin versions -->
<templating-maven-plugin.version>1.0.0</templating-maven-plugin.version>
@@ -1067,10 +1067,6 @@
<buildArg>-H:+AddAllCharsets</buildArg>
</buildArgs>
<quickBuild>true</quickBuild>
- <metadataRepository>
- <enabled>true</enabled>
- <version>0.3.5</version>
- </metadataRepository>
</configuration>
<executions>
<execution>
diff --git a/test/native/pom.xml b/test/native/pom.xml
index 12184e976ea..1ef2d6ee809 100644
--- a/test/native/pom.xml
+++ b/test/native/pom.xml
@@ -93,6 +93,17 @@
<artifactId>mssqlserver</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.etcd</groupId>
+ <artifactId>jetcd-test</artifactId>
+ <version>${jetcd.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/FileTestUtils.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/FileTestUtils.java
deleted file mode 100644
index 5c95c1fc7bb..00000000000
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/commons/FileTestUtils.java
+++ /dev/null
@@ -1,65 +0,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.
- */
-
-package org.apache.shardingsphere.test.natived.jdbc.commons;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * The background for this class comes from <a
href="https://github.com/oracle/graal/issues/7682">oracle/graal#7682</a>
- * and <a
href="https://github.com/oracle/graal/blob/vm-ce-23.1.2/docs/reference-manual/native-image/Resources.md">Accessing
Resources in Native Image</a>.
- * GraalVM Native Image has special features in its handling of file systems.
- * This means we are better off reading the file via `java.io.InputStream`
instead of `java.net.URL` to avoid extra code
- * processing.
- *
- * @see java.net.URL
- * @see InputStream
- */
-public class FileTestUtils {
-
- /**
- * read file From file URL string.
- * @param fileUrl fileUrl
- * @return byte array
- */
- public static byte[] readFromFileURLString(final String fileUrl) {
- return
readInputStream(ClassLoader.getSystemResourceAsStream(fileUrl)).getBytes(StandardCharsets.UTF_8);
- }
-
- private static String readInputStream(final InputStream is) {
- StringBuilder out = new StringBuilder();
- try (
- InputStreamReader streamReader = new InputStreamReader(is,
StandardCharsets.UTF_8);
- BufferedReader reader = new BufferedReader(streamReader)) {
- String line;
- while ((line = reader.readLine()) != null) {
- out.append(line);
- // ShardingSphere does not actively handle line separators
when parsing YAML and needs to be actively added.
- out.append(System.lineSeparator());
- }
- } catch (IOException e) {
- Logger.getLogger(FileTestUtils.class.getName()).log(Level.SEVERE,
null, e);
- }
- return out.toString();
- }
-}
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/MSSQLServerTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/MSSQLServerTest.java
index bf2f8ea9707..3a7aaf5ab05 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/MSSQLServerTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/MSSQLServerTest.java
@@ -17,24 +17,26 @@
package org.apache.shardingsphere.test.natived.jdbc.databases;
-import
org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
import org.apache.shardingsphere.test.natived.jdbc.commons.TestShardingService;
-import org.apache.shardingsphere.test.natived.jdbc.commons.FileTestUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledInNativeImage;
import javax.sql.DataSource;
-import java.io.IOException;
import java.sql.SQLException;
+@EnabledInNativeImage
class MSSQLServerTest {
private TestShardingService testShardingService;
@Test
- @EnabledInNativeImage
- void assertShardingInLocalTransactions() throws SQLException, IOException {
- DataSource dataSource =
YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("test-native/yaml/databases/mssqlserver.yaml"));
+ void assertShardingInLocalTransactions() throws SQLException {
+ HikariConfig config = new HikariConfig();
+
config.setDriverClassName("org.apache.shardingsphere.driver.ShardingSphereDriver");
+
config.setJdbcUrl("jdbc:shardingsphere:classpath:test-native/yaml/databases/mssqlserver.yaml");
+ DataSource dataSource = new HikariDataSource(config);
testShardingService = new TestShardingService(dataSource);
this.initEnvironment();
testShardingService.processSuccess();
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/PostgresTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/PostgresTest.java
index 650502117e2..9275d359c4e 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/PostgresTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/PostgresTest.java
@@ -17,24 +17,26 @@
package org.apache.shardingsphere.test.natived.jdbc.databases;
-import
org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
import org.apache.shardingsphere.test.natived.jdbc.commons.TestShardingService;
-import org.apache.shardingsphere.test.natived.jdbc.commons.FileTestUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledInNativeImage;
import javax.sql.DataSource;
-import java.io.IOException;
import java.sql.SQLException;
+@EnabledInNativeImage
class PostgresTest {
private TestShardingService testShardingService;
@Test
- @EnabledInNativeImage
- void assertShardingInLocalTransactions() throws SQLException, IOException {
- DataSource dataSource =
YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("test-native/yaml/databases/postgresql.yaml"));
+ void assertShardingInLocalTransactions() throws SQLException {
+ HikariConfig config = new HikariConfig();
+
config.setDriverClassName("org.apache.shardingsphere.driver.ShardingSphereDriver");
+
config.setJdbcUrl("jdbc:shardingsphere:classpath:test-native/yaml/databases/postgresql.yaml");
+ DataSource dataSource = new HikariDataSource(config);
testShardingService = new TestShardingService(dataSource);
this.initEnvironment();
testShardingService.processSuccess();
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/EncryptTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/EncryptTest.java
index e11830a8985..d8e6c9bb618 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/EncryptTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/EncryptTest.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.test.natived.jdbc.features;
-import
org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
-import org.apache.shardingsphere.test.natived.jdbc.commons.FileTestUtils;
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
import org.apache.shardingsphere.test.natived.jdbc.commons.entity.Address;
import org.apache.shardingsphere.test.natived.jdbc.commons.entity.Order;
import org.apache.shardingsphere.test.natived.jdbc.commons.entity.OrderItem;
@@ -28,7 +28,6 @@ import
org.apache.shardingsphere.test.natived.jdbc.commons.repository.OrderRepos
import org.junit.jupiter.api.Test;
import javax.sql.DataSource;
-import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
@@ -48,8 +47,11 @@ class EncryptTest {
private AddressRepository addressRepository;
@Test
- void assertEncryptInLocalTransactions() throws SQLException, IOException {
- DataSource dataSource =
YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("test-native/yaml/features/encrypt.yaml"));
+ void assertEncryptInLocalTransactions() throws SQLException {
+ HikariConfig config = new HikariConfig();
+
config.setDriverClassName("org.apache.shardingsphere.driver.ShardingSphereDriver");
+
config.setJdbcUrl("jdbc:shardingsphere:classpath:test-native/yaml/features/encrypt.yaml");
+ DataSource dataSource = new HikariDataSource(config);
orderRepository = new OrderRepository(dataSource);
orderItemRepository = new OrderItemRepository(dataSource);
addressRepository = new AddressRepository(dataSource);
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/MaskTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/MaskTest.java
index 512bc207aaf..5f9a6742c36 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/MaskTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/MaskTest.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.test.natived.jdbc.features;
-import
org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
-import org.apache.shardingsphere.test.natived.jdbc.commons.FileTestUtils;
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
import org.apache.shardingsphere.test.natived.jdbc.commons.entity.Address;
import org.apache.shardingsphere.test.natived.jdbc.commons.entity.Order;
import org.apache.shardingsphere.test.natived.jdbc.commons.entity.OrderItem;
@@ -28,7 +28,6 @@ import
org.apache.shardingsphere.test.natived.jdbc.commons.repository.OrderRepos
import org.junit.jupiter.api.Test;
import javax.sql.DataSource;
-import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
@@ -48,8 +47,11 @@ class MaskTest {
private AddressRepository addressRepository;
@Test
- void assertMaskInLocalTransactions() throws SQLException, IOException {
- DataSource dataSource =
YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("test-native/yaml/features/mask.yaml"));
+ void assertMaskInLocalTransactions() throws SQLException {
+ HikariConfig config = new HikariConfig();
+
config.setDriverClassName("org.apache.shardingsphere.driver.ShardingSphereDriver");
+
config.setJdbcUrl("jdbc:shardingsphere:classpath:test-native/yaml/features/mask.yaml");
+ DataSource dataSource = new HikariDataSource(config);
orderRepository = new OrderRepository(dataSource);
orderItemRepository = new OrderItemRepository(dataSource);
addressRepository = new AddressRepository(dataSource);
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/ReadWriteSplittingTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/ReadWriteSplittingTest.java
index 3af60a478bb..e83e9e0a5a4 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/ReadWriteSplittingTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/ReadWriteSplittingTest.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.test.natived.jdbc.features;
-import
org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
-import org.apache.shardingsphere.test.natived.jdbc.commons.FileTestUtils;
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
import org.apache.shardingsphere.test.natived.jdbc.commons.entity.Address;
import org.apache.shardingsphere.test.natived.jdbc.commons.entity.Order;
import org.apache.shardingsphere.test.natived.jdbc.commons.entity.OrderItem;
@@ -29,7 +29,6 @@ import org.h2.jdbc.JdbcSQLSyntaxErrorException;
import org.junit.jupiter.api.Test;
import javax.sql.DataSource;
-import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
@@ -45,8 +44,11 @@ class ReadWriteSplittingTest {
private AddressRepository addressRepository;
@Test
- void assertReadWriteSplittingInLocalTransactions() throws SQLException,
IOException {
- DataSource dataSource =
YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("test-native/yaml/features/readwrite-splitting.yaml"));
+ void assertReadWriteSplittingInLocalTransactions() throws SQLException {
+ HikariConfig config = new HikariConfig();
+
config.setDriverClassName("org.apache.shardingsphere.driver.ShardingSphereDriver");
+
config.setJdbcUrl("jdbc:shardingsphere:classpath:test-native/yaml/features/readwrite-splitting.yaml");
+ DataSource dataSource = new HikariDataSource(config);
orderRepository = new OrderRepository(dataSource);
orderItemRepository = new OrderItemRepository(dataSource);
addressRepository = new AddressRepository(dataSource);
@@ -66,11 +68,11 @@ class ReadWriteSplittingTest {
private void processSuccess() throws SQLException {
Collection<Long> orderIds = insertData();
- // This is intentional because the read operation is in the slave
database and the corresponding table does not exist.
- assertThrows(JdbcSQLSyntaxErrorException.class, this::printData);
+ assertThrows(JdbcSQLSyntaxErrorException.class, this::printData,
+ "This is intentional because the read operation is in the
slave database and the corresponding table does not exist.");
deleteData(orderIds);
- // This is intentional because the read operation is in the slave
database and the corresponding table does not exist.
- assertThrows(JdbcSQLSyntaxErrorException.class, this::printData);
+ assertThrows(JdbcSQLSyntaxErrorException.class, this::printData,
+ "This is intentional because the read operation is in the
slave database and the corresponding table does not exist.");
}
private Collection<Long> insertData() throws SQLException {
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/ShadowTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/ShadowTest.java
index 17645c3ae4e..fea3bb471da 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/ShadowTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/ShadowTest.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.test.natived.jdbc.features;
-import
org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
-import org.apache.shardingsphere.test.natived.jdbc.commons.FileTestUtils;
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
import org.apache.shardingsphere.test.natived.jdbc.commons.entity.Address;
import org.apache.shardingsphere.test.natived.jdbc.commons.entity.Order;
import org.apache.shardingsphere.test.natived.jdbc.commons.entity.OrderItem;
@@ -28,7 +28,6 @@ import
org.apache.shardingsphere.test.natived.jdbc.commons.repository.OrderRepos
import org.junit.jupiter.api.Test;
import javax.sql.DataSource;
-import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -49,8 +48,11 @@ class ShadowTest {
private AddressRepository addressRepository;
@Test
- void assertShadowInLocalTransactions() throws SQLException, IOException {
- DataSource dataSource =
YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("test-native/yaml/features/shadow.yaml"));
+ void assertShadowInLocalTransactions() throws SQLException {
+ HikariConfig config = new HikariConfig();
+
config.setDriverClassName("org.apache.shardingsphere.driver.ShardingSphereDriver");
+
config.setJdbcUrl("jdbc:shardingsphere:classpath:test-native/yaml/features/shadow.yaml");
+ DataSource dataSource = new HikariDataSource(config);
orderRepository = new OrderRepository(dataSource);
orderItemRepository = new OrderItemRepository(dataSource);
addressRepository = new AddressRepository(dataSource);
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/ShardingTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/ShardingTest.java
index 76b966af7b5..79e34f43470 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/ShardingTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/features/ShardingTest.java
@@ -17,13 +17,12 @@
package org.apache.shardingsphere.test.natived.jdbc.features;
-import
org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
import org.apache.shardingsphere.test.natived.jdbc.commons.TestShardingService;
-import org.apache.shardingsphere.test.natived.jdbc.commons.FileTestUtils;
import org.junit.jupiter.api.Test;
import javax.sql.DataSource;
-import java.io.IOException;
import java.sql.SQLException;
class ShardingTest {
@@ -31,8 +30,11 @@ class ShardingTest {
private TestShardingService testShardingService;
@Test
- void assertShardingInLocalTransactions() throws SQLException, IOException {
- DataSource dataSource =
YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("test-native/yaml/features/sharding.yaml"));
+ void assertShardingInLocalTransactions() throws SQLException {
+ HikariConfig config = new HikariConfig();
+
config.setDriverClassName("org.apache.shardingsphere.driver.ShardingSphereDriver");
+
config.setJdbcUrl("jdbc:shardingsphere:classpath:test-native/yaml/features/sharding.yaml");
+ DataSource dataSource = new HikariDataSource(config);
testShardingService = new TestShardingService(dataSource);
this.initEnvironment();
testShardingService.processSuccess();
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/mode/cluster/EtcdTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/mode/cluster/EtcdTest.java
index 96f371e435f..078b82f4b63 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/mode/cluster/EtcdTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/mode/cluster/EtcdTest.java
@@ -17,47 +17,41 @@
package org.apache.shardingsphere.test.natived.jdbc.mode.cluster;
-import com.github.dockerjava.api.model.ExposedPort;
-import com.github.dockerjava.api.model.HostConfig;
-import com.github.dockerjava.api.model.PortBinding;
-import com.github.dockerjava.api.model.Ports;
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
+import io.etcd.jetcd.test.EtcdClusterExtension;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.io.entity.EntityUtils;
-import
org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
-import org.apache.shardingsphere.test.natived.jdbc.commons.FileTestUtils;
import org.apache.shardingsphere.test.natived.jdbc.commons.TestShardingService;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledInNativeImage;
-import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.GenericContainer;
-import org.testcontainers.containers.output.Slf4jLogConsumer;
-import org.testcontainers.containers.wait.strategy.Wait;
-import org.testcontainers.utility.DockerImageName;
+import org.junit.jupiter.api.extension.RegisterExtension;
import javax.sql.DataSource;
import java.io.IOException;
+import java.net.URI;
import java.sql.SQLException;
import java.time.Duration;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.UUID;
-import java.util.stream.Collectors;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
+
+@EnabledInNativeImage
class EtcdTest {
- private static final Integer ETCD_CLIENT_PORT_ON_HOST = 62290;
-
- private static final Integer ETCD_CLIENT_PORT = 2379;
+ @RegisterExtension
+ public static final EtcdClusterExtension CLUSTER =
EtcdClusterExtension.builder()
+ .withNodes(1)
+ .withMountDirectory(false)
+ .build();
- private static final Integer ETCD_PEER_PORT = 2380;
+ private static final String SYSTEM_PROP_KEY_PREFIX =
"fixture.test-native.yaml.mode.cluster.etcd.";
private TestShardingService testShardingService;
@@ -68,34 +62,17 @@ class EtcdTest {
*
* @see
org.apache.shardingsphere.mode.repository.cluster.etcd.EtcdRepository
*/
- @SuppressWarnings("resource")
@Test
- @EnabledInNativeImage
- void assertShardingInLocalTransactions() throws SQLException, IOException {
- String node = "etcd0";
- Collection<String> nodes = Collections.singletonList(node);
- try (
- GenericContainer<?> container = new
GenericContainer<>(DockerImageName.parse("quay.io/coreos/etcd:v3.5.11"))
- .withCreateContainerCmdModifier(
- cmd -> cmd.withHostConfig(new
HostConfig().withPortBindings(new
PortBinding(Ports.Binding.bindPort(ETCD_CLIENT_PORT_ON_HOST), new
ExposedPort(ETCD_CLIENT_PORT)))))
- .withNetworkAliases(node)
- .withLogConsumer(new
Slf4jLogConsumer(LoggerFactory.getLogger(getClass())).withPrefix(node))
- .withCommand(createCommand(node, nodes))
- .withEnv("ETCD_LOG_LEVEL", "info")
- .withEnv("ETCD_LOGGER", "zap")
-
.waitingFor(Wait.forHttp("/health").forPort(ETCD_CLIENT_PORT))) {
- container.start();
- beforeAll();
- DataSource dataSource =
YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("test-native/yaml/mode/cluster/etcd.yaml"));
- testShardingService = new TestShardingService(dataSource);
- initEnvironment();
-
Awaitility.await().atMost(Duration.ofSeconds(30L)).ignoreExceptions().until(()
-> {
- dataSource.getConnection().close();
- return true;
- });
- testShardingService.processSuccess();
- testShardingService.cleanEnvironment();
- }
+ void assertShardingInLocalTransactions() throws SQLException {
+ DataSource dataSource = createDataSource();
+ testShardingService = new TestShardingService(dataSource);
+ initEnvironment();
+
Awaitility.await().atMost(Duration.ofSeconds(30L)).ignoreExceptions().until(()
-> {
+ dataSource.getConnection().close();
+ return true;
+ });
+ testShardingService.processSuccess();
+ testShardingService.cleanEnvironment();
}
private void initEnvironment() throws SQLException {
@@ -107,40 +84,24 @@ class EtcdTest {
testShardingService.getAddressRepository().truncateTable();
}
- private void beforeAll() {
-
Awaitility.await().atMost(Duration.ofSeconds(30L)).ignoreExceptions().until(this::verifyEtcdClusterRunning);
- }
-
- @SuppressWarnings("HttpUrlsUsage")
- private String[] createCommand(final String node, final Collection<String>
nodes) {
- List<String> cmd = new ArrayList<>();
- cmd.add("etcd");
- cmd.add("--name");
- cmd.add(node);
- cmd.add("--advertise-client-urls");
- cmd.add("http" + "://0.0.0.0:" + ETCD_CLIENT_PORT);
- cmd.add("--listen-client-urls");
- cmd.add("http" + "://0.0.0.0:" + ETCD_CLIENT_PORT);
- Collection<String> shouldMountDataDirectory =
Arrays.asList("--data-dir", "/tmp/etcd-data");
- cmd.addAll(shouldMountDataDirectory);
- if (nodes.size() > 1) {
- cmd.add("--initial-advertise-peer-urls");
- cmd.add("http://" + node + ":" + ETCD_PEER_PORT);
- cmd.add("--listen-peer-urls");
- cmd.add("http://0.0.0.0:" + ETCD_PEER_PORT);
- cmd.add("--initial-cluster");
- cmd.add(nodes.stream().map(e -> e + "=http://" + e + ":" +
ETCD_PEER_PORT).collect(Collectors.joining(",")));
- cmd.add("--initial-cluster-state");
- cmd.add("new");
- Collection<String> clusterToken =
Arrays.asList("--initial-cluster-token", UUID.randomUUID().toString());
- cmd.addAll(clusterToken);
+ private DataSource createDataSource() {
+ URI clientEndpoint = CLUSTER.clientEndpoints().get(0);
+
Awaitility.await().atMost(Duration.ofSeconds(30L)).ignoreExceptions().until(()
-> verifyEtcdClusterRunning(clientEndpoint));
+ HikariConfig config = new HikariConfig();
+
config.setDriverClassName("org.apache.shardingsphere.driver.ShardingSphereDriver");
+
config.setJdbcUrl("jdbc:shardingsphere:classpath-system-props:test-native/yaml/mode/cluster/etcd.yaml");
+ try {
+ assertThat(System.getProperty(SYSTEM_PROP_KEY_PREFIX +
"server-lists"), is(nullValue()));
+ System.setProperty(SYSTEM_PROP_KEY_PREFIX + "server-lists",
clientEndpoint.toString());
+ return new HikariDataSource(config);
+ } finally {
+ System.clearProperty(SYSTEM_PROP_KEY_PREFIX + "server-lists");
}
- return cmd.toArray(new String[0]);
}
- private Boolean verifyEtcdClusterRunning() throws IOException {
+ private Boolean verifyEtcdClusterRunning(final URI clientEndpoint) throws
IOException {
boolean flag = false;
- HttpGet httpGet = new HttpGet("http://localhost:" +
ETCD_CLIENT_PORT_ON_HOST + "/health");
+ HttpGet httpGet = new HttpGet(clientEndpoint.toString() + "/health");
try (
CloseableHttpClient httpclient = HttpClients.createDefault();
CloseableHttpResponse response = httpclient.execute(httpGet)) {
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/mode/cluster/ZookeeperTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/mode/cluster/ZookeeperTest.java
index d1c9ee4f2bb..b547e15ed54 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/mode/cluster/ZookeeperTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/mode/cluster/ZookeeperTest.java
@@ -17,30 +17,29 @@
package org.apache.shardingsphere.test.natived.jdbc.mode.cluster;
-import com.github.dockerjava.api.model.ExposedPort;
-import com.github.dockerjava.api.model.HostConfig;
-import com.github.dockerjava.api.model.PortBinding;
-import com.github.dockerjava.api.model.Ports;
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;
-import
org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
-import org.apache.shardingsphere.test.natived.jdbc.commons.FileTestUtils;
+import org.apache.curator.test.TestingServer;
import org.apache.shardingsphere.test.natived.jdbc.commons.TestShardingService;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledInNativeImage;
-import org.testcontainers.containers.GenericContainer;
-import org.testcontainers.utility.DockerImageName;
import javax.sql.DataSource;
-import java.io.IOException;
import java.sql.SQLException;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
+
class ZookeeperTest {
+ private static final String SYSTEM_PROP_KEY_PREFIX =
"fixture.test-native.yaml.mode.cluster.zookeeper.";
+
private TestShardingService testShardingService;
/**
@@ -50,16 +49,11 @@ class ZookeeperTest {
*
* @see
org.apache.shardingsphere.mode.repository.cluster.zookeeper.ZookeeperRepository
*/
- @SuppressWarnings("resource")
@Test
- @EnabledInNativeImage
- void assertShardingInLocalTransactions() throws SQLException, IOException {
- try (
- GenericContainer<?> container = new
GenericContainer<>(DockerImageName.parse("zookeeper:3.9.1-jre-17"))
- .withCreateContainerCmdModifier(cmd ->
cmd.withHostConfig(new HostConfig().withPortBindings(new
PortBinding(Ports.Binding.bindPort(62372), new ExposedPort(2181)))))) {
- container.start();
- beforeAll();
- DataSource dataSource =
YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("test-native/yaml/mode/cluster/zookeeper.yaml"));
+ void assertShardingInLocalTransactions() throws Exception {
+ try (TestingServer testingServer = new TestingServer()) {
+ String connectString = testingServer.getConnectString();
+ DataSource dataSource = createDataSource(connectString);
testShardingService = new TestShardingService(dataSource);
initEnvironment();
Awaitility.await().atMost(Duration.ofSeconds(30L)).ignoreExceptions().until(()
-> {
@@ -80,12 +74,22 @@ class ZookeeperTest {
testShardingService.getAddressRepository().truncateTable();
}
- private void beforeAll() {
+ private DataSource createDataSource(final String connectString) {
Awaitility.await().atMost(Duration.ofSeconds(30L)).ignoreExceptions().until(()
-> {
- try (CuratorFramework client =
CuratorFrameworkFactory.newClient("localhost:" + 62372, new
ExponentialBackoffRetry(1000, 3))) {
+ try (CuratorFramework client =
CuratorFrameworkFactory.newClient(connectString, new
ExponentialBackoffRetry(1000, 3))) {
client.start();
return client.blockUntilConnected(5, TimeUnit.SECONDS);
}
});
+ HikariConfig config = new HikariConfig();
+
config.setDriverClassName("org.apache.shardingsphere.driver.ShardingSphereDriver");
+
config.setJdbcUrl("jdbc:shardingsphere:classpath-system-props:test-native/yaml/mode/cluster/zookeeper.yaml");
+ try {
+ assertThat(System.getProperty(SYSTEM_PROP_KEY_PREFIX +
"server-lists"), is(nullValue()));
+ System.setProperty(SYSTEM_PROP_KEY_PREFIX + "server-lists",
connectString);
+ return new HikariDataSource(config);
+ } finally {
+ System.clearProperty(SYSTEM_PROP_KEY_PREFIX + "server-lists");
+ }
}
}
diff --git
a/test/native/src/test/resources/test-native/yaml/mode/cluster/etcd.yaml
b/test/native/src/test/resources/test-native/yaml/mode/cluster/etcd.yaml
index 76763d3438f..71efc4b792e 100644
--- a/test/native/src/test/resources/test-native/yaml/mode/cluster/etcd.yaml
+++ b/test/native/src/test/resources/test-native/yaml/mode/cluster/etcd.yaml
@@ -21,7 +21,7 @@ mode:
type: etcd
props:
namespace: governance-etcd-data-source
- server-lists: http://localhost:62290
+ server-lists:
$${fixture.test-native.yaml.mode.cluster.etcd.server-lists::}
dataSources:
ds_0:
diff --git
a/test/native/src/test/resources/test-native/yaml/mode/cluster/zookeeper.yaml
b/test/native/src/test/resources/test-native/yaml/mode/cluster/zookeeper.yaml
index fbf8d05b50a..0c0690c6010 100644
---
a/test/native/src/test/resources/test-native/yaml/mode/cluster/zookeeper.yaml
+++
b/test/native/src/test/resources/test-native/yaml/mode/cluster/zookeeper.yaml
@@ -21,7 +21,7 @@ mode:
type: ZooKeeper
props:
namespace: governance-zookeeper-data-source
- server-lists: localhost:62372
+ server-lists:
$${fixture.test-native.yaml.mode.cluster.zookeeper.server-lists::}
dataSources:
ds_0: