Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move native test from infra module to test module #29107

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}/test/natived/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

This file was deleted.

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>
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@
<version>${maven-surefire-plugin.version}</version>
<configuration>
<includes>
<include>org.apache.shardingsphere.infra.nativetest.**</include>
<include>org.apache.shardingsphere.test.natived.**</include>
</includes>
</configuration>
</plugin>
Expand All @@ -1041,8 +1041,8 @@
<defaultMode>Conditional</defaultMode>
<modes>
<conditional>
<userCodeFilterPath>${user.dir}/infra/nativetest/native-image-filter/user-code-filter.json</userCodeFilterPath>
<extraFilterPath>${user.dir}/infra/nativetest/native-image-filter/extra-filter.json</extraFilterPath>
<userCodeFilterPath>${user.dir}/test/natived/native-image-filter/user-code-filter.json</userCodeFilterPath>
<extraFilterPath>${user.dir}/test/natived/native-image-filter/extra-filter.json</extraFilterPath>
<parallel>true</parallel>
</conditional>
</modes>
Expand Down Expand Up @@ -1088,7 +1088,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>org.apache.shardingsphere.infra.nativetest.**</include>
<include>org.apache.shardingsphere.test.natived.**</include>
</includes>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{"excludeClasses": "org.locationtech.jts.geom.**"},
{"excludeClasses": "org.slf4j.event.**"},

{"excludeClasses": "org.apache.shardingsphere.infra.nativetest.**"}
{"excludeClasses": "org.apache.shardingsphere.test.natived.**"}
],
"regexRules": [
]
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.shardingsphere.infra.nativetest;
package org.apache.shardingsphere.test.natived;

import java.io.BufferedReader;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
* limitations under the License.
*/

package org.apache.shardingsphere.infra.nativetest.jdbc.features;
package org.apache.shardingsphere.test.natived.jdbc.features;

import org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
import org.apache.shardingsphere.infra.nativetest.FileTestUtils;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.entity.Address;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.entity.Order;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.entity.OrderItem;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.repository.AddressRepository;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.repository.OrderItemRepository;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.repository.OrderRepository;
import org.apache.shardingsphere.test.natived.FileTestUtils;
import org.apache.shardingsphere.test.natived.jdbc.features.entity.Address;
import org.apache.shardingsphere.test.natived.jdbc.features.entity.Order;
import org.apache.shardingsphere.test.natived.jdbc.features.entity.OrderItem;
import org.apache.shardingsphere.test.natived.jdbc.features.repository.AddressRepository;
import org.apache.shardingsphere.test.natived.jdbc.features.repository.OrderItemRepository;
import org.apache.shardingsphere.test.natived.jdbc.features.repository.OrderRepository;
import org.junit.jupiter.api.Test;

import javax.sql.DataSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
* limitations under the License.
*/

package org.apache.shardingsphere.infra.nativetest.jdbc.features;
package org.apache.shardingsphere.test.natived.jdbc.features;

import org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
import org.apache.shardingsphere.infra.nativetest.FileTestUtils;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.entity.Address;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.entity.Order;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.entity.OrderItem;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.repository.AddressRepository;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.repository.OrderItemRepository;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.repository.OrderRepository;
import org.apache.shardingsphere.test.natived.FileTestUtils;
import org.apache.shardingsphere.test.natived.jdbc.features.entity.Address;
import org.apache.shardingsphere.test.natived.jdbc.features.entity.Order;
import org.apache.shardingsphere.test.natived.jdbc.features.entity.OrderItem;
import org.apache.shardingsphere.test.natived.jdbc.features.repository.AddressRepository;
import org.apache.shardingsphere.test.natived.jdbc.features.repository.OrderItemRepository;
import org.apache.shardingsphere.test.natived.jdbc.features.repository.OrderRepository;
import org.junit.jupiter.api.Test;

import javax.sql.DataSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
* limitations under the License.
*/

package org.apache.shardingsphere.infra.nativetest.jdbc.features;
package org.apache.shardingsphere.test.natived.jdbc.features;

import org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
import org.apache.shardingsphere.infra.nativetest.FileTestUtils;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.entity.Address;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.entity.Order;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.entity.OrderItem;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.repository.AddressRepository;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.repository.OrderItemRepository;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.repository.OrderRepository;
import org.apache.shardingsphere.test.natived.FileTestUtils;
import org.apache.shardingsphere.test.natived.jdbc.features.entity.Address;
import org.apache.shardingsphere.test.natived.jdbc.features.entity.Order;
import org.apache.shardingsphere.test.natived.jdbc.features.entity.OrderItem;
import org.apache.shardingsphere.test.natived.jdbc.features.repository.AddressRepository;
import org.apache.shardingsphere.test.natived.jdbc.features.repository.OrderItemRepository;
import org.apache.shardingsphere.test.natived.jdbc.features.repository.OrderRepository;
import org.h2.jdbc.JdbcSQLSyntaxErrorException;
import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
* limitations under the License.
*/

