Skip to content

Commit 1a1df97

Browse files
authored
ci(core): 在 push/PR 上运行 core 单元测试 (#529)
* ci(core): run core unit tests on push/PR and add JaCoCo report Adds .github/workflows/core-test.yml to run `mvn test -pl core` and upload the JaCoCo report. Adds the JaCoCo plugin to core/pom.xml in report-only mode (no coverage gate). * ci(core): drop JaCoCo, fix core unit test fork crash - Remove jacoco-maven-plugin from core/pom.xml and the coverage upload step from the workflow; keep only `mvn test -pl core`. - Add surefire config pointing benchmark-conf at the repo-root config dir so ConfigDescriptor finds function.xml/config.properties. Under surefire the fork's working dir is core/, where these files don't exist, so Config.initInnerFunction() did System.exit(0) and crashed the forked VM ("terminated without properly saying goodbye"). - Fix stale OPERATION_PROPORTION in OperationControllerTest (11 -> 13 values) to match the current count of normal operations.
1 parent 4703643 commit 1a1df97

3 files changed

Lines changed: 48 additions & 3 deletions

File tree

.github/workflows/core-test.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: core-unit-test
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
jobs:
10+
core-unit-test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: checkout
14+
uses: actions/checkout@v4
15+
with:
16+
path: iot-benchmark
17+
- name: Set java 8
18+
uses: actions/setup-java@v4
19+
with:
20+
distribution: 'zulu'
21+
java-version: 8
22+
- name: run core unit tests
23+
run: |
24+
cd ${{ github.workspace }}/iot-benchmark
25+
mvn -B test -pl core

core/pom.xml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,27 @@
114114
</dependency>
115115
</dependencies>
116116
<build>
117-
117+
<plugins>
118+
<plugin>
119+
<groupId>org.apache.maven.plugins</groupId>
120+
<artifactId>maven-surefire-plugin</artifactId>
121+
<version>3.5.4</version>
122+
<configuration>
123+
<!--
124+
Tests trigger ConfigDescriptor, which resolves config.properties and
125+
function.xml relative to "benchmark-conf" (default: configuration/conf).
126+
Surefire forks with workingDirectory=core/, where these files don't
127+
exist, so Config.initInnerFunction() hits a missing function.xml and
128+
calls System.exit(0) (crashing the fork). Point benchmark-conf at the
129+
repo-root config dir so the files resolve. The root config.properties
130+
is fully commented out, so config stays at defaults.
131+
-->
132+
<systemPropertyVariables>
133+
<benchmark-conf>${project.parent.basedir}/configuration/conf</benchmark-conf>
134+
</systemPropertyVariables>
135+
</configuration>
136+
</plugin>
137+
</plugins>
118138
</build>
119139

120140
</project>

core/src/test/java/cn/edu/tsinghua/iot/benchmark/client/OperationControllerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ public void after() {}
4242

4343
@Test
4444
public void testGetNextOperationType() {
45-
config.setOPERATION_PROPORTION("1:0:0:0:0:0:0:0:0:0:0");
45+
config.setOPERATION_PROPORTION("1:0:0:0:0:0:0:0:0:0:0:0:0");
4646
OperationController operationController = new OperationController(0);
4747

4848
int loop = 10000;
4949
for (int i = 0; i < loop; i++) {
5050
Assert.assertEquals(Operation.INGESTION, operationController.getNextOperationType());
5151
}
5252

53-
config.setOPERATION_PROPORTION("0:1:0:0:0:0:0:0:0:0:0");
53+
config.setOPERATION_PROPORTION("0:1:0:0:0:0:0:0:0:0:0:0:0");
5454
operationController = new OperationController(0);
5555
for (int i = 0; i < loop; i++) {
5656
assertEquals(Operation.PRECISE_QUERY, operationController.getNextOperationType());

0 commit comments

Comments
 (0)