Fix apache shenyu latest dep test (#13037)

This commit is contained in:
Lauri Tulmin 2025-01-14 15:26:54 +02:00 committed by GitHub
parent ff331d8e0d
commit cefd973d40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 20 deletions

View File

@ -26,12 +26,21 @@ dependencies {
exclude("org.codehaus.groovy", "groovy") exclude("org.codehaus.groovy", "groovy")
} }
// the latest version of apache shenyu uses spring-boot 2.7 // the latest version of apache shenyu uses spring-boot 3.3
latestDepTestLibrary("org.springframework.boot:spring-boot-starter-test:2.7.+") // related dependency latestDepTestLibrary("org.springframework.boot:spring-boot-starter-test:3.3.+") // related dependency
testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent")) testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent"))
} }
val latestDepTest = findProperty("testLatestDeps") as Boolean
// spring 6 (spring boot 3) requires java 17
if (latestDepTest) {
otelJava {
minJavaVersionSupported.set(JavaVersion.VERSION_17)
}
}
tasks.withType<Test>().configureEach { tasks.withType<Test>().configureEach {
jvmArgs("-Dotel.instrumentation.apache-shenyu.experimental-span-attributes=true") jvmArgs("-Dotel.instrumentation.apache-shenyu.experimental-span-attributes=true")
@ -39,13 +48,16 @@ tasks.withType<Test>().configureEach {
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean) systemProperty("testLatestDeps", latestDepTest)
} }
configurations.testRuntimeClasspath { // spring 6 (spring boot 3) uses slf4j 2.0
resolutionStrategy { if (!latestDepTest) {
// requires old logback (and therefore also old slf4j) configurations.testRuntimeClasspath {
force("ch.qos.logback:logback-classic:1.2.11") resolutionStrategy {
force("org.slf4j:slf4j-api:1.7.36") // requires old logback (and therefore also old slf4j)
force("ch.qos.logback:logback-classic:1.2.11")
force("org.slf4j:slf4j-api:1.7.36")
}
} }
} }

View File

@ -74,7 +74,7 @@ class ShenYuRouteTest {
InvocationTargetException, InvocationTargetException,
IllegalAccessException { IllegalAccessException {
Class<?> metaDataCache = null; Class<?> metaDataCache;
try { try {
metaDataCache = Class.forName("org.apache.shenyu.plugin.global.cache.MetaDataCache"); metaDataCache = Class.forName("org.apache.shenyu.plugin.global.cache.MetaDataCache");
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
@ -87,17 +87,18 @@ class ShenYuRouteTest {
cacheMethod.invoke( cacheMethod.invoke(
cacheInst, cacheInst,
new MetaData( MetaData.builder()
"123", .id("123")
"test-shenyu", .appName("test-shenyu")
"/", .contextPath("/")
"/a/b/c", .path("/a/b/c")
"http", .rpcType("http")
"shenyu-service", .serviceName("shenyu-service")
"hello", .methodName("hello")
"string", .parameterTypes("string")
"test-ext", .rpcExt("test-ext")
true)); .enabled(true)
.build());
} }
@Test @Test