未验证 提交 49594c4d 编写于 作者: K kezhenxu94 提交者: GitHub

Bump up Java version to 11 and use junit tag to group IT and slow IT (#10390)

- `./mvnw test ...` by its nature only runs unit tests, whose name is pattern of `*Test`, and it does never runs integration tests, whose name is patter of `IT*` or `*IT`, so in this PR we use `./mvnw clean test ...` to only run unit tests.
- `./mvnw integration-test ...` will run integration tests and unit tests, so we have `skipUTs` to control whether to skip the UT when running ITs, we already had this before.
  - As for ITs, we have two groups, one is normal tests without any `@Tag`s, the other one is slow integration tests, which is annotated with `@Tag("slow")`, so we divided the integration tests into two workflow jobs:
  - `./mvnw -DskipUTs=true clean integration-test -DexcludedGroups=slow ...` run the ITs but don't run the slow ITs and UTs, `-DexcludedGroups=slow` excludes tests annotated with `@Tag("slow")`
  - `./mvnw -DskipUTs=true clean integration-test -Dcheckstyle.skip -Dtest=${{ matrix.test.class }}` run the slow ITs (because `excludedGroups` is not set) one case at a time, by setting `-Dtest={{ class }}`, not run UTs,
上级 dbf4e864
......@@ -70,7 +70,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "8"
java-version: "11"
cache: "maven"
- name: Setup Go
uses: actions/setup-go@v3
......@@ -157,7 +157,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "8"
java-version: "11"
cache: "maven"
- name: Build distribution tar
run: |
......@@ -181,7 +181,7 @@ jobs:
timeout-minutes: 30
strategy:
matrix:
java-version: [8, 11, 17]
java-version: [11, 17]
steps:
- uses: actions/checkout@v3
with:
......@@ -220,10 +220,10 @@ jobs:
strategy:
matrix:
os: [ubuntu, macos, windows]
java-version: [8]
java-version: [11]
include:
- os: ubuntu
java-version: 11
java-version: 17
steps:
- uses: actions/checkout@v3
with:
......@@ -237,9 +237,9 @@ jobs:
- uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
distribution: adopt
distribution: temurin
- name: Unit test
run: ./mvnw clean verify -q -B -D"checkstyle.skip" || ./mvnw clean verify -q -B -D"checkstyle.skip"
run: ./mvnw clean test -q -B -D"checkstyle.skip" || ./mvnw clean test -q -B -D"checkstyle.skip"
integration-test:
if: |
......@@ -251,7 +251,7 @@ jobs:
timeout-minutes: 60
strategy:
matrix:
java-version: [8, 11]
java-version: [11, 17]
steps:
- uses: actions/checkout@v3
with:
......@@ -265,18 +265,19 @@ jobs:
- uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
distribution: adopt
distribution: temurin
- name: Integration test
run: |
./mvnw clean verify -q -B -Dcheckstyle.skip -DskipUTs -DskipITs=false || \
./mvnw clean verify -q -B -Dcheckstyle.skip -DskipUTs -DskipITs=false
# Exclude slow integration tests and run those tests separately below.
./mvnw -B clean integration-test -Dcheckstyle.skip -DskipUTs=true -DexcludedGroups=slow || \
./mvnw -B clean integration-test -Dcheckstyle.skip -DskipUTs=true -DexcludedGroups=slow
# Time consuming integration tests
tc-integration-test:
# Slow tests
slow-integration-test:
if: |
( always() && ! cancelled() ) &&
((github.event_name == 'schedule' && github.repository == 'apache/skywalking') || needs.changes.outputs.oap == 'true')
name: Time Consuming Integration Tests
name: Slow Integration Tests
needs: [sanity-check, changes]
runs-on: ubuntu-latest
timeout-minutes: 60
......@@ -284,9 +285,9 @@ jobs:
matrix:
test:
- name: ShardingSphere
class: org.apache.skywalking.oap.server.storage.plugin.jdbc.shardingsphere.TCITShardingSphere
class: org.apache.skywalking.oap.server.storage.plugin.jdbc.shardingsphere.ShardingSphereIT
- name: ElasticSearch / OpenSearch
class: org.apache.skywalking.library.elasticsearch.TCITElasticSearch
class: org.apache.skywalking.library.elasticsearch.ElasticSearchIT
steps:
- uses: actions/checkout@v3
with:
......@@ -299,12 +300,12 @@ jobs:
restore-keys: ${{ runner.os }}-maven-
- uses: actions/setup-java@v3
with:
java-version: 8
distribution: adopt
java-version: 11
distribution: temurin
- name: ${{ matrix.test.name }}
run: |
./mvnw clean test -Dtest=${{ matrix.test.class }} -DfailIfNoTests=false || \
./mvnw clean test -Dtest=${{ matrix.test.class }} -DfailIfNoTests=false
./mvnw -B clean integration-test -Dcheckstyle.skip -DskipUTs=true -Dit.test=${{ matrix.test.class }} -DfailIfNoTests=false || \
./mvnw -B clean integration-test -Dcheckstyle.skip -DskipUTs=true -Dit.test=${{ matrix.test.class }} -DfailIfNoTests=false
e2e-test:
if: |
......@@ -669,7 +670,7 @@ jobs:
- uses: actions/download-artifact@v3
name: Download docker images
with:
name: docker-images-8
name: docker-images-11
path: docker-images
- name: Load docker images
run: find docker-images -name "*.tar" -exec docker load -i {} \;
......@@ -731,7 +732,7 @@ jobs:
- uses: actions/download-artifact@v3
name: Download docker images
with:
name: docker-images-8
name: docker-images-11
path: docker-images
- name: Load docker images
run: find docker-images -name "*.tar" -exec docker load -i {} \;
......@@ -755,7 +756,7 @@ jobs:
strategy:
fail-fast: false
matrix:
java-version: [8, 11, 17]
java-version: [11, 17]
steps:
- uses: actions/checkout@v3
with:
......@@ -770,7 +771,7 @@ jobs:
- uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
distribution: adopt
distribution: temurin
- name: Prepare test services
shell: bash
run: ./mvnw -B -f test/e2e-v2/java-test-service/pom.xml clean package
......@@ -788,7 +789,7 @@ jobs:
- dependency-license
- unit-test
- integration-test
- tc-integration-test
- slow-integration-test
- e2e-test
- e2e-test-istio
- e2e-test-java-versions
......@@ -807,7 +808,7 @@ jobs:
depLicenseResults=${{ needs.dependency-license.result }}
unitResults=${{ needs.unit-test.result }};
integrationResults=${{ needs.integration-test.result }};
timeConsumingITResults=${{ needs.tc-integration-test.result }};
timeConsumingITResults=${{ needs.slow-integration-test.result }};
e2eResults=${{ needs.e2e-test.result }};
e2eIstioResults=${{ needs.e2e-test-istio.result }};
e2eJavaVersionResults=${{ needs.e2e-test-java-versions.result }};
......
......@@ -6,6 +6,7 @@
* Bump up Apache parent pom version to 29.
* Bump up Armeria version to 1.21.0.
* Clean up maven `pom.xml`s.
* Bump up Java version to 11.
#### OAP Server
......
......@@ -16,7 +16,7 @@ If you need to execute build behind the proxy, edit the *.mvn/jvm.config* and se
```
### Building from GitHub
1. Prepare git, JDK8+, and Maven 3.6+.
1. Prepare git, JDK11+, and Maven 3.6+.
1. Clone the project.
If you want to build a release from source codes, set a `tag name` by using `git clone -b [tag_name] ...` while cloning.
......@@ -41,7 +41,7 @@ If you need to execute build behind the proxy, edit the *.mvn/jvm.config* and se
For each official Apache release, there is a complete and independent source code tar, which includes all source codes. You could download it from [SkyWalking Apache download page](http://skywalking.apache.org/downloads/). There is no requirement related to git when compiling this. Just follow these steps.
1. Prepare JDK8+ and Maven 3.6+.
1. Prepare JDK11+ and Maven 3.6+.
1. Run `./mvnw clean package -Dmaven.test.skip`.
1. All packages are in `/dist`.(.tar.gz for Linux and .zip for Windows).
......
......@@ -32,16 +32,16 @@ as well as write some unit test (UT) codes to verify that the new codes would wo
If the new codes involve other components or libraries, you should also write integration tests (IT).
SkyWalking leverages the plugin `maven-surefire-plugin` to run the UTs and uses `maven-failsafe-plugin`
to run the ITs. `maven-surefire-plugin` excludes ITs (whose class name starts with `IT`)
and leaves them for `maven-failsafe-plugin` to run, which is bound to the `verify` goal.
to run the ITs. `maven-surefire-plugin` excludes ITs (whose class name starts or ends with `*IT`, `IT*`)
and leaves them for `maven-failsafe-plugin` to run, which is bound to the `integration-test` goal.
Therefore, to run the UTs, try `./mvnw clean test`, which only runs the UTs but not the ITs.
If you would like to run the ITs, please set the property `skipITs` to false
as well as the profiles of the modules whose ITs you want to run.
E.g. if you would like to run the ITs in `oap-server`, try `./mvnw -Pbackend clean verify -DskipITs=false`,
and if you would like to run all the ITs, simply run `./mvnw clean verify -DskipITs=false`.
If you would like to run the ITs, please run `./mvnw integration-test` as well as the profiles of the modules whose ITs you want to run.
If you don't want to run UTs, please add `-DskipUTs=true`.
E.g. if you would like to only run the ITs in `oap-server`, try `./mvnw -Pbackend clean verify -DskipUTs=true`,
and if you would like to run all the ITs, simply run `./mvnw clean integration-test -DskipUTs=true`.
Please be advised that if you're writing integration tests, name it with the pattern `IT*` so they would only run when property `skipITs` is set to false.
Please be advised that if you're writing integration tests, name it with the pattern `IT*` or `*IT` so they would only run in goal `integration-test`.
### Java Microbenchmark Harness (JMH)
JMH is a Java harness for building, running, and analysing nano/micro/milli/macro benchmarks written in Java and other languages targeting the JVM.
......
......@@ -14,7 +14,7 @@ SkyWalking's backend distribution package consists of the following parts:
## Requirements and default settings
Requirement: **JDK8 to JDK17 are tested**. Other versions are not tested and may or may not work.
Requirement: **JDK11 to JDK17 are tested**. Other versions are not tested and may or may not work.
Before you begin, you should understand that the main purpose of the following quickstart is to help you obtain a basic configuration for previews/demos. Performance and long-term running are **NOT** among the purposes of the quickstart.
......
......@@ -34,10 +34,11 @@ import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.apache.skywalking.oap.server.library.util.StringUtil;
import org.apache.skywalking.oap.server.core.alarm.AlarmCallback;
import org.apache.skywalking.oap.server.core.alarm.AlarmMessage;
import org.apache.skywalking.oap.server.core.alarm.provider.AlarmRulesWatcher;
import org.apache.skywalking.oap.server.library.util.StringUtil;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.IOException;
......
......@@ -58,7 +58,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
@Testcontainers
@ExtendWith(MockitoExtension.class)
public class ITClusterModuleConsulProviderFunctionalTest {
public class ClusterModuleConsulProviderFunctionalIT {
private String consulAddress;
......@@ -333,7 +333,7 @@ public class ITClusterModuleConsulProviderFunctionalTest {
assertTrue(otherExist);
}
class ClusterMockWatcher implements ClusterWatcher {
static class ClusterMockWatcher implements ClusterWatcher {
@Getter
private List<RemoteInstance> remoteInstances = new ArrayList<>();
......
......@@ -47,7 +47,7 @@ import static org.mockito.Mockito.mock;
@Slf4j
@Testcontainers
public class ITClusterEtcdPluginTest {
public class ClusterEtcdPluginIT {
private ClusterModuleEtcdConfig etcdConfig;
private Client client;
......
......@@ -53,7 +53,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
@Testcontainers
public class ITClusterModuleEtcdProviderFunctionalTest {
public class ClusterModuleEtcdProviderFunctionalIT {
private String endpoint;
private NoneTelemetryProvider telemetryProvider;
......@@ -322,7 +322,7 @@ public class ITClusterModuleEtcdProviderFunctionalTest {
assertTrue(otherExist);
}
class ClusterMockWatcher implements ClusterWatcher {
static class ClusterMockWatcher implements ClusterWatcher {
@Getter
private List<RemoteInstance> remoteInstances = new ArrayList<>();
......
......@@ -56,7 +56,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
@Testcontainers
@ExtendWith(MockitoExtension.class)
public class ITClusterModuleNacosProviderFunctionalTest {
public class ClusterModuleNacosProviderFunctionalIT {
private String nacosAddress;
private final String username = "nacos";
......@@ -335,7 +335,7 @@ public class ITClusterModuleNacosProviderFunctionalTest {
assertTrue(otherExist);
}
class ClusterMockWatcher implements ClusterWatcher {
static class ClusterMockWatcher implements ClusterWatcher {
@Getter
private List<RemoteInstance> remoteInstances = new ArrayList<>();
......
......@@ -22,7 +22,6 @@ import lombok.Getter;
import org.apache.curator.x.discovery.ServiceDiscovery;
import org.apache.skywalking.oap.server.core.cluster.ClusterCoordinator;
import org.apache.skywalking.oap.server.core.cluster.ClusterNodesQuery;
import org.apache.skywalking.oap.server.core.cluster.ClusterRegister;
import org.apache.skywalking.oap.server.core.cluster.ClusterWatcher;
import org.apache.skywalking.oap.server.core.cluster.RemoteInstance;
import org.apache.skywalking.oap.server.core.remote.client.Address;
......@@ -56,7 +55,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
@Testcontainers
@ExtendWith(MockitoExtension.class)
public class ITClusterModuleZookeeperProviderFunctionalTest {
public class ClusterModuleZookeeperProviderFunctionalIT {
private String zkAddress;
......@@ -258,10 +257,6 @@ public class ITClusterModuleZookeeperProviderFunctionalTest {
return provider;
}
private ClusterRegister getClusterRegister(ModuleProvider provider) {
return provider.getService(ClusterRegister.class);
}
private ClusterCoordinator getClusterCoordinator(ModuleProvider provider) {
return provider.getService(ClusterCoordinator.class);
}
......@@ -325,7 +320,7 @@ public class ITClusterModuleZookeeperProviderFunctionalTest {
assertTrue(otherExist);
}
class ClusterMockWatcher implements ClusterWatcher {
static class ClusterMockWatcher implements ClusterWatcher {
@Getter
private List<RemoteInstance> remoteInstances = new ArrayList<>();
......
......@@ -57,7 +57,7 @@ import static org.junit.jupiter.api.Assertions.fail;
@Slf4j
@Testcontainers
public class ITApolloConfigurationTest {
public class ApolloConfigurationIT {
private final Yaml yaml = new Yaml();
private final String token = "f71f002a4ff9845639ef655ee7019759e31449de";
private final CloseableHttpClient httpClient = HttpClients.createDefault();
......@@ -68,7 +68,7 @@ public class ITApolloConfigurationTest {
@Container
public final static DockerComposeContainer<?> ENVIRONMENT =
new DockerComposeContainer<>(new File(ITApolloConfigurationTest.class
new DockerComposeContainer<>(new File(ApolloConfigurationIT.class
.getClassLoader()
.getResource("docker/docker-compose.yaml").getPath()))
.withExposedService("apollo-config-and-portal", 8080,
......
......@@ -47,7 +47,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@Testcontainers
public class ITConsulConfigurationTest {
public class ConsulConfigurationIT {
private final Yaml yaml = new Yaml();
private ConsulConfigurationTestProvider provider;
......
......@@ -51,7 +51,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
@Slf4j
@Testcontainers
public class ITEtcdConfigurationTest {
public class EtcdConfigurationIT {
@Container
public final GenericContainer<?> container =
new GenericContainer<>(DockerImageName.parse("quay.io/coreos/etcd:v3.5.0"))
......
......@@ -50,7 +50,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
@Slf4j
@Testcontainers
public class ITNacosConfigurationTest {
public class NacosConfigurationIT {
private final Yaml yaml = new Yaml();
private NacosConfigurationTestProvider provider;
......
......@@ -50,7 +50,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
@Slf4j
@Testcontainers
public class ITZookeeperConfigurationTest {
public class ZookeeperConfigurationIT {
private final Yaml yaml = new Yaml();
private MockZookeeperConfigurationProvider provider;
......
......@@ -44,7 +44,7 @@ import java.util.Optional;
import java.util.function.Function;
@Slf4j
public class ITElasticSearch {
public class ElasticSearchIT {
public static Collection<Object[]> versions() {
// noinspection resource
......
......@@ -29,6 +29,7 @@ import org.apache.skywalking.library.elasticsearch.response.IndexTemplate;
import org.apache.skywalking.library.elasticsearch.response.Mappings;
import org.apache.skywalking.library.elasticsearch.response.search.SearchResponse;
import org.awaitility.Duration;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.testcontainers.elasticsearch.ElasticsearchContainer;
......@@ -50,7 +51,8 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class TCITElasticSearch {
@Tag("slow")
public class ElasticSearchIT {
public static Collection<Object[]> es() {
// noinspection resource
return Arrays.asList(new Object[][] {
......
......@@ -18,8 +18,6 @@
package org.apache.skywalking.oap.server.library.util;
import java.util.function.Consumer;
public final class StringUtil {
public static boolean isEmpty(String str) {
return str == null || str.length() == 0;
......@@ -37,12 +35,6 @@ public final class StringUtil {
return !isBlank(str);
}
public static void setIfPresent(String value, Consumer<String> setter) {
if (isNotEmpty(value)) {
setter.accept(value);
}
}
public static String join(final char delimiter, final String... strings) {
if (strings.length == 0) {
return null;
......
......@@ -102,7 +102,8 @@ import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;
@Slf4j
public class TCITShardingSphere {
@org.junit.jupiter.api.Tag("slow")
public class ShardingSphereIT {
private static MockedStatic<DefaultScopeDefine> DEFAULT_SCOPE_DEFINE_MOCKED_STATIC;
@BeforeAll
......@@ -158,7 +159,7 @@ public class TCITShardingSphere {
}
private void startEnv(String version, String dockerComposeName, int dsServicePort) {
environment = new DockerComposeContainer<>(new File(TCITShardingSphere.class
environment = new DockerComposeContainer<>(new File(ShardingSphereIT.class
.getClassLoader()
.getResource(dockerComposeName).getPath()))
.withExposedService("sharding-proxy", 3307,
......
......@@ -147,8 +147,8 @@
<properties>
<!-- Built in properties -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<powermock.version>2.0.9</powermock.version>
......@@ -180,6 +180,7 @@
<antlr.version>4.9.2</antlr.version>
<!-- Plugin versions -->
<maven-failsafe-plugin.version>3.0.0-M8</maven-failsafe-plugin.version>
<takari-maven-plugin.version>0.6.1</takari-maven-plugin.version>
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
<build-helper-maven-plugin.version>3.2.0</build-helper-maven-plugin.version>
......@@ -189,7 +190,7 @@
<assertj-core.version>3.20.2</assertj-core.version>
<skipUTs>false</skipUTs>
<skipITs>true</skipITs>
<system-stubs.version>2.0.2</system-stubs.version>
</properties>
......@@ -333,20 +334,12 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skip>${skipITs}</skip>
<!--
Exclude time-consuming tests and run those tests separately in skywalking.yaml.
TCIT means Time Consuming Integration Test.
-->
<excludes>
<exclude>**/TCIT*.java</exclude>
</excludes>
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
......@@ -360,18 +353,15 @@
<!--
maven-surefire-plugin will exclude integration tests (ITs)
and leave them for maven-failsafe-plugin to run, which is bound to the `verify` goal.
If you want to run the ITs please set the property skipITs to false (-DskipITs=false),
e.g. you want to run the ITs in oap-server, run `./mvnw -Pbackend clean verify -DskipITs=false`
If you want to run the ITs please run ./mvnw integration-test,
e.g. you want to run the ITs in oap-server, run `./mvnw -Pbackend clean integration-test`
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>${skipUTs}</skip>
<excludes>
<exclude>IT*.class</exclude>
<exclude>ShardingIntegrationTest.class</exclude>
</excludes>
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
</configuration>
</plugin>
......@@ -397,6 +387,7 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
......@@ -408,8 +399,7 @@
<configuration>
<rules>
<requireJavaVersion>
<!-- Build has not yet been updated for Java 9+ -->
<version>1.8</version>
<version>11</version>
</requireJavaVersion>
</rules>
</configuration>
......@@ -421,6 +411,7 @@
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
......@@ -432,6 +423,7 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<configuration>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册