Skip to content

Commit

Permalink
Add GraalVM Reachability Metadata and corresponding nativeTest for Et…
Browse files Browse the repository at this point in the history
…cd integration
  • Loading branch information
linghengqian committed Jan 17, 2024
1 parent 9d21e57 commit 3aef7b5
Show file tree
Hide file tree
Showing 13 changed files with 295 additions and 42 deletions.
2 changes: 1 addition & 1 deletion infra/expr/type/espresso/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-api</artifactId>
<version>${graalvm.version}</version>
<version>${graal-sdk.version}</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"condition":{"typeReachable":"io.netty.channel.epoll.EpollChannelOption"},
"name":"io.netty.channel.epoll.EpollChannelOption",
"fields":[{"name":"TCP_USER_TIMEOUT"}]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.yaml.YamlEngine"},
"name":"org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptColumnItemRuleConfiguration",
"allDeclaredFields":true,
"queryAllPublicMethods":true,
"allPublicMethods":true,
"methods":[{"name":"<init>","parameterTypes":[] }, {"name":"setEncryptorName","parameterTypes":["java.lang.String"] }, {"name":"setName","parameterTypes":["java.lang.String"] }]
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.yaml.YamlEngine"},
Expand All @@ -112,8 +113,9 @@
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.yaml.YamlEngine"},
"name":"org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptColumnRuleConfiguration",
"allDeclaredFields":true,
"queryAllPublicMethods":true,
"allPublicMethods":true,
"methods":[{"name":"<init>","parameterTypes":[] }, {"name":"setAssistedQuery","parameterTypes":["org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptColumnItemRuleConfiguration"] }, {"name":"setCipher","parameterTypes":["org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptColumnItemRuleConfiguration"] }]
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.yaml.YamlEngine"},
Expand Down Expand Up @@ -266,7 +268,7 @@
"name":"org.apache.shardingsphere.infra.yaml.schema.pojo.YamlShardingSphereColumn",
"allDeclaredFields":true,
"allPublicMethods":true,
"methods":[{"name":"<init>","parameterTypes":[] }, {"name":"setCaseSensitive","parameterTypes":["boolean"] }, {"name":"setDataType","parameterTypes":["int"] }, {"name":"setGenerated","parameterTypes":["boolean"] }, {"name":"setName","parameterTypes":["java.lang.String"] }, {"name":"setPrimaryKey","parameterTypes":["boolean"] }, {"name":"setUnsigned","parameterTypes":["boolean"] }, {"name":"setVisible","parameterTypes":["boolean"] }]
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.metadata.persist.service.schema.NewTableMetaDataPersistService"},
Expand All @@ -279,7 +281,7 @@
"name":"org.apache.shardingsphere.infra.yaml.schema.pojo.YamlShardingSphereIndex",
"allDeclaredFields":true,
"allPublicMethods":true,
"methods":[{"name":"<init>","parameterTypes":[] }, {"name":"setName","parameterTypes":["java.lang.String"] }]
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.metadata.persist.service.schema.NewTableMetaDataPersistService"},
Expand All @@ -292,7 +294,7 @@
"name":"org.apache.shardingsphere.infra.yaml.schema.pojo.YamlShardingSphereTable",
"allDeclaredFields":true,
"allPublicMethods":true,
"methods":[{"name":"<init>","parameterTypes":[] }, {"name":"setColumns","parameterTypes":["java.util.Map"] }, {"name":"setIndexes","parameterTypes":["java.util.Map"] }, {"name":"setName","parameterTypes":["java.lang.String"] }]
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.metadata.persist.service.database.NewDatabaseMetaDataPersistService"},
Expand Down Expand Up @@ -400,8 +402,9 @@
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.yaml.YamlEngine"},
"name":"org.apache.shardingsphere.mask.yaml.config.rule.YamlMaskColumnRuleConfiguration",
"allDeclaredFields":true,
"queryAllPublicMethods":true,
"allPublicMethods":true,
"methods":[{"name":"<init>","parameterTypes":[] }, {"name":"setMaskAlgorithm","parameterTypes":["java.lang.String"] }]
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.yaml.YamlEngine"},
Expand Down Expand Up @@ -507,6 +510,11 @@
"name":"org.apache.shardingsphere.mode.process.ProcessSubscriber",
"queryAllDeclaredMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.NewClusterContextManagerBuilder"},
"name":"org.apache.shardingsphere.mode.repository.cluster.etcd.EtcdRepository",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.NewClusterContextManagerBuilder"},
"name":"org.apache.shardingsphere.mode.repository.cluster.zookeeper.ZookeeperRepository",
Expand All @@ -530,17 +538,13 @@
"name":"org.apache.shardingsphere.mode.subsciber.NewConfigurationChangedSubscriber",
"queryAllDeclaredMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.cluster.NewClusterContextManagerBuilder"},
"name":"org.apache.shardingsphere.mode.subsciber.RuleItemChangedSubscriber",
"queryAllDeclaredMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.yaml.YamlEngine"},
"name":"org.apache.shardingsphere.parser.yaml.config.YamlSQLParserCacheOptionRuleConfiguration",
"allDeclaredFields":true,
"queryAllPublicMethods":true,
"allPublicMethods":true,
"methods":[{"name":"<init>","parameterTypes":[] }, {"name":"setInitialCapacity","parameterTypes":["int"] }, {"name":"setMaximumSize","parameterTypes":["long"] }]
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.yaml.YamlEngine"},
Expand Down Expand Up @@ -805,8 +809,9 @@
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.yaml.YamlEngine"},
"name":"org.apache.shardingsphere.sharding.yaml.config.strategy.keygen.YamlKeyGenerateStrategyConfiguration",
"allDeclaredFields":true,
"queryAllPublicMethods":true,
"allPublicMethods":true,
"methods":[{"name":"<init>","parameterTypes":[] }, {"name":"setColumn","parameterTypes":["java.lang.String"] }, {"name":"setKeyGeneratorName","parameterTypes":["java.lang.String"] }]
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.yaml.YamlEngine"},
Expand Down Expand Up @@ -841,8 +846,9 @@
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.yaml.YamlEngine"},
"name":"org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlStandardShardingStrategyConfiguration",
"allDeclaredFields":true,
"queryAllPublicMethods":true,
"allPublicMethods":true,
"methods":[{"name":"<init>","parameterTypes":[] }, {"name":"setShardingAlgorithmName","parameterTypes":["java.lang.String"] }, {"name":"setShardingColumn","parameterTypes":["java.lang.String"] }]
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.util.yaml.YamlEngine"},
Expand Down Expand Up @@ -1049,16 +1055,6 @@
"name":"org.apache.shardingsphere.sql.parser.sqlserver.visitor.statement.type.SQLServerDMLStatementVisitor",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.connection.refresher.type.table.CreateTableStatementSchemaRefresher"},
"name":"org.apache.shardingsphere.sqlfederation.optimizer.planner.util.SQLFederationFunctionUtils",
"queryAllPublicMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.connection.refresher.type.table.DropTableStatementSchemaRefresher"},
"name":"org.apache.shardingsphere.sqlfederation.optimizer.planner.util.SQLFederationFunctionUtils",
"queryAllPublicMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.infra.rule.builder.global.GlobalRulesBuilder"},
"name":"org.apache.shardingsphere.sqlfederation.optimizer.planner.util.SQLFederationFunctionUtils"
Expand All @@ -1068,10 +1064,6 @@
"name":"org.apache.shardingsphere.sqlfederation.optimizer.planner.util.SQLFederationFunctionUtils",
"queryAllPublicMethods":true
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.context.ConfigurationContextManager"},
"name":"org.apache.shardingsphere.sqlfederation.optimizer.planner.util.SQLFederationFunctionUtils"
},
{
"condition":{"typeReachable":"org.apache.shardingsphere.mode.manager.context.ResourceMetaDataContextManager"},
"name":"org.apache.shardingsphere.sqlfederation.optimizer.planner.util.SQLFederationFunctionUtils"
Expand Down
5 changes: 4 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<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>
<consul.api.version>1.4.5</consul.api.version>

<grpc.version>1.58.0</grpc.version>
Expand Down Expand Up @@ -145,7 +146,7 @@
<testcontainers.version>1.19.3</testcontainers.version>
<commons-csv.version>1.9.0</commons-csv.version>

<graalvm.version>21.2.0</graalvm.version>
<graal-sdk.version>21.2.0</graal-sdk.version>

<!-- 3rd party library plugin versions -->
<protobuf-maven-plugin.version>0.6.1</protobuf-maven-plugin.version>
Expand Down Expand Up @@ -1079,8 +1080,10 @@
<extensions>true</extensions>
<configuration>
<buildArgs>
<buildArg>-J-Xmx7g</buildArg>
<buildArg>-H:+AddAllCharsets</buildArg>
</buildArgs>
<quickBuild>true</quickBuild>
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
<metadataRepository>
<enabled>true</enabled>
Expand Down
11 changes: 8 additions & 3 deletions test/native/native-image-filter/extra-filter.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
{"includeClasses": "java.util.Properties"},
{"excludeClasses": "javax.security.auth.x500.**"},
{"excludeClasses": "javax.smartcardio.**"},
{"excludeClasses": "jdk.internal.misc.**"},
{"excludeClasses": "sun.misc.**"},
{"excludeClasses": "sun.nio.ch.**"},
{"excludeClasses": "sun.security.**"},

{"excludeClasses": "com.fasterxml.jackson.databind.**"},
Expand All @@ -21,17 +23,20 @@
{"excludeClasses": "com.microsoft.sqlserver.jdbc.**"},
{"excludeClasses": "com.mysql.cj.**"},
{"excludeClasses": "com.zaxxer.hikari.**"},
{"excludeClasses": "javax.xml.**"},
{"excludeClasses": "io.grpc.**"},
{"excludeClasses": "io.netty.**"},
{"excludeClasses": "io.vertx.core.**"},
{"excludeClasses": "groovy.**"},
{"excludeClasses": "libcore.io.**"},
{"excludeClasses": "org.apache.calcite.**"},
{"excludeClasses": "org.apache.zookeeper.**"},
{"excludeClasses": "org.codehaus.groovy.**"},
{"excludeClasses": "org.h2.**"},
{"excludeClasses": "org.locationtech.jts.geom.**"},
{"excludeClasses": "org.opengauss.**"},
{"excludeClasses": "org.postgresql.**"},
{"excludeClasses": "org.slf4j.event.**"},
{"excludeClasses": "org.testcontainers.**"}
{"excludeClasses": "org.robolectric.**"},
{"excludeClasses": "org.slf4j.event.**"}
],
"regexRules": [
]
Expand Down
12 changes: 12 additions & 0 deletions test/native/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-cluster-mode-repository-etcd</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-grpc</artifactId>
<version>${vertx.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.awaitility</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@
*/
class MySQLTest {

private static final Integer MYSQL_PORT_ON_HOST = 60107;

private static final String USERNAME = "root";

private static final String PASSWORD = "123456";

private static final String DATABASE = "test";

private static final String JDBC_URL = "jdbc:mysql://localhost:65107/" + DATABASE;
private static final String JDBC_URL = "jdbc:mysql://localhost:" + MYSQL_PORT_ON_HOST + "/" + DATABASE;

private TestShardingService testShardingService;

Expand All @@ -63,7 +65,8 @@ void assertShardingInLocalTransactions() throws SQLException, IOException {
GenericContainer<?> mySQLContainer = new GenericContainer<>(DockerImageName.parse("mysql:8.2.0-oracle"))
.withEnv("MYSQL_DATABASE", DATABASE)
.withEnv("MYSQL_ROOT_PASSWORD", PASSWORD)
.withCreateContainerCmdModifier(cmd -> cmd.withHostConfig(new HostConfig().withPortBindings(new PortBinding(Ports.Binding.bindPort(65107), new ExposedPort(3306)))))) {
.withCreateContainerCmdModifier(
cmd -> cmd.withHostConfig(new HostConfig().withPortBindings(new PortBinding(Ports.Binding.bindPort(MYSQL_PORT_ON_HOST), new ExposedPort(3306)))))) {
mySQLContainer.start();
beforeAll();
DataSource dataSource = YamlShardingSphereDataSourceFactory.createDataSource(FileTestUtils.readFromFileURLString("test-native/yaml/databases/mysql.yaml"));
Expand Down
Loading

0 comments on commit 3aef7b5

Please sign in to comment.