From cefd973d40abf9794b033b0bd540bfe4e18eefbb Mon Sep 17 00:00:00 2001 From: Lauri Tulmin Date: Tue, 14 Jan 2025 15:26:54 +0200 Subject: [PATCH] Fix apache shenyu latest dep test (#13037) --- .../javaagent/build.gradle.kts | 28 +++++++++++++------ .../apacheshenyu/v2_4/ShenYuRouteTest.java | 25 +++++++++-------- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/instrumentation/apache-shenyu-2.4/javaagent/build.gradle.kts b/instrumentation/apache-shenyu-2.4/javaagent/build.gradle.kts index 4bc674ecee..4915bc14bd 100644 --- a/instrumentation/apache-shenyu-2.4/javaagent/build.gradle.kts +++ b/instrumentation/apache-shenyu-2.4/javaagent/build.gradle.kts @@ -26,12 +26,21 @@ dependencies { exclude("org.codehaus.groovy", "groovy") } - // the latest version of apache shenyu uses spring-boot 2.7 - latestDepTestLibrary("org.springframework.boot:spring-boot-starter-test:2.7.+") // related dependency + // the latest version of apache shenyu uses spring-boot 3.3 + latestDepTestLibrary("org.springframework.boot:spring-boot-starter-test:3.3.+") // related dependency 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().configureEach { jvmArgs("-Dotel.instrumentation.apache-shenyu.experimental-span-attributes=true") @@ -39,13 +48,16 @@ tasks.withType().configureEach { jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") - systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean) + systemProperty("testLatestDeps", latestDepTest) } -configurations.testRuntimeClasspath { - resolutionStrategy { - // 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") +// spring 6 (spring boot 3) uses slf4j 2.0 +if (!latestDepTest) { + configurations.testRuntimeClasspath { + resolutionStrategy { + // 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") + } } } diff --git a/instrumentation/apache-shenyu-2.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ShenYuRouteTest.java b/instrumentation/apache-shenyu-2.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ShenYuRouteTest.java index 0dd60b248b..82ca31ba86 100644 --- a/instrumentation/apache-shenyu-2.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ShenYuRouteTest.java +++ b/instrumentation/apache-shenyu-2.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ShenYuRouteTest.java @@ -74,7 +74,7 @@ class ShenYuRouteTest { InvocationTargetException, IllegalAccessException { - Class metaDataCache = null; + Class metaDataCache; try { metaDataCache = Class.forName("org.apache.shenyu.plugin.global.cache.MetaDataCache"); } catch (ClassNotFoundException e) { @@ -87,17 +87,18 @@ class ShenYuRouteTest { cacheMethod.invoke( cacheInst, - new MetaData( - "123", - "test-shenyu", - "/", - "/a/b/c", - "http", - "shenyu-service", - "hello", - "string", - "test-ext", - true)); + MetaData.builder() + .id("123") + .appName("test-shenyu") + .contextPath("/") + .path("/a/b/c") + .rpcType("http") + .serviceName("shenyu-service") + .methodName("hello") + .parameterTypes("string") + .rpcExt("test-ext") + .enabled(true) + .build()); } @Test