Skip to content

Commit 13403f7

Browse files
Feat/optimize test (#117)
* feat: optimize trpc-core test * feat: optimize ci and codecov
1 parent 62da08b commit 13403f7

145 files changed

Lines changed: 1696 additions & 1721 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/codecov.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,20 @@ comment:
55

66
coverage: # https://docs.codecov.com/docs/codecovyml-reference#coverage
77
precision: 5
8-
range:
9-
- 70.0
10-
- 75.0
8+
range: "80...100"
119
status:
1210
project:
1311
default:
1412
branches:
15-
- ^master$
16-
target: 70.0 # the minimum coverage ratio that the commit must meet to be considered a success.
17-
threshold: 1% # allow the coverage to drop by X%, and posting a success status.
13+
- ^JDK17/Springboot3$
14+
target: 80.0
15+
threshold: 1%
16+
ignore:
17+
- "**/test/**"
18+
- "**/*Test.java"
19+
- "**/*AuthCenter.java"
20+
- "**/*QappPackage.java"
21+
- "**/*TRPCProtocol.java"
22+
parsers:
23+
jacoco:
24+
partials_as_hits: true

.github/workflows/ci.yml

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,12 @@ name: Maven Install Test
1010

1111
on:
1212
push:
13-
branches: [ "master" ]
13+
branches: [ "JDK17/Springboot3" ]
1414
pull_request:
15-
branches: [ "master" ]
15+
branches: [ "JDK17/Springboot3" ]
1616
schedule:
1717
- cron: '0 9 * * *'
1818
jobs:
19-
JDK8:
20-
runs-on: ubuntu-latest
21-
steps:
22-
- name: Checkout codes
23-
uses: actions/checkout@v3
24-
with:
25-
ref: ${{ github.event.pull_request.head.ref }}
26-
repository: ${{ github.event.pull_request.head.repo.full_name }}
27-
- name: Set up JDK 8
28-
uses: actions/setup-java@v3
29-
with:
30-
java-version: '8'
31-
distribution: 'temurin'
32-
cache: maven
33-
- name: Test with Maven
34-
run: mvn clean install -Dmaven.test.skip=true -B -U --file pom.xml
3519
JDK17:
3620
runs-on: ubuntu-latest
3721
steps:
@@ -64,29 +48,13 @@ jobs:
6448
cache: maven
6549
- name: Test with Maven
6650
run: mvn clean install -Dmaven.test.skip=true -B -U --file pom.xml
67-
JDK8-master:
68-
runs-on: ubuntu-latest
69-
steps:
70-
- name: Checkout codes
71-
uses: actions/checkout@v3
72-
with:
73-
ref: "master"
74-
repository: trpc-group/trpc-java
75-
- name: Set up JDK 8
76-
uses: actions/setup-java@v3
77-
with:
78-
java-version: '8'
79-
distribution: 'temurin'
80-
cache: maven
81-
- name: Test with Maven
82-
run: mvn clean install -Dmaven.test.skip=true -B -U --file pom.xml
8351
JDK17-master:
8452
runs-on: ubuntu-latest
8553
steps:
8654
- name: Checkout codes
8755
uses: actions/checkout@v3
8856
with:
89-
ref: "master"
57+
ref: "JDK17/Springboot3"
9058
repository: trpc-group/trpc-java
9159
- name: Set up JDK 17
9260
uses: actions/setup-java@v3
@@ -102,7 +70,7 @@ jobs:
10270
- name: Checkout codes
10371
uses: actions/checkout@v3
10472
with:
105-
ref: "master"
73+
ref: "JDK17/Springboot3"
10674
repository: trpc-group/trpc-java
10775
- name: Set up JDK 21
10876
uses: actions/setup-java@v3

.github/workflows/merge.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ name: Java CI with Maven
1010

1111
on:
1212
push:
13-
branches: [ "master" ]
13+
branches: [ "JDK17/Springboot3" ]
1414
schedule:
1515
- cron: '0 9 * * *'
1616
jobs:
@@ -19,10 +19,10 @@ jobs:
1919
steps:
2020
- name: Checkout codes
2121
uses: actions/checkout@v3
22-
- name: Set up JDK 8
22+
- name: Set up JDK 17
2323
uses: actions/setup-java@v3
2424
with:
25-
java-version: '8'
25+
java-version: '17'
2626
distribution: 'temurin'
2727
cache: maven
2828
- name: Test with Maven

.github/workflows/pull_request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
with:
2121
ref: ${{ github.event.pull_request.head.ref }}
2222
repository: ${{ github.event.pull_request.head.repo.full_name }}
23-
- name: Set up JDK 8
23+
- name: Set up JDK 17
2424
uses: actions/setup-java@v3
2525
with:
26-
java-version: '8'
26+
java-version: '17'
2727
distribution: 'temurin'
2828
cache: maven
2929
- name: Test with Maven

trpc-core/src/test/java/com/tencent/trpc/core/admin/AdminServiceManagerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
package com.tencent.trpc.core.admin;
1313

14-
import static org.junit.Assert.assertNotNull;
14+
import static org.junit.jupiter.api.Assertions.assertNotNull;
1515

16-
import org.junit.Test;
16+
import org.junit.jupiter.api.Test;
1717

1818
public class AdminServiceManagerTest {
1919

trpc-core/src/test/java/com/tencent/trpc/core/admin/TRpcFrameOverviewTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111

1212
package com.tencent.trpc.core.admin;
1313

14-
import static org.junit.Assert.assertEquals;
14+
import static org.junit.jupiter.api.Assertions.assertEquals;
1515

16-
import org.junit.Assert;
17-
import org.junit.Test;
16+
import org.junit.jupiter.api.Assertions;
17+
import org.junit.jupiter.api.Test;
1818

1919
public class TRpcFrameOverviewTest {
2020

2121
@Test
2222
public void test() {
2323
String trpcName = TRpcFrameOverview.getName();
2424
assertEquals(trpcName, "trpc-java");
25-
Assert.assertNotNull(TRpcFrameOverview.getVersion());
25+
Assertions.assertNotNull(TRpcFrameOverview.getVersion());
2626
}
2727

2828
}

trpc-core/src/test/java/com/tencent/trpc/core/cluster/ClusterInterceptorInvokerTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
import com.tencent.trpc.core.rpc.def.DefResponse;
2222
import com.tencent.trpc.core.utils.FutureUtils;
2323
import java.util.concurrent.CompletionStage;
24-
import org.junit.Assert;
25-
import org.junit.Before;
26-
import org.junit.Test;
24+
import org.junit.jupiter.api.Assertions;
25+
import org.junit.jupiter.api.BeforeEach;
26+
import org.junit.jupiter.api.Test;
2727

2828
public class ClusterInterceptorInvokerTest {
2929

@@ -33,7 +33,7 @@ public class ClusterInterceptorInvokerTest {
3333
/**
3434
* Init clusterInvoker & clusterInvokerNoInterceptors
3535
*/
36-
@Before
36+
@BeforeEach
3737
public void setUp() {
3838
ConsumerConfig<BlankRpcServiceName> consumerConfig = new ConsumerConfig<>();
3939
consumerConfig.setMock(false);
@@ -80,20 +80,20 @@ public CompletionStage<Response> invoke(Request request) {
8080
public void testNew() {
8181
ClusterInterceptorInvoker<BlankRpcServiceName> invoker = new ClusterInterceptorInvoker<>(clusterInvoker);
8282
ConsumerConfig<BlankRpcServiceName> config = invoker.getConfig();
83-
Assert.assertNotNull(config);
84-
Assert.assertFalse(config.getMock());
85-
Assert.assertTrue(invoker.getInterface().isAssignableFrom(BlankRpcServiceName.class));
86-
Assert.assertNotNull(invoker.getBackendConfig());
87-
Assert.assertEquals(invoker.getBackendConfig().getInterceptors().get(0), "log");
88-
Assert.assertNotNull(invoker.invoke(new DefRequest()));
83+
Assertions.assertNotNull(config);
84+
Assertions.assertFalse(config.getMock());
85+
Assertions.assertTrue(invoker.getInterface().isAssignableFrom(BlankRpcServiceName.class));
86+
Assertions.assertNotNull(invoker.getBackendConfig());
87+
Assertions.assertEquals(invoker.getBackendConfig().getInterceptors().get(0), "log");
88+
Assertions.assertNotNull(invoker.invoke(new DefRequest()));
8989
}
9090

9191
@Test
9292
public void testNewNoInterceptor() {
9393
ClusterInterceptorInvoker<BlankRpcServiceName> invokerWithoutInterceptor = new ClusterInterceptorInvoker<>(
9494
clusterInvokerNoInterceptors);
95-
Assert.assertNotNull(invokerWithoutInterceptor);
96-
Assert.assertTrue(invokerWithoutInterceptor.getBackendConfig().getInterceptors().isEmpty());
95+
Assertions.assertNotNull(invokerWithoutInterceptor);
96+
Assertions.assertTrue(invokerWithoutInterceptor.getBackendConfig().getInterceptors().isEmpty());
9797
}
9898

9999
@TRpcService

trpc-core/src/test/java/com/tencent/trpc/core/cluster/ClusterInterceptorManagerTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,21 @@
1313

1414
import com.tencent.trpc.core.cluster.spi.ClusterInterceptor;
1515
import com.tencent.trpc.core.cluster.spi.LogClusterInterceptor;
16-
import org.junit.Assert;
17-
import org.junit.Test;
16+
import org.junit.jupiter.api.Assertions;
17+
import org.junit.jupiter.api.Test;
1818

1919
public class ClusterInterceptorManagerTest {
2020

2121
@Test
2222
public void testGet() {
2323
ClusterInterceptor log = ClusterInterceptorManager.get("log");
24-
Assert.assertTrue(log instanceof LogClusterInterceptor);
24+
Assertions.assertTrue(log instanceof LogClusterInterceptor);
2525
}
2626

27-
@Test(expected = IllegalArgumentException.class)
27+
@Test
2828
public void testValidate() {
29-
ClusterInterceptorManager.validate("log1");
29+
Assertions.assertThrows(IllegalArgumentException.class, () -> {
30+
ClusterInterceptorManager.validate("log1");
31+
});
3032
}
31-
}
33+
}

trpc-core/src/test/java/com/tencent/trpc/core/cluster/RpcClusterClientManagerTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
package com.tencent.trpc.core.cluster;
1313

14-
import static org.junit.Assert.assertEquals;
14+
import static org.junit.jupiter.api.Assertions.assertEquals;
1515

1616
import com.tencent.trpc.core.common.config.BackendConfig;
1717
import com.tencent.trpc.core.common.config.ConsumerConfig;
@@ -22,8 +22,8 @@
2222
import com.tencent.trpc.core.rpc.RpcClient;
2323
import java.lang.reflect.Field;
2424
import java.util.Map;
25-
import org.junit.Assert;
26-
import org.junit.Test;
25+
import org.junit.jupiter.api.Assertions;
26+
import org.junit.jupiter.api.Test;
2727

2828
public class RpcClusterClientManagerTest {
2929

@@ -35,7 +35,7 @@ public void test() throws IllegalArgumentException, IllegalAccessException, NoSu
3535
backendConfig.setNamingUrl("ip://127.0.0.1");
3636
ProtocolConfigTest config = new ProtocolConfigTest();
3737
RpcClient rpcClient = RpcClusterClientManager.getOrCreateClient(backendConfig, config);
38-
Assert.assertNotNull(rpcClient);
38+
Assertions.assertNotNull(rpcClient);
3939
Field field = RpcClusterClientManager.class.getDeclaredField("CLUSTER_MAP");
4040
field.setAccessible(true);
4141
Map<BackendConfig, Map> clusterMap = (Map<BackendConfig, Map>) field.get(null);

trpc-core/src/test/java/com/tencent/trpc/core/cluster/StandardRpcClusterClientFactoryTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
import com.tencent.trpc.core.cluster.def.DefRpcClusterClient;
1515
import com.tencent.trpc.core.common.config.BackendConfig;
16-
import org.junit.Assert;
17-
import org.junit.Test;
16+
import org.junit.jupiter.api.Assertions;
17+
import org.junit.jupiter.api.Test;
1818

1919
public class StandardRpcClusterClientFactoryTest {
2020

@@ -23,6 +23,6 @@ public void testCreate() {
2323
StandardRpcClusterClientFactory factory = new StandardRpcClusterClientFactory();
2424
BackendConfig config = new BackendConfig();
2525
RpcClusterClient standard = factory.create(config);
26-
Assert.assertTrue(standard instanceof DefRpcClusterClient);
26+
Assertions.assertTrue(standard instanceof DefRpcClusterClient);
2727
}
28-
}
28+
}

0 commit comments

Comments
 (0)