1
1
package de .sldk .mc .exporter ;
2
2
3
3
4
- import static org .assertj .core .api .Assertions .assertThat ;
5
-
6
4
import de .sldk .mc .MetricsServer ;
7
5
import de .sldk .mc .PrometheusExporter ;
6
+ import de .sldk .mc .health .ConcurrentHealthChecks ;
8
7
import io .prometheus .client .CollectorRegistry ;
9
8
import io .prometheus .client .Counter ;
10
9
import io .prometheus .client .exporter .common .TextFormat ;
21
20
import java .io .IOException ;
22
21
import java .net .ServerSocket ;
23
22
23
+ import static org .assertj .core .api .Assertions .assertThat ;
24
+
24
25
@ ExtendWith (MockitoExtension .class )
25
26
public class PrometheusExporterTest {
26
27
@@ -34,7 +35,9 @@ public class PrometheusExporterTest {
34
35
void setup () throws Exception {
35
36
CollectorRegistry .defaultRegistry .clear ();
36
37
metricsServerPort = getRandomFreePort ();
37
- metricsServer = new MetricsServer ("localhost" , metricsServerPort , exporterMock );
38
+ metricsServer = new MetricsServer (
39
+ "localhost" , metricsServerPort , exporterMock , ConcurrentHealthChecks .create ()
40
+ );
38
41
metricsServer .start ();
39
42
}
40
43
@@ -83,4 +86,14 @@ void metrics_server_should_return_404_on_unknown_paths() {
83
86
.statusCode (HttpStatus .NOT_FOUND_404 );
84
87
}
85
88
89
+ @ Test
90
+ void metrics_server_should_return_200_on_health_check () {
91
+ String requestPath = URIUtil .newURI ("http" , "localhost" , metricsServerPort , "/health" , null );
92
+
93
+ RestAssured .when ()
94
+ .get (requestPath )
95
+ .then ()
96
+ .statusCode (HttpStatus .OK_200 );
97
+ }
98
+
86
99
}
0 commit comments