Skip to content

Commit 12959a7

Browse files
committed
more assertions for e2e tests
1 parent 0f37c1d commit 12959a7

File tree

35 files changed

+234
-67
lines changed

35 files changed

+234
-67
lines changed

sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry-noagent/src/test/kotlin/io/sentry/systemtest/GraphqlGreetingSystemTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class GraphqlGreetingSystemTest {
1919

2020
testHelper.ensureNoErrors(response)
2121
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
22-
testHelper.doesTransactionContainSpanWithDescription(transaction, "Query.greeting")
22+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "graphql", "Query.greeting")
2323
}
2424
}
2525

@@ -32,7 +32,7 @@ class GraphqlGreetingSystemTest {
3232
error.message?.message?.startsWith("Unresolved RuntimeException for executionId ") ?: false
3333
}
3434
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
35-
testHelper.doesTransactionContainSpanWithDescription(transaction, "Query.greeting")
35+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "graphql", "Query.greeting")
3636
}
3737
}
3838
}

sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry-noagent/src/test/kotlin/io/sentry/systemtest/GraphqlProjectSystemTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class GraphqlProjectSystemTest {
2323
testHelper.ensureNoErrors(response)
2424
assertEquals("proj-slug", response?.data?.project?.slug)
2525
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
26-
testHelper.doesTransactionContainSpanWithDescription(transaction, "Query.project")
26+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "graphql", "Query.project")
2727
}
2828
}
2929

@@ -34,7 +34,7 @@ class GraphqlProjectSystemTest {
3434
testHelper.ensureNoErrors(response)
3535
assertNotNull(response?.data?.addProject)
3636
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
37-
testHelper.doesTransactionContainSpanWithDescription(transaction, "Mutation.addProject")
37+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "graphql", "Mutation.addProject")
3838
}
3939
}
4040

@@ -48,7 +48,7 @@ class GraphqlProjectSystemTest {
4848
error.message?.message?.startsWith("Unresolved RuntimeException for executionId ") ?: false
4949
}
5050
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
51-
testHelper.doesTransactionContainSpanWithDescription(transaction, "Mutation.addProject")
51+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "graphql", "Mutation.addProject")
5252
}
5353
}
5454
}

sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry-noagent/src/test/kotlin/io/sentry/systemtest/GraphqlTaskSystemTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class GraphqlTaskSystemTest {
3030
assertEquals("C3", firstTask.creator?.id)
3131

3232
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
33-
testHelper.doesTransactionContainSpanWithDescription(transaction, "Query.tasks")
33+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "graphql", "Query.tasks")
3434
}
3535
}
3636
}

sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry-noagent/src/test/kotlin/io/sentry/systemtest/PersonSystemTest.kt

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,58 @@ class PersonSystemTest {
4646

4747
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
4848
testHelper.doesTransactionContainSpanWithOp(transaction, "spanCreatedThroughOtelApi") &&
49-
testHelper.doesTransactionContainSpanWithOp(transaction, "spanCreatedThroughSentryApi")
49+
testHelper.doesTransactionContainSpanWithOp(transaction, "spanCreatedThroughSentryApi") &&
50+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "db", "insert into person (firstName, lastName) values (?, ?)")
51+
}
52+
}
53+
54+
@Test
55+
fun `create person creates transaction if no sampled flag in sentry-trace header`() {
56+
val restClient = testHelper.restClient
57+
val person = Person("firstA", "lastB")
58+
val returnedPerson =
59+
restClient.createPerson(
60+
person,
61+
mapOf(
62+
"sentry-trace" to "f9118105af4a2d42b4124532cd1065ff-424cffc8f94feeee",
63+
"baggage" to
64+
"sentry-public_key=502f25099c204a2fbf4cb16edc5975d1,sentry-sample_rate=1,sentry-trace_id=f9118105af4a2d42b4124532cd1065ff,sentry-transaction=HTTP%20GET",
65+
),
66+
)
67+
assertEquals(200, restClient.lastKnownStatusCode)
68+
69+
assertEquals(person.firstName, returnedPerson!!.firstName)
70+
assertEquals(person.lastName, returnedPerson!!.lastName)
71+
72+
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
73+
testHelper.doesTransactionContainSpanWithOp(transaction, "spanCreatedThroughOtelApi") &&
74+
testHelper.doesTransactionContainSpanWithOp(transaction, "spanCreatedThroughSentryApi") &&
75+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "db", "insert into person (firstName, lastName) values (?, ?)")
76+
}
77+
}
78+
79+
@Test
80+
fun `create person creates transaction if sampled true in sentry-trace header`() {
81+
val restClient = testHelper.restClient
82+
val person = Person("firstA", "lastB")
83+
val returnedPerson =
84+
restClient.createPerson(
85+
person,
86+
mapOf(
87+
"sentry-trace" to "f9118105af4a2d42b4124532cd1065ff-424cffc8f94feeee-1",
88+
"baggage" to
89+
"sentry-public_key=502f25099c204a2fbf4cb16edc5975d1,sentry-sample_rate=1,sentry-trace_id=f9118105af4a2d42b4124532cd1065ff,sentry-transaction=HTTP%20GET",
90+
),
91+
)
92+
assertEquals(200, restClient.lastKnownStatusCode)
93+
94+
assertEquals(person.firstName, returnedPerson!!.firstName)
95+
assertEquals(person.lastName, returnedPerson!!.lastName)
96+
97+
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
98+
testHelper.doesTransactionContainSpanWithOp(transaction, "spanCreatedThroughOtelApi") &&
99+
testHelper.doesTransactionContainSpanWithOp(transaction, "spanCreatedThroughSentryApi") &&
100+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "db", "insert into person (firstName, lastName) values (?, ?)")
50101
}
51102
}
52103
}

sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry-noagent/src/test/kotlin/io/sentry/systemtest/TodoSystemTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class TodoSystemTest {
2323
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
2424
testHelper.doesTransactionContainSpanWithOp(transaction, "todoSpanOtelApi") &&
2525
testHelper.doesTransactionContainSpanWithOp(transaction, "todoSpanSentryApi") &&
26-
testHelper.doesTransactionContainSpanWithOp(transaction, "http.client")
26+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "http.client", "GET https://jsonplaceholder.typicode.com/todos/1")
2727
}
2828
}
2929

@@ -34,7 +34,7 @@ class TodoSystemTest {
3434
assertEquals(200, restClient.lastKnownStatusCode)
3535

3636
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
37-
testHelper.doesTransactionContainSpanWithOp(transaction, "http.client")
37+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "http.client", "GET https://jsonplaceholder.typicode.com/todos/1")
3838
}
3939
}
4040

@@ -47,7 +47,7 @@ class TodoSystemTest {
4747
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
4848
testHelper.doesTransactionContainSpanWithOp(transaction, "todoRestClientSpanOtelApi") &&
4949
testHelper.doesTransactionContainSpanWithOp(transaction, "todoRestClientSpanSentryApi") &&
50-
testHelper.doesTransactionContainSpanWithOp(transaction, "http.client")
50+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "http.client", "GET https://jsonplaceholder.typicode.com/todos/1")
5151
}
5252
}
5353
}

sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry/src/test/kotlin/io/sentry/systemtest/GraphqlGreetingSystemTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class GraphqlGreetingSystemTest {
1919

2020
testHelper.ensureNoErrors(response)
2121
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
22-
testHelper.doesTransactionContainSpanWithOp(transaction, "query GreetingQuery")
22+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "query GreetingQuery", "query GreetingQuery")
2323
}
2424
}
2525

@@ -32,7 +32,7 @@ class GraphqlGreetingSystemTest {
3232
error.message?.message?.startsWith("Unresolved RuntimeException for executionId ") ?: false
3333
}
3434
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
35-
testHelper.doesTransactionContainSpanWithOp(transaction, "query GreetingQuery")
35+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "query GreetingQuery", "query GreetingQuery")
3636
}
3737
}
3838
}

sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry/src/test/kotlin/io/sentry/systemtest/GraphqlProjectSystemTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class GraphqlProjectSystemTest {
2323
testHelper.ensureNoErrors(response)
2424
assertEquals("proj-slug", response?.data?.project?.slug)
2525
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
26-
testHelper.doesTransactionContainSpanWithOp(transaction, "query ProjectQuery")
26+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "query ProjectQuery", "query ProjectQuery")
2727
}
2828
}
2929

@@ -34,7 +34,7 @@ class GraphqlProjectSystemTest {
3434
testHelper.ensureNoErrors(response)
3535
assertNotNull(response?.data?.addProject)
3636
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
37-
testHelper.doesTransactionContainSpanWithOp(transaction, "mutation AddProjectMutation")
37+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "mutation AddProjectMutation", "mutation AddProjectMutation")
3838
}
3939
}
4040

@@ -48,7 +48,7 @@ class GraphqlProjectSystemTest {
4848
error.message?.message?.startsWith("Unresolved RuntimeException for executionId ") ?: false
4949
}
5050
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
51-
testHelper.doesTransactionContainSpanWithOp(transaction, "mutation AddProjectMutation")
51+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "mutation AddProjectMutation", "mutation AddProjectMutation")
5252
}
5353
}
5454
}

sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry/src/test/kotlin/io/sentry/systemtest/GraphqlTaskSystemTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class GraphqlTaskSystemTest {
3030
assertEquals("C3", firstTask.creator?.id)
3131

3232
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
33-
testHelper.doesTransactionContainSpanWithOp(transaction, "query TasksAndAssigneesQuery")
33+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "query TasksAndAssigneesQuery", "query TasksAndAssigneesQuery")
3434
}
3535
}
3636
}

sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry/src/test/kotlin/io/sentry/systemtest/PersonSystemTest.kt

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,58 @@ class PersonSystemTest {
4646

4747
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
4848
testHelper.doesTransactionContainSpanWithOp(transaction, "spanCreatedThroughOtelApi") &&
49-
testHelper.doesTransactionContainSpanWithOp(transaction, "spanCreatedThroughSentryApi")
49+
testHelper.doesTransactionContainSpanWithOp(transaction, "spanCreatedThroughSentryApi") &&
50+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "db", "insert into person (firstName, lastName) values (?, ?)")
51+
}
52+
}
53+
54+
@Test
55+
fun `create person creates transaction if no sampled flag in sentry-trace header`() {
56+
val restClient = testHelper.restClient
57+
val person = Person("firstA", "lastB")
58+
val returnedPerson =
59+
restClient.createPerson(
60+
person,
61+
mapOf(
62+
"sentry-trace" to "f9118105af4a2d42b4124532cd1065ff-424cffc8f94feeee",
63+
"baggage" to
64+
"sentry-public_key=502f25099c204a2fbf4cb16edc5975d1,sentry-sample_rate=1,sentry-trace_id=f9118105af4a2d42b4124532cd1065ff,sentry-transaction=HTTP%20GET",
65+
),
66+
)
67+
assertEquals(200, restClient.lastKnownStatusCode)
68+
69+
assertEquals(person.firstName, returnedPerson!!.firstName)
70+
assertEquals(person.lastName, returnedPerson!!.lastName)
71+
72+
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
73+
testHelper.doesTransactionContainSpanWithOp(transaction, "spanCreatedThroughOtelApi") &&
74+
testHelper.doesTransactionContainSpanWithOp(transaction, "spanCreatedThroughSentryApi") &&
75+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "db", "insert into person (firstName, lastName) values (?, ?)")
76+
}
77+
}
78+
79+
@Test
80+
fun `create person creates transaction if sampled true in sentry-trace header`() {
81+
val restClient = testHelper.restClient
82+
val person = Person("firstA", "lastB")
83+
val returnedPerson =
84+
restClient.createPerson(
85+
person,
86+
mapOf(
87+
"sentry-trace" to "f9118105af4a2d42b4124532cd1065ff-424cffc8f94feeee-1",
88+
"baggage" to
89+
"sentry-public_key=502f25099c204a2fbf4cb16edc5975d1,sentry-sample_rate=1,sentry-trace_id=f9118105af4a2d42b4124532cd1065ff,sentry-transaction=HTTP%20GET",
90+
),
91+
)
92+
assertEquals(200, restClient.lastKnownStatusCode)
93+
94+
assertEquals(person.firstName, returnedPerson!!.firstName)
95+
assertEquals(person.lastName, returnedPerson!!.lastName)
96+
97+
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
98+
testHelper.doesTransactionContainSpanWithOp(transaction, "spanCreatedThroughOtelApi") &&
99+
testHelper.doesTransactionContainSpanWithOp(transaction, "spanCreatedThroughSentryApi") &&
100+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "db", "insert into person (firstName, lastName) values (?, ?)")
50101
}
51102
}
52103
}

sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry/src/test/kotlin/io/sentry/systemtest/TodoSystemTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class TodoSystemTest {
2323
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
2424
testHelper.doesTransactionContainSpanWithOp(transaction, "todoSpanOtelApi") &&
2525
testHelper.doesTransactionContainSpanWithOp(transaction, "todoSpanSentryApi") &&
26-
testHelper.doesTransactionContainSpanWithOp(transaction, "http.client")
26+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "http.client", "GET https://jsonplaceholder.typicode.com/todos/1")
2727
}
2828
}
2929

@@ -34,7 +34,7 @@ class TodoSystemTest {
3434
assertEquals(200, restClient.lastKnownStatusCode)
3535

3636
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
37-
testHelper.doesTransactionContainSpanWithOp(transaction, "http.client")
37+
testHelper.doesTransactionContainSpanWithOpAndDescription(transaction, "http.client", "GET https://jsonplaceholder.typicode.com/todos/1")
3838
}
3939
}
4040

0 commit comments

Comments
 (0)