forked from beltram/spring-test-sleuth-reproducer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TracingResourceTest.kt
73 lines (67 loc) · 2.63 KB
/
TracingResourceTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package com.spring.reproducer.spring.test.sleuth.reproducer
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.web.reactive.server.WebTestClient
import org.springframework.test.web.reactive.server.expectBody
@SpringBootTest
@AutoConfigureWebTestClient
internal class TracingResourceTest(@Autowired private val webTestClient: WebTestClient) {
@Test
fun `should retrieve span id`() {
val spanId = "a2fb4a1d1a96d312"
webTestClient.get()
.uri("/api/tracing/spanId")
.header("X-B3-TraceId", "463ac35c9f6413ad48485a3953bb6124")
.header("X-B3-SpanId", spanId)
.header("X-B3-ParentSpanId", "0020000000000001")
.header("X-B3-Flags", "1")
.exchange()
.expectStatus().isOk
.expectBody<String>()
.isEqualTo(spanId)
}
@Test
fun `should retrieve parent id`() {
val parentId = "0020000000000001"
webTestClient.get()
.uri("/api/tracing/parentId")
.header("X-B3-TraceId", "463ac35c9f6413ad48485a3953bb6124")
.header("X-B3-SpanId", "a2fb4a1d1a96d312")
.header("X-B3-ParentSpanId", parentId)
.header("X-B3-Flags", "1")
.exchange()
.expectStatus().isOk
.expectBody<String>()
.isEqualTo(parentId)
}
@Test
fun `should retrieve span id with CurrentTraceContext`() {
val spanId = "a2fb4a1d1a96d312"
webTestClient.get()
.uri("/api/tracing/currentSpanId")
.header("X-B3-TraceId", "463ac35c9f6413ad48485a3953bb6124")
.header("X-B3-SpanId", spanId)
.header("X-B3-ParentSpanId", "0020000000000001")
.header("X-B3-Flags", "1")
.exchange()
.expectStatus().isOk
.expectBody<String>()
.isEqualTo(spanId)
}
@Test
fun `should retrieve parent id with CurrentTraceContext`() {
val parentId = "0020000000000001"
webTestClient.get()
.uri("/api/tracing/currentParentId")
.header("X-B3-TraceId", "463ac35c9f6413ad48485a3953bb6124")
.header("X-B3-SpanId", "a2fb4a1d1a96d312")
.header("X-B3-ParentSpanId", parentId)
.header("X-B3-Flags", "1")
.exchange()
.expectStatus().isOk
.expectBody<String>()
.isEqualTo(parentId)
}
}