@@ -7,19 +7,48 @@ import spock.lang.Specification
7
7
8
8
class EndpointPeriodicActionTest extends Specification {
9
9
10
- void ' test that common metrics are joined before being sent to telemetry #iterationIndex ' () {
10
+ void ' test that endpoints are captured by the periodic action ' () {
11
11
given :
12
12
final endpoint = new Endpoint (). first(true ). type(' REST' ). method(" GET" ). operation(' http.request' ). path(" /test" )
13
13
final service = Mock (TelemetryService )
14
- final endpointCollector = Mock (EndpointCollector )
14
+ final endpointCollector = new EndpointCollector ()
15
+ endpointCollector. supplier([endpoint]. iterator())
15
16
final action = new EndpointPeriodicAction (endpointCollector)
16
17
17
18
when :
18
19
action. doIteration(service)
19
20
20
21
then :
21
- 1 * endpointCollector. drain() >> [endpoint]. iterator()
22
22
1 * service. addEndpoint(endpoint)
23
23
0 * _
24
24
}
25
+
26
+ void ' test that endpoints are not lost if the service is at capacity' () {
27
+ given :
28
+ final endpoints = [
29
+ new Endpoint (). first(true ). type(' REST' ). method(" GET" ). operation(' http.request' ). path(" /test1" ),
30
+ new Endpoint (). type(' REST' ). method(" GET" ). operation(' http.request' ). path(" /test2" ),
31
+ new Endpoint (). type(' REST' ). method(" GET" ). operation(' http.request' ). path(" /test3" ),
32
+ ]
33
+ final service = Mock (TelemetryService )
34
+ final endpointCollector = new EndpointCollector ()
35
+ endpointCollector. supplier(endpoints. iterator())
36
+ final action = new EndpointPeriodicAction (endpointCollector)
37
+
38
+ when :
39
+ action. doIteration(service)
40
+
41
+ then :
42
+ 1 * service. addEndpoint(endpoints[0 ]) >> true
43
+ 1 * service. addEndpoint(endpoints[1 ]) >> false
44
+ 0 * _
45
+
46
+ when :
47
+ action. doIteration(service)
48
+
49
+ then :
50
+ 1 * service. addEndpoint(endpoints[1 ]) >> true
51
+ 1 * service. addEndpoint(endpoints[2 ]) >> true
52
+ 0 * _
53
+ }
25
54
}
0 commit comments