Skip to content

Commit 5eb3279

Browse files
Replace RestTemplate with OkHttp for system tests (#4239)
* Also use port when checking if a request is made to Sentry DSN * changelog * Add a param to control whether the test script should rebuild before running the tested server * Add system tests for distributed tracing * reuse util classes for system tests * add schema * Add distributed tracing tests to more modules * use mono.just for post body * Replace RestTemplate with OkHttp in system tests * Format code * format + api * Update buildSrc/src/main/java/Config.kt --------- Co-authored-by: Sentry Github Bot <[email protected]>
1 parent ac9ebcd commit 5eb3279

File tree

15 files changed

+129
-111
lines changed

15 files changed

+129
-111
lines changed

buildSrc/src/main/java/Config.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,13 @@ object Config {
6969
val slf4jJdk14 = "org.slf4j:slf4j-jdk14:1.7.30"
7070
val logbackVersion = "1.2.9"
7171
val logbackClassic = "ch.qos.logback:logback-classic:$logbackVersion"
72+
val logbackCore = "ch.qos.logback:logback-core:$logbackVersion"
7273

7374
val log4j2Version = "2.20.0"
7475
val log4j2Api = "org.apache.logging.log4j:log4j-api:$log4j2Version"
7576
val log4j2Core = "org.apache.logging.log4j:log4j-core:$log4j2Version"
7677

77-
val jacksonDatabind = "com.fasterxml.jackson.core:jackson-databind"
78+
val jacksonDatabind = "com.fasterxml.jackson.core:jackson-databind:2.18.3"
7879
val jacksonKotlin = "com.fasterxml.jackson.module:jackson-module-kotlin:2.18.3"
7980

8081
val springBootStarter = "org.springframework.boot:spring-boot-starter:$springBootVersion"

sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry-noagent/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ dependencies {
6363
testImplementation(kotlin(Config.kotlinStdLib))
6464
testImplementation(Config.TestLibs.kotlinTestJunit)
6565
testImplementation("ch.qos.logback:logback-classic:1.5.16")
66+
testImplementation("ch.qos.logback:logback-core:1.5.16")
6667
testImplementation(Config.Libs.slf4jApi2)
6768
testImplementation(Config.Libs.apolloKotlin)
6869
}

sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ dependencies {
6565
testImplementation(kotlin(Config.kotlinStdLib))
6666
testImplementation(Config.TestLibs.kotlinTestJunit)
6767
testImplementation("ch.qos.logback:logback-classic:1.5.16")
68+
testImplementation("ch.qos.logback:logback-core:1.5.16")
6869
testImplementation(Config.Libs.slf4jApi2)
6970
testImplementation(Config.Libs.apolloKotlin)
7071
}

sentry-samples/sentry-samples-spring-boot-jakarta/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ dependencies {
6363
testImplementation(kotlin(Config.kotlinStdLib))
6464
testImplementation(Config.TestLibs.kotlinTestJunit)
6565
testImplementation("ch.qos.logback:logback-classic:1.5.16")
66+
testImplementation("ch.qos.logback:logback-core:1.5.16")
6667
testImplementation(Config.Libs.slf4jApi2)
6768
testImplementation(Config.Libs.apolloKotlin)
6869
testImplementation(projects.sentry)

sentry-samples/sentry-samples-spring-boot-opentelemetry-noagent/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ dependencies {
6363
}
6464
testImplementation(kotlin(Config.kotlinStdLib))
6565
testImplementation(Config.TestLibs.kotlinTestJunit)
66-
testImplementation(Config.Libs.logbackClassic)
66+
testImplementation("ch.qos.logback:logback-classic:1.5.16")
67+
testImplementation("ch.qos.logback:logback-core:1.5.16")
6768
testImplementation(Config.Libs.slf4jApi2)
6869
testImplementation(Config.Libs.apolloKotlin)
6970
testImplementation("org.apache.httpcomponents:httpclient")

sentry-samples/sentry-samples-spring-boot-opentelemetry/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ dependencies {
6464
}
6565
testImplementation(kotlin(Config.kotlinStdLib))
6666
testImplementation(Config.TestLibs.kotlinTestJunit)
67-
testImplementation(Config.Libs.logbackClassic)
67+
testImplementation("ch.qos.logback:logback-classic:1.5.16")
68+
testImplementation("ch.qos.logback:logback-core:1.5.16")
6869
testImplementation(Config.Libs.slf4jApi2)
6970
testImplementation(Config.Libs.apolloKotlin)
7071
testImplementation("org.apache.httpcomponents:httpclient")

sentry-samples/sentry-samples-spring-boot-webflux-jakarta/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ dependencies {
3636
testImplementation(kotlin(Config.kotlinStdLib))
3737
testImplementation(Config.TestLibs.kotlinTestJunit)
3838
testImplementation("ch.qos.logback:logback-classic:1.5.16")
39+
testImplementation("ch.qos.logback:logback-core:1.5.16")
3940
testImplementation(Config.Libs.slf4jApi2)
4041
testImplementation(Config.Libs.apolloKotlin)
4142
}

sentry-samples/sentry-samples-spring-boot-webflux/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ dependencies {
3333
}
3434
testImplementation(kotlin(Config.kotlinStdLib))
3535
testImplementation(Config.TestLibs.kotlinTestJunit)
36-
testImplementation(Config.Libs.logbackClassic)
36+
testImplementation("ch.qos.logback:logback-classic:1.5.16")
37+
testImplementation("ch.qos.logback:logback-core:1.5.16")
3738
testImplementation(Config.Libs.slf4jApi2)
3839
testImplementation(Config.Libs.apolloKotlin)
3940
testImplementation("org.apache.httpcomponents:httpclient")

sentry-samples/sentry-samples-spring-boot/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ dependencies {
6161
}
6262
testImplementation(kotlin(Config.kotlinStdLib))
6363
testImplementation(Config.TestLibs.kotlinTestJunit)
64-
testImplementation(Config.Libs.logbackClassic)
64+
testImplementation("ch.qos.logback:logback-classic:1.5.16")
65+
testImplementation("ch.qos.logback:logback-core:1.5.16")
6566
testImplementation(Config.Libs.slf4jApi2)
6667
testImplementation(Config.Libs.apolloKotlin)
6768
testImplementation("org.apache.httpcomponents:httpclient")

sentry-system-test-support/api/sentry-system-test-support.api

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,10 @@ public final class io/sentry/systemtest/Todo {
488488
public final fun copy (JLjava/lang/String;Z)Lio/sentry/systemtest/Todo;
489489
public static synthetic fun copy$default (Lio/sentry/systemtest/Todo;JLjava/lang/String;ZILjava/lang/Object;)Lio/sentry/systemtest/Todo;
490490
public fun equals (Ljava/lang/Object;)Z
491+
public final fun getCompleted ()Z
491492
public final fun getId ()J
492493
public final fun getTitle ()Ljava/lang/String;
493494
public fun hashCode ()I
494-
public final fun isCompleted ()Z
495495
public fun toString ()Ljava/lang/String;
496496
}
497497

@@ -518,7 +518,14 @@ public final class io/sentry/systemtest/util/EnvelopesReceived {
518518

519519
public class io/sentry/systemtest/util/LoggingInsecureRestClient {
520520
public fun <init> ()V
521-
protected final fun restTemplate ()Lorg/springframework/web/client/RestTemplate;
521+
protected final fun call (Lokhttp3/Request$Builder;ZLjava/util/Map;)Lokhttp3/Response;
522+
public static synthetic fun call$default (Lio/sentry/systemtest/util/LoggingInsecureRestClient;Lokhttp3/Request$Builder;ZLjava/util/Map;ILjava/lang/Object;)Lokhttp3/Response;
523+
protected final fun client ()Lokhttp3/OkHttpClient;
524+
public final fun getLastKnownStatusCode ()Ljava/lang/Integer;
525+
public final fun getLogger ()Lorg/slf4j/Logger;
526+
protected final fun objectMapper ()Lcom/fasterxml/jackson/databind/ObjectMapper;
527+
public final fun setLastKnownStatusCode (Ljava/lang/Integer;)V
528+
protected final fun toRequestBody (Ljava/lang/Object;)Lokhttp3/RequestBody;
522529
}
523530

524531
public final class io/sentry/systemtest/util/RestTestClient : io/sentry/systemtest/util/LoggingInsecureRestClient {
@@ -527,14 +534,12 @@ public final class io/sentry/systemtest/util/RestTestClient : io/sentry/systemte
527534
public static synthetic fun createPerson$default (Lio/sentry/systemtest/util/RestTestClient;Lio/sentry/systemtest/Person;Ljava/util/Map;ILjava/lang/Object;)Lio/sentry/systemtest/Person;
528535
public final fun createPersonDistributedTracing (Lio/sentry/systemtest/Person;Ljava/util/Map;)Lio/sentry/systemtest/Person;
529536
public static synthetic fun createPersonDistributedTracing$default (Lio/sentry/systemtest/util/RestTestClient;Lio/sentry/systemtest/Person;Ljava/util/Map;ILjava/lang/Object;)Lio/sentry/systemtest/Person;
530-
public final fun getLastKnownStatusCode ()Ljava/lang/Integer;
531537
public final fun getPerson (J)Lio/sentry/systemtest/Person;
532538
public final fun getPersonDistributedTracing (JLjava/util/Map;)Lio/sentry/systemtest/Person;
533539
public static synthetic fun getPersonDistributedTracing$default (Lio/sentry/systemtest/util/RestTestClient;JLjava/util/Map;ILjava/lang/Object;)Lio/sentry/systemtest/Person;
534540
public final fun getTodo (J)Lio/sentry/systemtest/Todo;
535541
public final fun getTodoRestClient (J)Lio/sentry/systemtest/Todo;
536542
public final fun getTodoWebclient (J)Lio/sentry/systemtest/Todo;
537-
public final fun setLastKnownStatusCode (Ljava/lang/Integer;)V
538543
}
539544

540545
public final class io/sentry/systemtest/util/SentryMockServerClient : io/sentry/systemtest/util/LoggingInsecureRestClient {

0 commit comments

Comments
 (0)