Skip to content

Commit

Permalink
Provide relevant nativeTest and corresponding GraalVM Reachability Me…
Browse files Browse the repository at this point in the history
…tadata for MySQL and Postgres Module (#29357)

* Provide relevant nativeTest and corresponding GraalVM Reachability Metadata for MySQL and Postgres

* Use testcontainers-java to test

* Simplify the writing of `resource-config.json`
  • Loading branch information
linghengqian authored Dec 12, 2023
1 parent 565c068 commit 460349e
Show file tree
Hide file tree
Showing 41 changed files with 1,043 additions and 390 deletions.
15 changes: 2 additions & 13 deletions distribution/proxy-native/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,11 @@
<profile>
<id>release.native</id>
<properties>
<jacoco.skip>true</jacoco.skip>
<maven.javadoc.skip>true</maven.javadoc.skip>
<checkstyle.skip>true</checkstyle.skip>
<rat.skip>true</rat.skip>
<spotless.apply.skip>true</spotless.apply.skip>
<java.version>17</java.version>
</properties>
<build>
<finalName>apache-shardingsphere-${project.version}</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
Expand All @@ -101,6 +89,7 @@
</buildArgs>
<metadataRepository>
<enabled>true</enabled>
<version>0.3.5</version>
</metadataRepository>
</configuration>
<executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ ShardingSphere 定义了 `nativeTestInShardingSphere` 的 Maven Profile 用于
假设贡献者处于新的 Ubuntu 22.04.3 LTS 实例下,其可通过如下 bash 命令通过 SDKMAN! 管理 JDK 和工具链,
并为 `shardingsphere-test-native` 子模块执行 nativeTest。

你必须安装 Docker Engine 或 PodMan 等 container tools 以执行 `testcontainers-java` 相关的单元测试。

```bash
sudo apt install unzip zip curl sed -y
curl -s "https://get.sdkman.io" | bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ ShardingSphere defines the Maven Profile of `nativeTestInShardingSphere` for exe
Assuming that the contributor is under a new Ubuntu 22.04.3 LTS instance, Contributors can manage the JDK and tool chain through
`SDKMAN!` through the following bash command, and execute nativeTest for the `shardingsphere-test-native` submodule.

You must install container tools such as Docker Engine or PodMan to execute `testcontainers-java` related unit tests.

```bash
sudo apt install unzip zip curl sed -y
curl -s "https://get.sdkman.io" | bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public final class PostgreSQLDatabaseType implements DatabaseType {

@Override
public Collection<String> getJdbcUrlPrefixes() {
return Arrays.asList(String.format("jdbc:%s:", getType().toLowerCase()), "jdbc:tc:postgres:");
return Arrays.asList(String.format("jdbc:%s:", getType().toLowerCase()), "jdbc:tc:postgresql:");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ class PostgreSQLDatabaseTypeTest {

@Test
void assertGetJdbcUrlPrefixes() {
assertThat(TypedSPILoader.getService(DatabaseType.class, "PostgreSQL").getJdbcUrlPrefixes(), is(Arrays.asList("jdbc:postgresql:", "jdbc:tc:postgres:")));
assertThat(TypedSPILoader.getService(DatabaseType.class, "PostgreSQL").getJdbcUrlPrefixes(), is(Arrays.asList("jdbc:postgresql:", "jdbc:tc:postgresql:")));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[
{
"condition":{"typeReachable":"com.mysql.cj.jdbc.ConnectionImpl"},
"name":"com.mysql.cj.PerConnectionLRUFactory",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"com.mysql.cj.util.Util"},
"name":"com.mysql.cj.conf.url.SingleConnectionUrl",
"methods":[{"name":"<init>","parameterTypes":["com.mysql.cj.conf.ConnectionUrlParser","java.util.Properties"] }]
},
{
"condition":{"typeReachable":"com.mysql.cj.exceptions.ExceptionFactory"},
"name":"com.mysql.cj.exceptions.CJCommunicationsException",
"methods":[{"name":"<init>","parameterTypes":["java.lang.String"] }]
},
{
"condition":{"typeReachable":"com.mysql.cj.jdbc.NonRegisteringDriver"},
"name":"com.mysql.cj.jdbc.AbandonedConnectionCleanupThread"
},
{
"condition":{"typeReachable":"com.mysql.cj.log.LogFactory"},
"name":"com.mysql.cj.log.StandardLogger",
"methods":[{"name":"<init>","parameterTypes":["java.lang.String"] }]
},
{
"condition":{"typeReachable":"com.mysql.cj.protocol.AbstractSocketConnection"},
"name":"com.mysql.cj.protocol.StandardSocketFactory",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"com.mysql.cj.NativeSession"},
"name":"com.mysql.cj.util.PerVmServerConfigCacheFactory",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"com.mysql.cj.protocol.StandardSocketFactory"},
"name":"java.lang.Thread",
"fields":[{"name":"threadLocalRandomProbe"}]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,5 @@
"name":"com.zaxxer.hikari.HikariDataSource",
"fields":[{"name":"dataSourceProperties"}, {"name":"jdbcUrl"}],
"methods":[{"name":"<init>","parameterTypes":[] }, {"name":"getAllowPoolSuspension","parameterTypes":[] }, {"name":"getAutoCommit","parameterTypes":[] }, {"name":"getIsolateInternalQueries","parameterTypes":[] }, {"name":"getReadOnly","parameterTypes":[] }, {"name":"getRegisterMbeans","parameterTypes":[] }, {"name":"isClosed","parameterTypes":[] }, {"name":"isRunning","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"com.zaxxer.hikari.util.PropertyElf"},
"name":"com.zaxxer.hikari.HikariDataSource",
"methods":[{"name":"getAllowPoolSuspension","parameterTypes":[] }, {"name":"getAutoCommit","parameterTypes":[] }, {"name":"getIsolateInternalQueries","parameterTypes":[] }, {"name":"getReadOnly","parameterTypes":[] }, {"name":"getRegisterMbeans","parameterTypes":[] }]
}
]
Loading

0 comments on commit 460349e

Please sign in to comment.