package org.apache.shardingsphere.infra.nativetest.jdbc.features;
package org.apache.shardingsphere.test.natived.jdbc.features;

import org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
import org.apache.shardingsphere.infra.nativetest.FileTestUtils;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.entity.Address;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.entity.Order;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.entity.OrderItem;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.repository.AddressRepository;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.repository.OrderItemRepository;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.repository.OrderRepository;
import org.apache.shardingsphere.test.natived.FileTestUtils;
import org.apache.shardingsphere.test.natived.jdbc.features.entity.Address;
import org.apache.shardingsphere.test.natived.jdbc.features.entity.Order;
import org.apache.shardingsphere.test.natived.jdbc.features.entity.OrderItem;
import org.apache.shardingsphere.test.natived.jdbc.features.repository.AddressRepository;
import org.apache.shardingsphere.test.natived.jdbc.features.repository.OrderItemRepository;
import org.apache.shardingsphere.test.natived.jdbc.features.repository.OrderRepository;
import org.junit.jupiter.api.Test;

import javax.sql.DataSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
* limitations under the License.
*/

package org.apache.shardingsphere.infra.nativetest.jdbc.features;
package org.apache.shardingsphere.test.natived.jdbc.features;

import org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory;
import org.apache.shardingsphere.infra.nativetest.FileTestUtils;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.entity.Address;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.entity.Order;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.entity.OrderItem;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.repository.AddressRepository;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.repository.OrderItemRepository;
import org.apache.shardingsphere.infra.nativetest.jdbc.features.repository.OrderRepository;
import org.apache.shardingsphere.test.natived.FileTestUtils;
import org.apache.shardingsphere.test.natived.jdbc.features.entity.Address;
import org.apache.shardingsphere.test.natived.jdbc.features.entity.Order;
import org.apache.shardingsphere.test.natived.jdbc.features.entity.OrderItem;
import org.apache.shardingsphere.test.natived.jdbc.features.repository.AddressRepository;
import org.apache.shardingsphere.test.natived.jdbc.features.repository.OrderItemRepository;
import org.apache.shardingsphere.test.natived.jdbc.features.repository.OrderRepository;
import org.junit.jupiter.api.Test;

import javax.sql.DataSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.shardingsphere.infra.nativetest.jdbc.features.algorithm;
package org.apache.shardingsphere.test.natived.jdbc.features.algorithm;

import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.shardingsphere.infra.nativetest.jdbc.features.algorithm;
package org.apache.shardingsphere.test.natived.jdbc.features.algorithm;

import lombok.Getter;
import org.apache.shardingsphere.encrypt.api.context.EncryptContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.shardingsphere.infra.nativetest.jdbc.features.entity;
package org.apache.shardingsphere.test.natived.jdbc.features.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.shardingsphere.infra.nativetest.jdbc.features.entity;
package org.apache.shardingsphere.test.natived.jdbc.features.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.shardingsphere.infra.nativetest.jdbc.features.entity;
package org.apache.shardingsphere.test.natived.jdbc.features.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* limitations under the License.
*/

package org.apache.shardingsphere.infra.nativetest.jdbc.features.repository;
package org.apache.shardingsphere.test.natived.jdbc.features.repository;

import org.apache.shardingsphere.infra.nativetest.jdbc.features.entity.Address;
import org.apache.shardingsphere.test.natived.jdbc.features.entity.Address;

import javax.sql.DataSource;
import java.sql.Connection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* limitations under the License.
*/

package org.apache.shardingsphere.infra.nativetest.jdbc.features.repository;
package org.apache.shardingsphere.test.natived.jdbc.features.repository;

import org.apache.shardingsphere.infra.nativetest.jdbc.features.entity.OrderItem;
import org.apache.shardingsphere.test.natived.jdbc.features.entity.OrderItem;

import javax.sql.DataSource;
import java.sql.Connection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* limitations under the License.
*/

package org.apache.shardingsphere.infra.nativetest.jdbc.features.repository;
package org.apache.shardingsphere.test.natived.jdbc.features.repository;

import org.apache.shardingsphere.infra.nativetest.jdbc.features.entity.Order;
import org.apache.shardingsphere.test.natived.jdbc.features.entity.Order;

import javax.sql.DataSource;
import java.sql.Connection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[
{
"condition":{"typeReachable":"org.apache.shardingsphere.sharding.algorithm.sharding.classbased.ClassBasedShardingAlgorithmFactory"},
"name":"org.apache.shardingsphere.infra.nativetest.jdbc.features.algorithm.ClassBasedInlineShardingAlgorithmFixture",
"name":"org.apache.shardingsphere.test.natived.jdbc.features.algorithm.ClassBasedInlineShardingAlgorithmFixture",
"methods":[{"name":"<init>","parameterTypes":[] }]
}
]

Loading
Loading