Skip to content

Commit bc1bc3e

Browse files
authored
Extend plugin test coverage for newer framework versions (#801)
* Extend MySQL plugin to support MySQL Connector/J 8.4.0 and 9.x (9.0 -> 9.6). * Extend MariaDB plugin to support MariaDB Connector/J 2.7.x. * Extend MongoDB 4.x plugin to support MongoDB Java Driver 4.2 -> 4.10. Fix db.bind_vars extraction for driver 4.9+ where InsertOperation/DeleteOperation/UpdateOperation classes were removed. * Extend Feign plugin to support OpenFeign 10.x, 11.x, 12.1. * Extend Undertow plugin to support Undertow 2.1.x, 2.2.x, 2.3.x. * Extend GraphQL plugin to support graphql-java 18 -> 24 (20+ requires JDK 17). * Extend Spring Kafka plugin to support Spring Kafka 2.4 -> 2.9 and 3.0 -> 3.3. * Enhance test/plugin/run.sh to support extra Maven properties per version in support-version.list (format: version,key=value).
1 parent b1351bc commit bc1bc3e

File tree

65 files changed

+3864
-39
lines changed

Some content is hidden

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

65 files changed

+3864
-39
lines changed

.claude/skills/compile/SKILL.md

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
name: compile
3+
description: Build the SkyWalking Java agent — full build, skip tests, single module, or plugin test scenarios
4+
user-invocable: true
5+
allowed-tools: Bash, Read, Glob, Grep
6+
---
7+
8+
# Compile SkyWalking Java Agent
9+
10+
Build the project based on user request. Detect what they want to build and run the appropriate command.
11+
12+
## Prerequisites
13+
14+
- JDK 17, 21, or 25 (JDK 8 is supported at runtime but JDK 17+ is needed to compile)
15+
- Maven is bundled as `./mvnw` (Maven wrapper)
16+
- Git submodules must be initialized for protocol definitions
17+
18+
Check JDK version first:
19+
```bash
20+
java -version
21+
```
22+
23+
If submodules are not initialized:
24+
```bash
25+
git submodule init && git submodule update
26+
```
27+
28+
## Build Commands
29+
30+
### Full build (with tests)
31+
```bash
32+
./mvnw clean package -Pall
33+
```
34+
35+
### Full build (skip tests — recommended for development)
36+
```bash
37+
./mvnw clean package -Dmaven.test.skip=true
38+
```
39+
40+
### CI build (with javadoc verification)
41+
```bash
42+
./mvnw clean verify install javadoc:javadoc -Dmaven.test.skip=true
43+
```
44+
45+
### Build a single plugin module
46+
```bash
47+
./mvnw clean package -pl apm-sniffer/apm-sdk-plugin/{plugin-name} -am -Dmaven.test.skip=true
48+
```
49+
The `-am` flag builds required dependencies. Replace `{plugin-name}` with the actual plugin directory name.
50+
51+
### Run checkstyle only
52+
```bash
53+
./mvnw checkstyle:check
54+
```
55+
56+
### Run unit tests for a single module
57+
```bash
58+
./mvnw test -pl apm-sniffer/apm-sdk-plugin/{plugin-name}
59+
```
60+
61+
### Build agent distribution only (after full build)
62+
The built agent is in `skywalking-agent/` directory after a full build.
63+
64+
### Run a plugin E2E test scenario
65+
66+
The E2E test framework has a **two-phase build** (matching CI):
67+
68+
**Phase 1 — Build agent + test tools + Docker images (one-time setup):**
69+
```bash
70+
# Build the agent (JDK 17+ required)
71+
./mvnw clean package -Dmaven.test.skip=true
72+
73+
# Switch to JDK 8 to build test tools and Docker images
74+
# The test/plugin/pom.xml builds: runner-helper, agent-test-tools, JVM/Tomcat container images
75+
export JAVA_HOME=$(/usr/libexec/java_home -v 8)
76+
export PATH=$JAVA_HOME/bin:$PATH
77+
78+
./mvnw --batch-mode -f test/plugin/pom.xml \
79+
-Dmaven.test.skip \
80+
-Dbase_image_java=eclipse-temurin:8-jdk \
81+
-Dbase_image_tomcat=tomcat:8.5-jdk8-openjdk \
82+
-Dcontainer_image_version=1.0.0 \
83+
clean package
84+
```
85+
86+
This builds `skywalking/agent-test-jvm:1.0.0` and `skywalking/agent-test-tomcat:1.0.0` Docker images,
87+
plus `test/plugin/dist/plugin-runner-helper.jar` and `test/plugin/agent-test-tools/dist/` (mock-collector, validator).
88+
89+
**Phase 2 — Run test scenarios (per scenario):**
90+
```bash
91+
# Use JDK 8 (matching CI). JDK 17 works for runner-helper but JDK 8 matches CI exactly.
92+
export JAVA_HOME=$(/usr/libexec/java_home -v 8)
93+
export PATH=$JAVA_HOME/bin:$PATH
94+
95+
# Run WITHOUT -f (reuses pre-built tools and images from Phase 1)
96+
bash ./test/plugin/run.sh --debug {scenario-name}
97+
```
98+
99+
**IMPORTANT flags:**
100+
- `--debug` — keeps workspace with logs and `actualData.yaml` for inspection after test
101+
- `-f` (force) — rebuilds ALL test tools and Docker images from scratch. **Do NOT use** if Phase 1 already completed — it re-clones `skywalking-agent-test-tool` from GitHub and rebuilds everything, which is slow and may fail due to network issues.
102+
- Without `-f` — reuses existing tools/images. This is the normal way to run tests.
103+
104+
**Key rules:**
105+
- Run scenarios **one at a time** — they share Docker ports (8080, etc.) and will conflict if parallel
106+
- JDK 8 test scenarios use `eclipse-temurin:8-jdk` base image
107+
- JDK 17 test scenarios (in `plugins-jdk17-test` workflows) use `eclipse-temurin:17-jdk` base image
108+
- After a test, check `test/plugin/workspace/{scenario}/{version}/data/actualData.yaml` vs `expectedData.yaml` for debugging failures
109+
- Check `test/plugin/workspace/{scenario}/{version}/logs/` for container logs
110+
111+
**Diagnosing "startup script not exists" failures:**
112+
This error means the scenario ZIP wasn't built or copied into the container. The root cause is almost always a **silent Maven build failure**`run.sh` uses `mvnw -q` (quiet mode) which hides errors. Common causes:
113+
1. **Maven Central network timeout** — downloading a new library version fails silently. The `mvnw clean package` exits non-zero but the `-q` flag hides the error, and `run.sh` continues with missing artifacts.
114+
2. **Docker Hub timeout** — pulling dependency images (mongo, mysql, kafka, zookeeper) fails with EOF/TLS errors.
115+
3. **Killed previous run** — if a prior parallel run was killed mid-execution, leftover state in `test/plugin/workspace/` can interfere. Always `rm -rf test/plugin/workspace/{scenario}` before rerunning.
116+
117+
To debug: run the Maven build manually in the scenario directory with verbose output:
118+
```bash
119+
cd test/plugin/scenarios/{scenario-name}
120+
../../../../mvnw clean package -Dtest.framework.version={version} -Dmaven.test.skip=true
121+
```
122+
If this succeeds but `run.sh` fails, it's likely a transient Maven Central network issue. Pre-download dependencies first:
123+
```bash
124+
# Pre-warm Maven cache for all versions before running tests
125+
for v in $(grep -v '^#' test/plugin/scenarios/{scenario}/support-version.list | grep -v '^$'); do
126+
cd test/plugin/scenarios/{scenario}
127+
../../../../mvnw dependency:resolve -Dtest.framework.version=$v -q
128+
cd -
129+
done
130+
```
131+
132+
**Pre-pulling Docker dependency images:**
133+
Scenarios with `dependencies:` in `configuration.yml` need external Docker images. Pre-pull them before running tests to avoid mid-test Docker Hub failures:
134+
```bash
135+
# Check what images a scenario needs
136+
grep "image:" test/plugin/scenarios/{scenario}/configuration.yml
137+
# Pull them
138+
docker pull {image:tag}
139+
```
140+
141+
### Generate protobuf sources (needed before IDE import)
142+
```bash
143+
./mvnw compile -Dmaven.test.skip=true
144+
```
145+
Then mark `*/target/generated-sources/protobuf/java` and `*/target/generated-sources/protobuf/grpc-java` as generated source folders in your IDE.
146+
147+
## Common Issues
148+
149+
- **Submodule not initialized**: If proto files are missing, run `git submodule init && git submodule update`
150+
- **Wrong JDK version**: Agent build requires JDK 17+. Test tools build (test/plugin/pom.xml) works best with JDK 8. Check with `java -version`.
151+
- **Checkstyle failures**: Run `./mvnw checkstyle:check` to see violations. Common: star imports, unused imports, System.out.println, missing @Override.
152+
- **Test scenario Docker issues**: Ensure Docker daemon is running. Use `--debug` flag to inspect `actualData.yaml`.
153+
- **`run.sh -f` fails on agent-test-tools**: The `-f` flag clones `skywalking-agent-test-tool` from GitHub and rebuilds from source. If GitHub is slow or unreachable, this fails. Solution: run Phase 1 build separately (see above), then use `run.sh` without `-f`.
154+
- **Lombok errors in runner-helper on JDK 25**: The test framework uses Lombok 1.18.20 which doesn't support JDK 25. Use JDK 8 or JDK 17 for building and running test tools.
155+
- **"startup script not exists" inside container**: The scenario ZIP wasn't built or copied correctly. Check that `mvnw clean package` succeeds in the scenario directory and produces both a `.jar` and `.zip` in `target/`.
156+
- **Port conflicts**: Never run multiple E2E scenarios simultaneously — they all bind to the same Docker ports.

0 commit comments

Comments
 (0)