Skip to content

Commit cefd973

Browse files
authored
Fix apache shenyu latest dep test (#13037)
1 parent ff331d8 commit cefd973

File tree

2 files changed

+33
-20
lines changed

2 files changed

+33
-20
lines changed

instrumentation/apache-shenyu-2.4/javaagent/build.gradle.kts

+20-8
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,38 @@ dependencies {
2626
exclude("org.codehaus.groovy", "groovy")
2727
}
2828

29-
// the latest version of apache shenyu uses spring-boot 2.7
30-
latestDepTestLibrary("org.springframework.boot:spring-boot-starter-test:2.7.+") // related dependency
29+
// the latest version of apache shenyu uses spring-boot 3.3
30+
latestDepTestLibrary("org.springframework.boot:spring-boot-starter-test:3.3.+") // related dependency
3131

3232
testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent"))
3333
}
3434

35+
val latestDepTest = findProperty("testLatestDeps") as Boolean
36+
37+
// spring 6 (spring boot 3) requires java 17
38+
if (latestDepTest) {
39+
otelJava {
40+
minJavaVersionSupported.set(JavaVersion.VERSION_17)
41+
}
42+
}
43+
3544
tasks.withType<Test>().configureEach {
3645
jvmArgs("-Dotel.instrumentation.apache-shenyu.experimental-span-attributes=true")
3746

3847
// required on jdk17
3948
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
4049
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
4150

42-
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
51+
systemProperty("testLatestDeps", latestDepTest)
4352
}
4453

45-
configurations.testRuntimeClasspath {
46-
resolutionStrategy {
47-
// requires old logback (and therefore also old slf4j)
48-
force("ch.qos.logback:logback-classic:1.2.11")
49-
force("org.slf4j:slf4j-api:1.7.36")
54+
// spring 6 (spring boot 3) uses slf4j 2.0
55+
if (!latestDepTest) {
56+
configurations.testRuntimeClasspath {
57+
resolutionStrategy {
58+
// requires old logback (and therefore also old slf4j)
59+
force("ch.qos.logback:logback-classic:1.2.11")
60+
force("org.slf4j:slf4j-api:1.7.36")
61+
}
5062
}
5163
}

instrumentation/apache-shenyu-2.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ShenYuRouteTest.java

+13-12
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static void beforeAll()
7474
InvocationTargetException,
7575
IllegalAccessException {
7676

77-
Class<?> metaDataCache = null;
77+
Class<?> metaDataCache;
7878
try {
7979
metaDataCache = Class.forName("org.apache.shenyu.plugin.global.cache.MetaDataCache");
8080
} catch (ClassNotFoundException e) {
@@ -87,17 +87,18 @@ static void beforeAll()
8787

8888
cacheMethod.invoke(
8989
cacheInst,
90-
new MetaData(
91-
"123",
92-
"test-shenyu",
93-
"/",
94-
"/a/b/c",
95-
"http",
96-
"shenyu-service",
97-
"hello",
98-
"string",
99-
"test-ext",
100-
true));
90+
MetaData.builder()
91+
.id("123")
92+
.appName("test-shenyu")
93+
.contextPath("/")
94+
.path("/a/b/c")
95+
.rpcType("http")
96+
.serviceName("shenyu-service")
97+
.methodName("hello")
98+
.parameterTypes("string")
99+
.rpcExt("test-ext")
100+
.enabled(true)
101+
.build());
101102
}
102103

103104
@Test

0 commit comments

Comments
 (0)