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 4ddc0df3c5e Refactor NativeTest to prevent failure in building GraalVM
Native Image (#36078)
4ddc0df3c5e is described below
commit 4ddc0df3c5e240dbb08fa7e4811005ad506a9a5b
Author: Ling Hengqian <[email protected]>
AuthorDate: Mon Jul 28 11:48:00 2025 +0800
Refactor NativeTest to prevent failure in building GraalVM Native Image
(#36078)
---
.github/workflows/graalvm.yml | 6 ++-
.github/workflows/nightly-ci-dynamic.yml | 2 +-
.github/workflows/nightly-ci.yml | 4 +-
.../optional-plugins/clickhouse/_index.cn.md | 10 +++-
.../optional-plugins/clickhouse/_index.en.md | 11 ++++-
.../optional-plugins/firebird/_index.cn.md | 2 +-
.../optional-plugins/firebird/_index.en.md | 2 +-
.../optional-plugins/hiveserver2/_index.cn.md | 36 +++++++++++++--
.../optional-plugins/hiveserver2/_index.en.md | 42 ++++++++++++++---
.../special-api/transaction/seata.cn.md | 4 +-
.../special-api/transaction/seata.en.md | 4 +-
.../optional-plugins/seata-at/_index.cn.md | 2 +-
.../optional-plugins/seata-at/_index.en.md | 2 +-
.../reachability-metadata.json | 54 +++++++++++++++++-----
.../reachability-metadata.json | 28 -----------
pom.xml | 6 +--
.../commons/repository/AddressRepository.java | 22 ++++++++-
.../commons/repository/OrderItemRepository.java | 27 ++++++++++-
.../commons/repository/OrderRepository.java | 33 ++++++++++---
.../test/natived/jdbc/databases/FirebirdTest.java | 4 +-
.../test/natived/jdbc/databases/MySQLTest.java | 2 +-
.../natived/jdbc/databases/hive/AcidTableTest.java | 42 ++++++-----------
.../natived/jdbc/databases/hive/IcebergTest.java | 24 +++++-----
.../databases/hive/StandaloneMetastoreTest.java | 26 +++++------
.../hive/ZookeeperServiceDiscoveryTest.java | 23 +++++----
.../test/natived/proxy/databases/MySQLTest.java | 2 +-
.../test/natived/proxy/databases/PostgresTest.java | 2 +-
.../natived/proxy/transactions/base/SeataTest.java | 2 +-
.../resources/container-license-acceptance.txt | 2 +-
.../yaml/jdbc/databases/clickhouse.yaml | 6 +--
.../yaml/jdbc/databases/postgresql.yaml | 6 +--
.../test-native/yaml/jdbc/databases/sqlserver.yaml | 6 +--
.../yaml/jdbc/transactions/base/seata.yaml | 6 +--
33 files changed, 289 insertions(+), 161 deletions(-)
diff --git a/.github/workflows/graalvm.yml b/.github/workflows/graalvm.yml
index 698700c51b0..1a8f5ce8381 100644
--- a/.github/workflows/graalvm.yml
+++ b/.github/workflows/graalvm.yml
@@ -33,8 +33,12 @@ concurrency:
cancel-in-progress: true
jobs:
+ global-environment:
+ name: Import Global Environment
+ uses: ./.github/workflows/required-reusable.yml
nativetest:
if: github.repository == 'apache/shardingsphere'
+ needs: global-environment
name: GraalVM - GraalVM CE for JDK ${{ matrix.java-version }} on ${{
matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 90
@@ -74,4 +78,4 @@ jobs:
run: ./mvnw -PgenerateMetadata -e -T 1C clean verify
- name: Run nativeTest with GraalVM CE for ${{ matrix.java-version }}
if: matrix.os == 'ubuntu-latest'
- run: ./mvnw -PnativeTestInShardingSphere -e
"-DjvmArgs=-XX:MaxRAMPercentage=70.0" clean verify
+ run: ./mvnw -PnativeTestInShardingSphere -e
"-DjvmArgs=-XX:MaxRAMPercentage=85.0" clean verify
diff --git a/.github/workflows/nightly-ci-dynamic.yml
b/.github/workflows/nightly-ci-dynamic.yml
index 55b35cbcc12..10eb5488243 100644
--- a/.github/workflows/nightly-ci-dynamic.yml
+++ b/.github/workflows/nightly-ci-dynamic.yml
@@ -156,4 +156,4 @@ jobs:
${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX
}}-maven-third-party-cache-
${{ needs.global-environment.outputs.GLOBAL_CACHE_PREFIX
}}-maven-third-party-
- name: Run nativeTest with GraalVM CE
- run: ./mvnw -PnativeTestInShardingSphere -e
"-DjvmArgs=-XX:MaxRAMPercentage=70.0" clean verify
+ run: ./mvnw -PnativeTestInShardingSphere -e
"-DjvmArgs=-XX:MaxRAMPercentage=85.0" clean verify
diff --git a/.github/workflows/nightly-ci.yml b/.github/workflows/nightly-ci.yml
index e1980ee5e59..146efa31b88 100644
--- a/.github/workflows/nightly-ci.yml
+++ b/.github/workflows/nightly-ci.yml
@@ -101,7 +101,7 @@ jobs:
run: ./mvnw test -B -ntp -fae -T1C
ci-native-test:
- if: github.repository == 'apache/shardingsphere'
+ if: ${{ needs.global-environment.outputs.GLOBAL_JOB_ENABLED == 'true' }}
name: NativeTest CI - GraalVM CE on ${{ matrix.os }}
needs: global-environment
runs-on: ${{ matrix.os }}
@@ -141,4 +141,4 @@ jobs:
run: ./mvnw -PgenerateMetadata -e -T 1C clean verify
- name: Run nativeTest with GraalVM CE
if: matrix.os == 'ubuntu-latest'
- run: ./mvnw -PnativeTestInShardingSphere -e
"-DjvmArgs=-XX:MaxRAMPercentage=70.0" clean verify
+ run: ./mvnw -PnativeTestInShardingSphere -e
"-DjvmArgs=-XX:MaxRAMPercentage=85.0" clean verify
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/clickhouse/_index.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/clickhouse/_index.cn.md
index d7fd211fcd9..f726c3aec18 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/clickhouse/_index.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/clickhouse/_index.cn.md
@@ -43,7 +43,9 @@ ShardingSphere 对 ClickHouse JDBC Driver 的支持位于可选模块中。
```yaml
services:
clickhouse-server:
- image: clickhouse/clickhouse-server:25.4.5.24
+ image: clickhouse/clickhouse-server:25.6.5.41
+ environment:
+ CLICKHOUSE_SKIP_USER_SETUP: "1"
ports:
- "8123:8123"
```
@@ -225,3 +227,9 @@ ClickHouse 不支持 ShardingSphere 集成级别的本地事务,XA 事务或 S
嵌入式 ClickHouse `chDB` 尚未发布 Java 客户端,
ShardingSphere 不针对 SNAPSHOT 版本的 https://github.com/chdb-io/chdb-java 做集成测试。
参考 https://github.com/chdb-io/chdb/issues/243 。
+
+### ClickHouse JDBC Driver V2 限制
+
+ClickHouse JDBC Driver V2 自
https://github.com/ClickHouse/clickhouse-java/pull/2368 所在的 `0.8.6` 里程碑开始,
+使用 `org.antlr:antlr4-maven-plugin:4.13.2`。这与 ShardingSphere 使用的
`org.antlr:antlr4-runtime:4.10.1` 产生冲突。
+ShardingSphere 仅使用 `com.clickhouse:clickhouse-jdbc:0.6.3:http` 测试 ClickHouse
集成。
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/clickhouse/_index.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/clickhouse/_index.en.md
index 6d500363947..1de9af104ce 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/clickhouse/_index.en.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/clickhouse/_index.en.md
@@ -43,7 +43,9 @@ Write a Docker Compose file to start ClickHouse.
```yaml
services:
clickhouse-server:
- image: clickhouse/clickhouse-server:25.4.5.24
+ image: clickhouse/clickhouse-server:25.6.5.41
+ environment:
+ CLICKHOUSE_SKIP_USER_SETUP: "1"
ports:
- "8123:8123"
```
@@ -231,3 +233,10 @@ See
https://github.com/ClickHouse/clickhouse-java/issues/2023 .
The embedded ClickHouse `chDB` Java client has not been released yet.
ShardingSphere does not do integration testing for the SNAPSHOT version of
https://github.com/chdb-io/chdb-java .
Refer to https://github.com/chdb-io/chdb/issues/243 .
+
+### Limitations of ClickHouse JDBC Driver V2
+
+Starting from the `0.8.6` milestone at
https://github.com/ClickHouse/clickhouse-java/pull/2368 ,
+ClickHouse JDBC Driver V2 uses `org.antlr:antlr4-maven-plugin:4.13.2`.
+This conflicts with `org.antlr:antlr4-runtime:4.10.1` used by ShardingSphere.
+ShardingSphere only uses `com.clickhouse:clickhouse-jdbc:0.6.3:http` to test
ClickHouse integration.
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/firebird/_index.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/firebird/_index.cn.md
index 49755454244..9c2afcd4b68 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/firebird/_index.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/firebird/_index.cn.md
@@ -42,7 +42,7 @@ ShardingSphere 对 Firebird JDBC Driver 的支持位于可选模块中。
```yaml
services:
firebird:
- image: firebirdsql/firebird:5.0.1
+ image: firebirdsql/firebird:5.0.3
environment:
FIREBIRD_ROOT_PASSWORD: masterkey
FIREBIRD_USER: alice
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/firebird/_index.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/firebird/_index.en.md
index 8809e7fe2ed..b3e7d366444 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/firebird/_index.en.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/firebird/_index.en.md
@@ -42,7 +42,7 @@ Write a Docker Compose file to start Firebird.
```yaml
services:
firebird:
- image: firebirdsql/firebird:5.0.1
+ image: firebirdsql/firebird:5.0.3
environment:
FIREBIRD_ROOT_PASSWORD: masterkey
FIREBIRD_USER: alice
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/hiveserver2/_index.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/hiveserver2/_index.cn.md
index fc61495d6ac..0d46a995c78 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/hiveserver2/_index.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/hiveserver2/_index.cn.md
@@ -393,8 +393,6 @@ CREATE TABLE IF NOT EXISTS t_order
status string,
PRIMARY KEY (order_id) disable novalidate
) STORED BY ICEBERG STORED AS ORC TBLPROPERTIES ('format-version' = '2');
-
-TRUNCATE TABLE t_order;
```
此时,旧的 ShardingSphere JDBC DataSource 仍可在不重新创建 JDBC DataSource 的情况下,
@@ -409,9 +407,11 @@ public class ExampleUtils {
void test(HikariDataSource dataSource) throws SQLException {
try (Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement()) {
+ statement.execute("TRUNCATE TABLE t_order");
statement.execute("INSERT INTO t_order (user_id, order_type,
address_id, status) VALUES (1, 1, 1, 'INSERT_TEST')");
statement.executeQuery("SELECT * FROM t_order");
statement.execute("DELETE FROM t_order WHERE order_id=1");
+ statement.execute("DROP TABLE IF EXISTS t_order");
}
}
}
@@ -469,8 +469,36 @@ ShardingSphere 仅需要使用 `org.apache.hadoop.mapred.JobConf` 类,
HiveServer2 并不能保证每一条 `insert` 相关的 DML SQL 都能成功执行,尽管可能没有任何异常被抛出。
-ShardingSphere JDBC DataSource 尚不支持执行 HiveServer2 的 `set`,`create
table`,`truncate table` 和 `drop table` 语句。
-用户应考虑为 ShardingSphere 提交包含单元测试的 PR。
+ShardingSphere JDBC DataSource 尚不支持执行 HiveServer2 的 `set` 语句。
+
+ShardingSphere JDBC DataSource 当前支持通过执行 `create table` 语句创建普通表,但不支持通过执行
`create table` 语句创建 Iceberg 表。
+这意味着 ShardingSphere JDBC DataSource 可执行类似如下的语句,
+
+```sql
+-- noinspection SqlNoDataSourceInspectionForFile
+create table IF NOT EXISTS t_order (
+ order_id BIGINT NOT NULL,
+ order_type INT,
+ user_id INT NOT NULL,
+ address_id BIGINT NOT NULL,
+ status VARCHAR(50),
+ PRIMARY KEY (order_id) disable novalidate
+) CLUSTERED BY (order_id) INTO 2 BUCKETS STORED AS ORC TBLPROPERTIES
('transactional' = 'true');
+```
+
+但 ShardingSphere JDBC DataSource 无法执行类似如下的语句,
+
+```sql
+-- noinspection SqlNoDataSourceInspectionForFile
+CREATE TABLE IF NOT EXISTS t_order (
+ order_id BIGINT NOT NULL,
+ order_type INT,
+ user_id INT NOT NULL,
+ address_id BIGINT NOT NULL,
+ status string,
+ PRIMARY KEY (order_id) disable novalidate
+) STORED BY ICEBERG STORED AS ORC TBLPROPERTIES ('format-version' = '2');
+```
#### 使用 `initFile` 参数部分绕开 SQL 限制
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/hiveserver2/_index.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/hiveserver2/_index.en.md
index e4e91e21de1..606a96e29d0 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/hiveserver2/_index.en.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/optional-plugins/hiveserver2/_index.en.md
@@ -150,8 +150,6 @@ CREATE TABLE IF NOT EXISTS t_order
status string,
PRIMARY KEY (order_id) disable novalidate
) STORED BY ICEBERG STORED AS ORC TBLPROPERTIES ('format-version' = '2');
-
-TRUNCATE TABLE t_order;
```
### Create ShardingSphere data source in business projects
@@ -213,9 +211,11 @@ public class ExampleUtils {
try (HikariDataSource dataSource = new HikariDataSource(config);
Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement()) {
+ statement.execute("TRUNCATE TABLE t_order");
statement.execute("INSERT INTO t_order (user_id, order_type,
address_id, status) VALUES (1, 1, 1, 'INSERT_TEST')");
statement.executeQuery("SELECT * FROM t_order");
statement.execute("DELETE FROM t_order WHERE user_id=1");
+ statement.execute("DROP TABLE IF EXISTS t_order");
}
}
}
@@ -432,7 +432,7 @@ ShardingSphere is only integrated tested for HiveServer2
`4.0.1`.
### Uber JAR Limitation of HiveServer2 JDBC Driver
-Affected by https://issues.apache.org/jira/browse/HIVE-28445,
+Affected by https://issues.apache.org/jira/browse/HIVE-28445 ,
users should not use `org.apache.hive:hive-jdbc:4.0.1` with `classifier` as
`standalone` to avoid dependency conflicts.
### Embedded HiveServer2 Limitation
@@ -440,7 +440,7 @@ users should not use `org.apache.hive:hive-jdbc:4.0.1` with
`classifier` as `sta
Embedded HiveServer2 is no longer considered user-friendly by the Hive
community,
and users should not try to start embedded HiveServer2 through
ShardingSphere's configuration file.
Users should always start HiveServer2 through HiveServer2's Docker Image
`apache/hive:4.0.1`.
-Reference https://issues.apache.org/jira/browse/HIVE-28418.
+Reference https://issues.apache.org/jira/browse/HIVE-28418 .
### Hadoop Limitations
@@ -475,9 +475,37 @@ so it is reasonable to exclude all additional dependencies
of `org.apache.hadoop
HiveServer2 does not guarantee that every `insert` related DML SQL can be
executed successfully, although no exception may be thrown.
-ShardingSphere JDBC DataSource does not yet support executing HiveServer2's
`set`, `create table`, `truncate table`,
-and `drop table` statements.
-Users should consider submitting a PR containing unit tests for ShardingSphere.
+ShardingSphere JDBC DataSource does not yet support executing the `set`
statement of HiveServer2.
+
+ShardingSphere JDBC DataSource currently supports creating normal tables by
executing the `create table` statement,
+but does not support creating Iceberg tables by executing the `create table`
statement.
+This means that ShardingSphere JDBC DataSource can execute statements similar
to the following,
+
+```sql
+-- noinspection SqlNoDataSourceInspectionForFile
+create table IF NOT EXISTS t_order (
+ order_id BIGINT NOT NULL,
+ order_type INT,
+ user_id INT NOT NULL,
+ address_id BIGINT NOT NULL,
+ status VARCHAR(50),
+ PRIMARY KEY (order_id) disable novalidate
+) CLUSTERED BY (order_id) INTO 2 BUCKETS STORED AS ORC TBLPROPERTIES
('transactional' = 'true');
+```
+
+But ShardingSphere JDBC DataSource cannot execute statements like the
following,
+
+```sql
+-- noinspection SqlNoDataSourceInspectionForFile
+CREATE TABLE IF NOT EXISTS t_order (
+ order_id BIGINT NOT NULL,
+ order_type INT,
+ user_id INT NOT NULL,
+ address_id BIGINT NOT NULL,
+ status string,
+ PRIMARY KEY (order_id) disable novalidate
+) STORED BY ICEBERG STORED AS ORC TBLPROPERTIES ('format-version' = '2');
+```
#### Use `initFile` parameter to partially bypass SQL restrictions
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/seata.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/seata.cn.md
index 1b6e7aacad4..d0ba0a5f2b2 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/seata.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/seata.cn.md
@@ -117,7 +117,7 @@ services:
ports:
- "8091:8091"
mysql:
- image: mysql:9.1.0
+ image: mysql:9.4.0
environment:
MYSQL_ROOT_PASSWORD: example
volumes:
@@ -215,7 +215,7 @@ config {
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
- <version>9.1.0</version>
+ <version>9.4.0</version>
</dependency>
```
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/seata.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/seata.en.md
index ab9e57bf225..e604848d32d 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/seata.en.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/special-api/transaction/seata.en.md
@@ -129,7 +129,7 @@ services:
ports:
- "8091:8091"
mysql:
- image: mysql:9.1.0
+ image: mysql:9.4.0
environment:
MYSQL_ROOT_PASSWORD: example
volumes:
@@ -228,7 +228,7 @@ add the Maven dependency of MySQL JDBC Driver.
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
- <version>9.1.0</version>
+ <version>9.4.0</version>
</dependency>
```
diff --git
a/docs/document/content/user-manual/shardingsphere-proxy/optional-plugins/seata-at/_index.cn.md
b/docs/document/content/user-manual/shardingsphere-proxy/optional-plugins/seata-at/_index.cn.md
index be1a1813a89..dde3aecbc08 100644
---
a/docs/document/content/user-manual/shardingsphere-proxy/optional-plugins/seata-at/_index.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-proxy/optional-plugins/seata-at/_index.cn.md
@@ -98,7 +98,7 @@ aopalliance:aopalliance:jar:1.0
```yaml
services:
postgres:
- image: postgres:17.2-bookworm
+ image: postgres:17.5-bookworm
environment:
POSTGRES_PASSWORD: example
volumes:
diff --git
a/docs/document/content/user-manual/shardingsphere-proxy/optional-plugins/seata-at/_index.en.md
b/docs/document/content/user-manual/shardingsphere-proxy/optional-plugins/seata-at/_index.en.md
index 10d5eedaacc..7e0977ed466 100644
---
a/docs/document/content/user-manual/shardingsphere-proxy/optional-plugins/seata-at/_index.en.md
+++
b/docs/document/content/user-manual/shardingsphere-proxy/optional-plugins/seata-at/_index.en.md
@@ -101,7 +101,7 @@ Write the Docker Compose file to start Seata Server and
Postgres Server.
```yaml
services:
postgres:
- image: postgres:17.2-bookworm
+ image: postgres:17.5-bookworm
environment:
POSTGRES_PASSWORD: example
volumes:
diff --git
a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/reachability-metadata.json
b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/reachability-metadata.json
index 8f43c6403ab..69d72e93711 100644
---
a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/reachability-metadata.json
+++
b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/generated-reachability-metadata/reachability-metadata.json
@@ -2259,18 +2259,6 @@
},
"type": "org.apache.shardingsphere.driver.ShardingSphereDriver"
},
- {
- "condition": {
- "typeReached":
"org.apache.shardingsphere.infra.database.core.metadata.data.loader.MetaDataLoader"
- },
- "type": "org.apache.shardingsphere.driver.ShardingSphereDriver"
- },
- {
- "condition": {
- "typeReached":
"org.apache.shardingsphere.infra.database.core.metadata.database.datatype.DataTypeRegistry"
- },
- "type": "org.apache.shardingsphere.driver.ShardingSphereDriver"
- },
{
"condition": {
"typeReached":
"org.apache.shardingsphere.infra.datasource.pool.props.validator.DataSourcePoolPropertiesValidator"
@@ -10209,6 +10197,34 @@
}
]
},
+ {
+ "condition": {
+ "typeReached":
"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement"
+ },
+ "type": "org.apache.shardingsphere.sql.parser.hive.parser.HiveLexer",
+ "methods": [
+ {
+ "name": "<init>",
+ "parameterTypes": [
+ "org.antlr.v4.runtime.CharStream"
+ ]
+ }
+ ]
+ },
+ {
+ "condition": {
+ "typeReached":
"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement"
+ },
+ "type": "org.apache.shardingsphere.sql.parser.hive.parser.HiveParser",
+ "methods": [
+ {
+ "name": "<init>",
+ "parameterTypes": [
+ "org.antlr.v4.runtime.TokenStream"
+ ]
+ }
+ ]
+ },
{
"condition": {
"typeReached":
"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement"
@@ -10251,6 +10267,20 @@
}
]
},
+ {
+ "condition": {
+ "typeReached":
"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement"
+ },
+ "type":
"org.apache.shardingsphere.sql.parser.hive.visitor.statement.type.HiveDDLStatementVisitor",
+ "methods": [
+ {
+ "name": "<init>",
+ "parameterTypes": [
+ "org.apache.shardingsphere.infra.database.core.type.DatabaseType"
+ ]
+ }
+ ]
+ },
{
"condition": {
"typeReached":
"org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement"
diff --git
a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/reachability-metadata.json
b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/reachability-metadata.json
index b0e554abf25..91705942896 100644
---
a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/reachability-metadata.json
+++
b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/reachability-metadata.json
@@ -380,34 +380,6 @@
},
"type":
"org.apache.shardingsphere.infra.yaml.schema.pojo.YamlShardingSphereColumnCustomizer"
},
- {
- "condition": {
- "typeReached":
"org.apache.shardingsphere.sql.parser.hive.parser.HiveLexer"
- },
- "type": "org.apache.shardingsphere.sql.parser.hive.parser.HiveLexer",
- "methods": [
- {
- "name": "<init>",
- "parameterTypes": [
- "org.antlr.v4.runtime.CharStream"
- ]
- }
- ]
- },
- {
- "condition": {
- "typeReached":
"org.apache.shardingsphere.sql.parser.hive.parser.HiveParser"
- },
- "type": "org.apache.shardingsphere.sql.parser.hive.parser.HiveParser",
- "methods": [
- {
- "name": "<init>",
- "parameterTypes": [
- "org.antlr.v4.runtime.TokenStream"
- ]
- }
- ]
- },
{
"condition": {
"typeReached":
"org.apache.shardingsphere.sql.parser.hive.visitor.statement.type.HiveDMLStatementVisitor"
diff --git a/pom.xml b/pom.xml
index a2acf4f6cc6..270400e535b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -146,11 +146,11 @@
<opentelemetry-semconv.version>1.27.0-alpha</opentelemetry-semconv.version>
<kotlin-stdlib.version>1.9.10</kotlin-stdlib.version>
- <junit.version>5.11.2</junit.version>
+ <junit.version>5.13.4</junit.version>
<hamcrest.version>3.0</hamcrest.version>
<mockito.version>4.11.0</mockito.version>
- <awaitility.version>4.2.2</awaitility.version>
- <testcontainers.version>1.21.0</testcontainers.version>
+ <awaitility.version>4.3.0</awaitility.version>
+ <testcontainers.version>1.21.3</testcontainers.version>
<commons-csv.version>1.9.0</commons-csv.version>
<graal-sdk.version>24.1.2</graal-sdk.version>
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/repository/AddressRepository.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/repository/AddressRepository.java
index 3535ee7f650..1c4e120933d 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/repository/AddressRepository.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/repository/AddressRepository.java
@@ -72,7 +72,7 @@ public final class AddressRepository {
/**
* create table t_address in Firebird.
- * Cannot use `create table if not exists` for Docker Image
`ghcr.io/fdcastel/firebird:5.0.1`,
+ * Cannot use `create table if not exists` for Docker Image
`firebirdsql/firebird`,
* see <a
href="https://github.com/FirebirdSQL/firebird/issues/8062">FirebirdSQL/firebird#8062</a>.
*
* @throws SQLException SQL exception
@@ -86,6 +86,24 @@ public final class AddressRepository {
}
}
+ /**
+ * create ACID table in HiveServer2.
+ *
+ * @throws SQLException SQL exception
+ */
+ public void createAcidTableInHiveServer2() throws SQLException {
+ String sql = "create table IF NOT EXISTS t_address (\n"
+ + " address_id BIGINT NOT NULL,\n"
+ + " address_name VARCHAR(100) NOT NULL,\n"
+ + " PRIMARY KEY (address_id) disable novalidate\n"
+ + ") CLUSTERED BY (address_id) INTO 2 BUCKETS STORED AS ORC
TBLPROPERTIES ('transactional' = 'true')";
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
+ statement.executeUpdate(sql);
+ }
+ }
+
/**
* drop table t_address in MySQL.
*
@@ -102,7 +120,7 @@ public final class AddressRepository {
/**
* drop table in Firebird.
- * Docker Image `ghcr.io/fdcastel/firebird:5.0.1` does not work with `DROP
TABLE IF EXISTS`.
+ * Docker Image `firebirdsql/firebird` does not work with `DROP TABLE IF
EXISTS`.
* See <a
href="https://github.com/FirebirdSQL/firebird/issues/4203">FirebirdSQL/firebird#4203</a>
.
*
* @throws SQLException SQL exception
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/repository/OrderItemRepository.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/repository/OrderItemRepository.java
index 2181a37f4b4..cc3b28c341e 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/repository/OrderItemRepository.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/repository/OrderItemRepository.java
@@ -104,7 +104,7 @@ public final class OrderItemRepository {
/**
* create table in Firebird.
- * Cannot use `create table if not exists` for Docker Image
`ghcr.io/fdcastel/firebird:5.0.1`,
+ * Cannot use `create table if not exists` for Docker Image
`firebirdsql/firebird`,
* see <a
href="https://github.com/FirebirdSQL/firebird/issues/8062">FirebirdSQL/firebird#8062</a>.
*
* @throws SQLException SQL exception
@@ -124,6 +124,29 @@ public final class OrderItemRepository {
}
}
+ /**
+ * create ACID table in HiveServer2.
+ * Hive does not support `AUTO_INCREMENT`,
+ * refer to <a
href="https://issues.apache.org/jira/browse/HIVE-6905">HIVE-6905</a>.
+ *
+ * @throws SQLException SQL exception
+ */
+ public void createAcidTableInHiveServer2() throws SQLException {
+ String sql = "create table IF NOT EXISTS t_order_item (\n"
+ + " order_item_id BIGINT NOT NULL,\n"
+ + " order_id BIGINT NOT NULL,\n"
+ + " user_id INT NOT NULL,\n"
+ + " phone VARCHAR(50),\n"
+ + " status VARCHAR(50),\n"
+ + " PRIMARY KEY (order_item_id) disable novalidate\n"
+ + ") CLUSTERED BY (order_item_id) INTO 2 BUCKETS STORED AS ORC
TBLPROPERTIES ('transactional' = 'true')";
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
+ statement.executeUpdate(sql);
+ }
+ }
+
/**
* drop table in MySQL.
*
@@ -140,7 +163,7 @@ public final class OrderItemRepository {
/**
* drop table in Firebird.
- * Docker Image `ghcr.io/fdcastel/firebird:5.0.1` does not work with `DROP
TABLE IF EXISTS`.
+ * Docker Image `firebirdsql/firebird` does not work with `DROP TABLE IF
EXISTS`.
* See <a
href="https://github.com/FirebirdSQL/firebird/issues/4203">FirebirdSQL/firebird#4203</a>
.
*
* @throws SQLException SQL exception
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/repository/OrderRepository.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/repository/OrderRepository.java
index 8472f5673a3..fd40a83c484 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/repository/OrderRepository.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/commons/repository/OrderRepository.java
@@ -101,7 +101,7 @@ public final class OrderRepository {
/**
* create table in Firebird.
- * Cannot use `create table if not exists` for Docker Image
`ghcr.io/fdcastel/firebird:5.0.1`,
+ * Cannot use `create table if not exists` for Docker Image
`firebirdsql/firebird`,
* see <a
href="https://github.com/FirebirdSQL/firebird/issues/8062">FirebirdSQL/firebird#8062</a>.
*
* @throws SQLException SQL exception
@@ -121,6 +121,29 @@ public final class OrderRepository {
}
}
+ /**
+ * create ACID table in HiveServer2.
+ * Hive does not support `AUTO_INCREMENT`,
+ * refer to <a
href="https://issues.apache.org/jira/browse/HIVE-6905">HIVE-6905</a>.
+ *
+ * @throws SQLException SQL exception
+ */
+ public void createAcidTableInHiveServer2() throws SQLException {
+ String sql = "create table IF NOT EXISTS t_order (\n"
+ + " order_id BIGINT NOT NULL,\n"
+ + " order_type INT,\n"
+ + " user_id INT NOT NULL,\n"
+ + " address_id BIGINT NOT NULL,\n"
+ + " status VARCHAR(50),\n"
+ + " PRIMARY KEY (order_id) disable novalidate\n"
+ + ") CLUSTERED BY (order_id) INTO 2 BUCKETS STORED AS ORC
TBLPROPERTIES ('transactional' = 'true')";
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
+ statement.executeUpdate(sql);
+ }
+ }
+
/**
* drop table in MySQL.
* TODO There is a bug in this function in shadow's unit test and requires
additional fixes.
@@ -138,7 +161,7 @@ public final class OrderRepository {
/**
* drop table in Firebird.
- * Docker Image `ghcr.io/fdcastel/firebird:5.0.1` does not work with `DROP
TABLE IF EXISTS`.
+ * Docker Image `firebirdsql/firebird` does not work with `DROP TABLE IF
EXISTS`.
* See <a
href="https://github.com/FirebirdSQL/firebird/issues/4203">FirebirdSQL/firebird#4203</a>
.
*
* @throws SQLException SQL exception
@@ -254,10 +277,8 @@ public final class OrderRepository {
* see <a
href="https://github.com/ClickHouse/ClickHouse/issues/56228">ClickHouse/ClickHouse#56228</a>
.
*
* @param order order
- * @param autoGeneratedKeys a flag indicating whether auto-generated keys
- * should be returned; one of
- * {@code Statement.RETURN_GENERATED_KEYS} or
- * {@code Statement.NO_GENERATED_KEYS}
+ * @param autoGeneratedKeys a flag indicating whether auto-generated keys
should be returned;
+ * one of {@link Statement#RETURN_GENERATED_KEYS}
or {@link Statement#NO_GENERATED_KEYS}
* @return orderId of the insert statement
* @throws SQLException SQL Exception
*/
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/FirebirdTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/FirebirdTest.java
index 23423cfff23..4e11ebd61de 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/FirebirdTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/FirebirdTest.java
@@ -53,7 +53,7 @@ class FirebirdTest {
@SuppressWarnings("resource")
@Container
- private final GenericContainer<?> container = new
GenericContainer<>("firebirdsql/firebird:5.0.1")
+ private final GenericContainer<?> container = new
GenericContainer<>("firebirdsql/firebird:5.0.3")
.withEnv("FIREBIRD_ROOT_PASSWORD", password)
.withEnv("FIREBIRD_USER", "alice")
.withEnv("FIREBIRD_PASSWORD", password)
@@ -93,7 +93,7 @@ class FirebirdTest {
}
/**
- * Docker Image `ghcr.io/fdcastel/firebird:5.0.1` cannot use `TRUNCATE
TABLE`.
+ * Docker Image `firebirdsql/firebird` cannot use `TRUNCATE TABLE`.
* See <a
href="https://github.com/FirebirdSQL/firebird/issues/2892">FirebirdSQL/firebird#2892</a>.
*
* @throws SQLException SQL Exception
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/MySQLTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/MySQLTest.java
index fa696d2bdaf..935922db3ee 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/MySQLTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/MySQLTest.java
@@ -57,7 +57,7 @@ class MySQLTest {
@SuppressWarnings("resource")
@Container
- private final GenericContainer<?> container = new
GenericContainer<>("mysql:9.1.0-oraclelinux9")
+ private final GenericContainer<?> container = new
GenericContainer<>("mysql:9.4.0-oraclelinux9")
.withEnv("MYSQL_ROOT_PASSWORD", password)
.withExposedPorts(3306);
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/hive/AcidTableTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/hive/AcidTableTest.java
index abc3dabc28d..1a57ab1ba82 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/hive/AcidTableTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/hive/AcidTableTest.java
@@ -62,6 +62,8 @@ class AcidTableTest {
private String jdbcUrlPrefix;
+ private TestShardingService testShardingService;
+
@BeforeEach
void beforeEach() {
assertThat(System.getProperty(systemPropKeyPrefix + "ds0.jdbc-url"),
is(nullValue()));
@@ -81,8 +83,19 @@ class AcidTableTest {
void assertShardingInLocalTransactions() throws SQLException {
jdbcUrlPrefix = "jdbc:hive2://localhost:" +
container.getMappedPort(10000) + "/";
logicDataSource = createDataSource();
- TestShardingService testShardingService = new
TestShardingService(logicDataSource);
+ testShardingService = new TestShardingService(logicDataSource);
+ initEnvironment();
testShardingService.processSuccessInHive();
+ testShardingService.cleanEnvironment();
+ }
+
+ private void initEnvironment() throws SQLException {
+
testShardingService.getOrderRepository().createAcidTableInHiveServer2();
+
testShardingService.getOrderItemRepository().createAcidTableInHiveServer2();
+
testShardingService.getAddressRepository().createAcidTableInHiveServer2();
+ testShardingService.getOrderRepository().truncateTable();
+ testShardingService.getOrderItemRepository().truncateTable();
+ testShardingService.getAddressRepository().truncateTable();
}
private DataSource createDataSource() throws SQLException {
@@ -108,8 +121,7 @@ class AcidTableTest {
}
/**
- * TODO `shardingsphere-parser-sql-hive` module does not support `set`,
`create table`,
- * `truncate table` and `drop table` statements yet,
+ * TODO `shardingsphere-parser-sql-hive` module does not support `set`
statements yet,
* we always need to execute the following Hive Session-level SQL in the
current {@link javax.sql.DataSource}.
* Hive does not support `AUTO_INCREMENT`,
* refer to <a
href="https://issues.apache.org/jira/browse/HIVE-6905">HIVE-6905</a>.
@@ -124,30 +136,6 @@ class AcidTableTest {
statement.execute("set metastore.compactor.initiator.on=true");
statement.execute("set metastore.compactor.cleaner.on=true");
statement.execute("set metastore.compactor.worker.threads=1");
- statement.execute("create table IF NOT EXISTS t_order (\n"
- + " order_id BIGINT NOT NULL,\n"
- + " order_type INT,\n"
- + " user_id INT NOT NULL,\n"
- + " address_id BIGINT NOT NULL,\n"
- + " status VARCHAR(50),\n"
- + " PRIMARY KEY (order_id) disable novalidate\n"
- + ") CLUSTERED BY (order_id) INTO 2 BUCKETS STORED AS ORC
TBLPROPERTIES ('transactional' = 'true')");
- statement.execute("create table IF NOT EXISTS t_order_item (\n"
- + " order_item_id BIGINT NOT NULL,\n"
- + " order_id BIGINT NOT NULL,\n"
- + " user_id INT NOT NULL,\n"
- + " phone VARCHAR(50),\n"
- + " status VARCHAR(50),\n"
- + " PRIMARY KEY (order_item_id) disable novalidate\n"
- + ") CLUSTERED BY (order_item_id) INTO 2 BUCKETS STORED AS
ORC TBLPROPERTIES ('transactional' = 'true')");
- statement.execute("create table IF NOT EXISTS t_address (\n"
- + " address_id BIGINT NOT NULL,\n"
- + " address_name VARCHAR(100) NOT NULL,\n"
- + " PRIMARY KEY (address_id) disable novalidate\n"
- + ") CLUSTERED BY (address_id) INTO 2 BUCKETS STORED AS
ORC TBLPROPERTIES ('transactional' = 'true')");
- statement.execute("TRUNCATE TABLE t_order");
- statement.execute("TRUNCATE TABLE t_order_item");
- statement.execute("TRUNCATE TABLE t_address");
} catch (final SQLException exception) {
throw new RuntimeException(exception);
}
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/hive/IcebergTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/hive/IcebergTest.java
index e14bec48c3a..0ce6c4d6465 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/hive/IcebergTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/hive/IcebergTest.java
@@ -36,7 +36,6 @@ import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.time.Duration;
-import java.util.Properties;
import java.util.stream.Stream;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -60,6 +59,8 @@ class IcebergTest {
private String jdbcUrlPrefix;
+ private TestShardingService testShardingService;
+
@BeforeEach
void beforeEach() {
assertThat(System.getProperty(systemPropKeyPrefix + "ds0.jdbc-url"),
is(nullValue()));
@@ -79,22 +80,25 @@ class IcebergTest {
void assertShardingInLocalTransactions() throws SQLException {
jdbcUrlPrefix = "jdbc:hive2://localhost:" +
container.getMappedPort(10000) + "/";
logicDataSource = createDataSource();
- TestShardingService testShardingService = new
TestShardingService(logicDataSource);
+ testShardingService = new TestShardingService(logicDataSource);
+ initEnvironment();
testShardingService.processSuccessInHive();
+ testShardingService.cleanEnvironment();
}
- private Connection openConnection() throws SQLException {
- Properties props = new Properties();
- return DriverManager.getConnection(jdbcUrlPrefix, props);
+ private void initEnvironment() throws SQLException {
+ testShardingService.getOrderRepository().truncateTable();
+ testShardingService.getOrderItemRepository().truncateTable();
+ testShardingService.getAddressRepository().truncateTable();
}
private DataSource createDataSource() throws SQLException {
Awaitility.await().atMost(Duration.ofMinutes(1L)).ignoreExceptions().until(()
-> {
- openConnection().close();
+ DriverManager.getConnection(jdbcUrlPrefix).close();
return true;
});
try (
- Connection connection = openConnection();
+ Connection connection =
DriverManager.getConnection(jdbcUrlPrefix);
Statement statement = connection.createStatement()) {
statement.execute("CREATE DATABASE demo_ds_0");
statement.execute("CREATE DATABASE demo_ds_1");
@@ -111,8 +115,7 @@ class IcebergTest {
}
/**
- * TODO `shardingsphere-parser-sql-hive` module does not support `set`,
`create table`,
- * `truncate table` and `drop table` statements yet,
+ * TODO `shardingsphere-parser-sql-hive` module does not support `set`,
`create table` statements yet,
* we always need to execute the following Hive Session-level SQL in the
current {@link javax.sql.DataSource}.
* Hive does not support `AUTO_INCREMENT`,
* refer to <a
href="https://issues.apache.org/jira/browse/HIVE-6905">HIVE-6905</a>.
@@ -145,9 +148,6 @@ class IcebergTest {
+ " address_name string NOT NULL,\n"
+ " PRIMARY KEY (address_id) disable novalidate\n"
+ ") STORED BY ICEBERG STORED AS ORC TBLPROPERTIES
('format-version' = '2')");
- statement.execute("TRUNCATE TABLE t_order");
- statement.execute("TRUNCATE TABLE t_order_item");
- statement.execute("TRUNCATE TABLE t_address");
} catch (final SQLException exception) {
throw new RuntimeException(exception);
}
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/hive/StandaloneMetastoreTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/hive/StandaloneMetastoreTest.java
index edac2943b6f..c2ee3c1add9 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/hive/StandaloneMetastoreTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/hive/StandaloneMetastoreTest.java
@@ -40,14 +40,13 @@ import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.time.Duration;
-import java.util.Properties;
import java.util.stream.Stream;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
-@SuppressWarnings({"resource", "deprecation"})
+@SuppressWarnings({"resource", "deprecation", "SqlNoDataSourceInspection"})
@EnabledInNativeImage
@Testcontainers
class StandaloneMetastoreTest {
@@ -88,6 +87,8 @@ class StandaloneMetastoreTest {
private String jdbcUrlPrefix;
+ private TestShardingService testShardingService;
+
@BeforeEach
void beforeEach() {
assertThat(System.getProperty(systemPropKeyPrefix + "ds0.jdbc-url"),
is(nullValue()));
@@ -107,22 +108,25 @@ class StandaloneMetastoreTest {
void assertShardingInLocalTransactions() throws SQLException {
jdbcUrlPrefix = "jdbc:hive2://localhost:" +
hs2Container.getMappedPort(10000) + "/";
logicDataSource = createDataSource();
- TestShardingService testShardingService = new
TestShardingService(logicDataSource);
+ testShardingService = new TestShardingService(logicDataSource);
+ initEnvironment();
testShardingService.processSuccessInHive();
+ testShardingService.cleanEnvironment();
}
- private Connection openConnection() throws SQLException {
- Properties props = new Properties();
- return DriverManager.getConnection(jdbcUrlPrefix, props);
+ private void initEnvironment() throws SQLException {
+ testShardingService.getOrderRepository().truncateTable();
+ testShardingService.getOrderItemRepository().truncateTable();
+ testShardingService.getAddressRepository().truncateTable();
}
private DataSource createDataSource() throws SQLException {
Awaitility.await().atMost(Duration.ofMinutes(1L)).ignoreExceptions().until(()
-> {
- openConnection().close();
+ DriverManager.getConnection(jdbcUrlPrefix).close();
return true;
});
try (
- Connection connection = openConnection();
+ Connection connection =
DriverManager.getConnection(jdbcUrlPrefix);
Statement statement = connection.createStatement()) {
statement.execute("CREATE DATABASE demo_ds_0");
statement.execute("CREATE DATABASE demo_ds_1");
@@ -139,8 +143,7 @@ class StandaloneMetastoreTest {
}
/**
- * TODO `shardingsphere-parser-sql-hive` module does not support `set`,
`create table`,
- * `truncate table` and `drop table` statements yet,
+ * TODO `shardingsphere-parser-sql-hive` module does not support `set`,
`create table` statements yet,
* we always need to execute the following Hive Session-level SQL in the
current {@link javax.sql.DataSource}.
* Hive does not support `AUTO_INCREMENT`,
* refer to <a
href="https://issues.apache.org/jira/browse/HIVE-6905">HIVE-6905</a>.
@@ -173,9 +176,6 @@ class StandaloneMetastoreTest {
+ " address_name string NOT NULL,\n"
+ " PRIMARY KEY (address_id) disable novalidate\n"
+ ") STORED BY ICEBERG STORED AS ORC TBLPROPERTIES
('format-version' = '2')");
- statement.execute("TRUNCATE TABLE t_order");
- statement.execute("TRUNCATE TABLE t_order_item");
- statement.execute("TRUNCATE TABLE t_address");
} catch (final SQLException exception) {
throw new RuntimeException(exception);
}
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/hive/ZookeeperServiceDiscoveryTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/hive/ZookeeperServiceDiscoveryTest.java
index 7febfee9e9a..17979542414 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/hive/ZookeeperServiceDiscoveryTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/jdbc/databases/hive/ZookeeperServiceDiscoveryTest.java
@@ -44,7 +44,6 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.time.Duration;
import java.util.List;
-import java.util.Properties;
import java.util.stream.Stream;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -74,6 +73,8 @@ class ZookeeperServiceDiscoveryTest {
private String jdbcUrlPrefix;
+ private TestShardingService testShardingService;
+
@BeforeEach
void beforeEach() {
assertThat(System.getProperty(systemPropKeyPrefix + "ds0.jdbc-url"),
is(nullValue()));
@@ -98,7 +99,6 @@ class ZookeeperServiceDiscoveryTest {
*/
@Test
void assertShardingInLocalTransactions() throws SQLException {
- TestShardingService testShardingService;
int randomPortFirst = InstanceSpec.getRandomPort();
try (
GenericContainer<?> hs2Container = new
FixedHostPortGenericContainer<>("apache/hive:4.0.1")
@@ -114,6 +114,7 @@ class ZookeeperServiceDiscoveryTest {
jdbcUrlPrefix = "jdbc:hive2://" + zookeeperContainer.getHost() +
":" + zookeeperContainer.getMappedPort(2181) + "/";
logicDataSource =
createDataSource(hs2Container.getMappedPort(randomPortFirst));
testShardingService = new TestShardingService(logicDataSource);
+ initEnvironment();
testShardingService.processSuccessInHive();
}
int randomPortSecond = InstanceSpec.getRandomPort();
@@ -130,12 +131,14 @@ class ZookeeperServiceDiscoveryTest {
hs2Container.start();
extracted(hs2Container.getMappedPort(randomPortSecond));
testShardingService.processSuccessInHive();
+ testShardingService.cleanEnvironment();
}
}
- private Connection openConnection() throws SQLException {
- Properties props = new Properties();
- return DriverManager.getConnection(jdbcUrlPrefix + jdbcUrlSuffix,
props);
+ private void initEnvironment() throws SQLException {
+ testShardingService.getOrderRepository().truncateTable();
+ testShardingService.getOrderItemRepository().truncateTable();
+ testShardingService.getAddressRepository().truncateTable();
}
private DataSource createDataSource(final Integer hiveServer2Port) throws
SQLException {
@@ -162,11 +165,11 @@ class ZookeeperServiceDiscoveryTest {
}
});
Awaitility.await().atMost(Duration.ofMinutes(1L)).ignoreExceptions().until(()
-> {
- openConnection().close();
+ DriverManager.getConnection(jdbcUrlPrefix + jdbcUrlSuffix).close();
return true;
});
try (
- Connection connection = openConnection();
+ Connection connection =
DriverManager.getConnection(jdbcUrlPrefix + jdbcUrlSuffix);
Statement statement = connection.createStatement()) {
statement.execute("CREATE DATABASE demo_ds_0");
statement.execute("CREATE DATABASE demo_ds_1");
@@ -176,8 +179,7 @@ class ZookeeperServiceDiscoveryTest {
}
/**
- * TODO `shardingsphere-parser-sql-hive` module does not support `set`,
`create table`,
- * `truncate table` and `drop table` statements yet,
+ * TODO `shardingsphere-parser-sql-hive` module does not support `set`,
`create table` statements yet,
* we always need to execute the following Hive Session-level SQL in the
current {@link javax.sql.DataSource}.
* Hive does not support `AUTO_INCREMENT`,
* refer to <a
href="https://issues.apache.org/jira/browse/HIVE-6905">HIVE-6905</a>.
@@ -210,9 +212,6 @@ class ZookeeperServiceDiscoveryTest {
+ " address_name string NOT NULL,\n"
+ " PRIMARY KEY (address_id) disable novalidate\n"
+ ") STORED BY ICEBERG STORED AS ORC TBLPROPERTIES
('format-version' = '2')");
- statement.execute("TRUNCATE TABLE t_order");
- statement.execute("TRUNCATE TABLE t_order_item");
- statement.execute("TRUNCATE TABLE t_address");
} catch (final SQLException exception) {
throw new RuntimeException(exception);
}
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/proxy/databases/MySQLTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/proxy/databases/MySQLTest.java
index 6261a77a166..f54058e221b 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/proxy/databases/MySQLTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/proxy/databases/MySQLTest.java
@@ -47,7 +47,7 @@ import java.util.Properties;
class MySQLTest {
@Container
- private final GenericContainer<?> mysqlContainer = new
GenericContainer<>("mysql:9.1.0-oraclelinux9")
+ private final GenericContainer<?> mysqlContainer = new
GenericContainer<>("mysql:9.4.0-oraclelinux9")
.withEnv("MYSQL_ROOT_PASSWORD", "yourStrongPassword123!")
.withExposedPorts(3306);
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/proxy/databases/PostgresTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/proxy/databases/PostgresTest.java
index dfc5ddcd294..bf8846f3967 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/proxy/databases/PostgresTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/proxy/databases/PostgresTest.java
@@ -46,7 +46,7 @@ import java.util.Properties;
class PostgresTest {
@Container
- private final PostgreSQLContainer<?> postgresContainer = new
PostgreSQLContainer<>("postgres:17.2-bookworm");
+ private final PostgreSQLContainer<?> postgresContainer = new
PostgreSQLContainer<>("postgres:17.5-bookworm");
private ProxyTestingServer proxyTestingServer;
diff --git
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/proxy/transactions/base/SeataTest.java
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/proxy/transactions/base/SeataTest.java
index 53afd46cf6a..94e12272e41 100644
---
a/test/native/src/test/java/org/apache/shardingsphere/test/natived/proxy/transactions/base/SeataTest.java
+++
b/test/native/src/test/java/org/apache/shardingsphere/test/natived/proxy/transactions/base/SeataTest.java
@@ -60,7 +60,7 @@ class SeataTest {
.waitingFor(Wait.forHttp("/health").forPort(7091).forStatusCode(HttpStatus.SC_OK).forResponsePredicate("ok"::equals));
@Container
- private final PostgreSQLContainer<?> postgresContainer = new
PostgreSQLContainer<>("postgres:17.2-bookworm")
+ private final PostgreSQLContainer<?> postgresContainer = new
PostgreSQLContainer<>("postgres:17.5-bookworm")
.withCopyFileToContainer(
MountableFile.forHostPath(Paths.get("src/test/resources/test-native/sh/postgres.sh").toAbsolutePath()),
"/docker-entrypoint-initdb.d/postgres.sh");
diff --git a/test/native/src/test/resources/container-license-acceptance.txt
b/test/native/src/test/resources/container-license-acceptance.txt
index 8ece678d2db..c0b6b2cc88e 100644
--- a/test/native/src/test/resources/container-license-acceptance.txt
+++ b/test/native/src/test/resources/container-license-acceptance.txt
@@ -1 +1 @@
-mcr.microsoft.com/mssql/server:2022-CU16-ubuntu-22.04
+mcr.microsoft.com/mssql/server:2022-CU20-ubuntu-22.04
diff --git
a/test/native/src/test/resources/test-native/yaml/jdbc/databases/clickhouse.yaml
b/test/native/src/test/resources/test-native/yaml/jdbc/databases/clickhouse.yaml
index 5f9d6f3c6bb..90bca7900e9 100644
---
a/test/native/src/test/resources/test-native/yaml/jdbc/databases/clickhouse.yaml
+++
b/test/native/src/test/resources/test-native/yaml/jdbc/databases/clickhouse.yaml
@@ -19,15 +19,15 @@ dataSources:
ds_0:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver
- jdbcUrl:
jdbc:tc:clickhouse:25.4.5.24:///demo_ds_0?TC_INITSCRIPT=test-native/sql/clickhouse-init.sql
+ jdbcUrl:
jdbc:tc:clickhouse:25.6.5.41:///demo_ds_0?TC_INITSCRIPT=test-native/sql/clickhouse-init.sql
ds_1:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver
- jdbcUrl:
jdbc:tc:clickhouse:25.4.5.24:///demo_ds_1?TC_INITSCRIPT=test-native/sql/clickhouse-init.sql
+ jdbcUrl:
jdbc:tc:clickhouse:25.6.5.41:///demo_ds_1?TC_INITSCRIPT=test-native/sql/clickhouse-init.sql
ds_2:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver
- jdbcUrl:
jdbc:tc:clickhouse:25.4.5.24:///demo_ds_2?TC_INITSCRIPT=test-native/sql/clickhouse-init.sql
+ jdbcUrl:
jdbc:tc:clickhouse:25.6.5.41:///demo_ds_2?TC_INITSCRIPT=test-native/sql/clickhouse-init.sql
rules:
- !SHARDING
diff --git
a/test/native/src/test/resources/test-native/yaml/jdbc/databases/postgresql.yaml
b/test/native/src/test/resources/test-native/yaml/jdbc/databases/postgresql.yaml
index 5af78e5a447..3400907e236 100644
---
a/test/native/src/test/resources/test-native/yaml/jdbc/databases/postgresql.yaml
+++
b/test/native/src/test/resources/test-native/yaml/jdbc/databases/postgresql.yaml
@@ -19,15 +19,15 @@ dataSources:
ds_0:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver
- jdbcUrl: jdbc:tc:postgresql:17.2-bookworm:///demo_ds_0
+ jdbcUrl: jdbc:tc:postgresql:17.5-bookworm:///demo_ds_0
ds_1:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver
- jdbcUrl: jdbc:tc:postgresql:17.2-bookworm:///demo_ds_1
+ jdbcUrl: jdbc:tc:postgresql:17.5-bookworm:///demo_ds_1
ds_2:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver
- jdbcUrl: jdbc:tc:postgresql:17.2-bookworm:///demo_ds_2
+ jdbcUrl: jdbc:tc:postgresql:17.5-bookworm:///demo_ds_2
rules:
- !SHARDING
diff --git
a/test/native/src/test/resources/test-native/yaml/jdbc/databases/sqlserver.yaml
b/test/native/src/test/resources/test-native/yaml/jdbc/databases/sqlserver.yaml
index bda776afbbd..ff16cdfaa9d 100644
---
a/test/native/src/test/resources/test-native/yaml/jdbc/databases/sqlserver.yaml
+++
b/test/native/src/test/resources/test-native/yaml/jdbc/databases/sqlserver.yaml
@@ -19,15 +19,15 @@ dataSources:
ds_0:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver
- jdbcUrl:
jdbc:tc:sqlserver:2022-CU16-ubuntu-22.04://test-native-databases-mssqlserver;databaseName=demo_ds_0
+ jdbcUrl:
jdbc:tc:sqlserver:2022-CU20-ubuntu-22.04://test-native-databases-mssqlserver;databaseName=demo_ds_0
ds_1:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver
- jdbcUrl:
jdbc:tc:sqlserver:2022-CU16-ubuntu-22.04://test-native-databases-mssqlserver;databaseName=demo_ds_1
+ jdbcUrl:
jdbc:tc:sqlserver:2022-CU20-ubuntu-22.04://test-native-databases-mssqlserver;databaseName=demo_ds_1
ds_2:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver
- jdbcUrl:
jdbc:tc:sqlserver:2022-CU16-ubuntu-22.04://test-native-databases-mssqlserver;databaseName=demo_ds_2
+ jdbcUrl:
jdbc:tc:sqlserver:2022-CU20-ubuntu-22.04://test-native-databases-mssqlserver;databaseName=demo_ds_2
rules:
- !SHARDING
diff --git
a/test/native/src/test/resources/test-native/yaml/jdbc/transactions/base/seata.yaml
b/test/native/src/test/resources/test-native/yaml/jdbc/transactions/base/seata.yaml
index 25e5a31fc8c..bb62b0128c8 100644
---
a/test/native/src/test/resources/test-native/yaml/jdbc/transactions/base/seata.yaml
+++
b/test/native/src/test/resources/test-native/yaml/jdbc/transactions/base/seata.yaml
@@ -19,15 +19,15 @@ dataSources:
ds_0:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver
- jdbcUrl:
jdbc:tc:postgresql:17.2-bookworm://test-native-transactions-base/demo_ds_0?TC_INITSCRIPT=test-native/sql/seata-script-client-at-postgresql.sql
+ jdbcUrl:
jdbc:tc:postgresql:17.5-bookworm://test-native-transactions-base/demo_ds_0?TC_INITSCRIPT=test-native/sql/seata-script-client-at-postgresql.sql
ds_1:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver
- jdbcUrl:
jdbc:tc:postgresql:17.2-bookworm://test-native-transactions-base/demo_ds_1?TC_INITSCRIPT=test-native/sql/seata-script-client-at-postgresql.sql
+ jdbcUrl:
jdbc:tc:postgresql:17.5-bookworm://test-native-transactions-base/demo_ds_1?TC_INITSCRIPT=test-native/sql/seata-script-client-at-postgresql.sql
ds_2:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver
- jdbcUrl:
jdbc:tc:postgresql:17.2-bookworm://test-native-transactions-base/demo_ds_2?TC_INITSCRIPT=test-native/sql/seata-script-client-at-postgresql.sql
+ jdbcUrl:
jdbc:tc:postgresql:17.5-bookworm://test-native-transactions-base/demo_ds_2?TC_INITSCRIPT=test-native/sql/seata-script-client-at-postgresql.sql
rules:
- !SHARDING