Skip to content

Commit

Permalink
Move native test from infra module to test module
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Nov 21, 2023
1 parent e99e714 commit 170ee43
Show file tree
Hide file tree
Showing 31 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ ShardingSphere 对在 GraalVM Native Image 下的可用性的验证,是通过
在 GraalVM Native Image 下的单元测试覆盖率。请贡献者不要使用 `io.kotest:kotest-runner-junit5-jvm:5.5.4` 等在 `test listener` mode 下
failed to discover tests 的测试库。

ShardingSphere 定义了 `shardingsphere-infra-nativetest` 的 Maven Module 用于为 native Test 提供小型的单元测试子集,
ShardingSphere 定义了 `shardingsphere-test-native` 的 Maven Module 用于为 native Test 提供小型的单元测试子集,
此单元测试子集避免了使用 Mockito 等 native Test 下无法使用的第三方库。

ShardingSphere 定义了 `nativeTestInShardingSphere` 的 Maven Profile 用于为 `shardingsphere-infra-nativetest` 模块执行 nativeTest 。
ShardingSphere 定义了 `nativeTestInShardingSphere` 的 Maven Profile 用于为 `shardingsphere-test-native` 模块执行 nativeTest 。

假设贡献者处于新的 Ubuntu 22.04.3 LTS 实例下,其可通过如下 bash 命令通过 SDKMAN! 管理 JDK 和工具链,
并为 `shardingsphere-infra-nativetest` 子模块执行 nativeTest。
并为 `shardingsphere-test-native` 子模块执行 nativeTest。

```bash
sudo apt install unzip zip curl sed -y
Expand All @@ -247,11 +247,11 @@ ShardingSphere 定义了 `generateMetadata` 的 Maven Profile 用于在 GraalVM
已有的 GraalVM Reachability Metadata 文件。可通过如下 bash 命令简单处理此流程。贡献者仍可能需要手动调整具体的 JSON 条目,并在适当的时候
调整 Maven Profile 和 GraalVM Tracing Agent 的 Filter 链。

以下命令仅为 `shardingsphere-infra-nativetest` 生成 Conditional 形态的 GraalVM Reachability Metadata 的一个举例。生成的 GraalVM
以下命令仅为 `shardingsphere-test-native` 生成 Conditional 形态的 GraalVM Reachability Metadata 的一个举例。生成的 GraalVM
Reachability Metadata 位于 `shardingsphere-infra-reachability-metadata` 子模块下。

对于测试类和测试文件独立使用的 GraalVM Reachability Metadata,贡献者应该放置到
`${user.dir}/infra/nativetest/src/test/resources/META-INF/native-image/shardingsphere-infra-nativetest-test-metadata/`
`${user.dir}/infra/nativetest/src/test/resources/META-INF/native-image/shardingsphere-test-native-test-metadata/`
文件夹下。`${}` 内为相关子模块对应的 POM 4.0 的常规系统变量,自行替换。

```bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ and then build it as GraalVM Native Image for nativeTest to test Unit Test Cover
Please do not use `io.kotest:kotest-runner-junit5-jvm:5.5.4` and some third-party test libraries, they are in `test listener`
mode failed to discover tests.

ShardingSphere defines the Maven Module of `shardingsphere-infra-nativetest` to provide a small subset of unit tests for native Test.
ShardingSphere defines the Maven Module of `shardingsphere-test-native` to provide a small subset of unit tests for native Test.
This subset of unit tests avoids the use of third-party libraries such as Mockito that are not available under native Test.

ShardingSphere defines the Maven Profile of `nativeTestInShardingSphere` for executing nativeTest for the `shardingsphere-infra-nativetest` module.
ShardingSphere defines the Maven Profile of `nativeTestInShardingSphere` for executing nativeTest for the `shardingsphere-test-native` module.

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-infra-nativetest` submodule.
`SDKMAN!` through the following bash command, and execute nativeTest for the `shardingsphere-test-native` submodule.

```bash
sudo apt install unzip zip curl sed -y
Expand Down Expand Up @@ -261,11 +261,11 @@ Metadata files in a specific directory.
This process can be easily handled with the following bash command. Contributors may still need to manually adjust specific
JSON entries and GraalVM Tracing Agent Filter chain of Maven Profile.

The following command is only an example of using `shardingsphere-infra-nativetest` to generate GraalVM Reachability Metadata
The following command is only an example of using `shardingsphere-test-native` to generate GraalVM Reachability Metadata
in Conditional form. Generated GraalVM Reachability Metadata is located under the `shardingsphere-infra-reachability-metadata` submodule.

For GraalVM Reachability Metadata used independently by test classes and test files, contributors should place
`${user.dir}/infra/nativetest/src/test/resources/META-INF/native-image/shardingsphere-infra-nativetest-test-metadata/`
`${user.dir}/infra/nativetest/src/test/resources/META-INF/native-image/shardingsphere-test-native-test-metadata/`
folder. `${}` contains the regular system variables of POM 4.0 corresponding to the relevant submodules, which can be replaced by yourself.

```bash
Expand Down
1 change: 0 additions & 1 deletion infra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
<module>expr</module>
<module>util</module>
<module>reachability-metadata</module>
<module>nativetest</module>
<module>algorithm</module>
</modules>
</project>
1 change: 0 additions & 1 deletion infra/reachability-metadata/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@
</parent>
<artifactId>shardingsphere-infra-reachability-metadata</artifactId>
<name>${project.artifactId}</name>

</project>
4 changes: 2 additions & 2 deletions infra/nativetest/pom.xml → test/native/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-infra</artifactId>
<artifactId>shardingsphere-test</artifactId>
<version>5.4.2-SNAPSHOT</version>
</parent>
<artifactId>shardingsphere-infra-nativetest</artifactId>
<artifactId>shardingsphere-test-native</artifactId>
<name>${project.artifactId}</name>

<properties>
Expand Down
1 change: 1 addition & 0 deletions test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

<module>it</module>
<module>e2e</module>
<module>native</module>
</modules>

<properties>
Expand Down

0 comments on commit 170ee43

Please sign in to comment.