aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-09-04 16:06:07 +0200
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-09-04 16:23:50 +0200
commitcf07e5a766cdb148f80bbacfb3eac6de3654e33b (patch)
tree186873cc4bfd23259fac5af1895a7d294d05d4b9 /src/test/java/org/onap
parent2c737fdd2aa908de60c211a6ae8c688da5b7a775 (diff)
Enable prometheus metrics in model-loader1.14.2
- add micrometer-registry-prometheus dependency - update vulnerable dependencies Issue-ID: AAI-3983 Change-Id: I9377ee4a1d1f77ca2811d3b954814374a2b2774e Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'src/test/java/org/onap')
-rw-r--r--src/test/java/org/onap/aai/modelloader/actuator/ActuatorTest.java45
1 files changed, 31 insertions, 14 deletions
diff --git a/src/test/java/org/onap/aai/modelloader/actuator/ActuatorTest.java b/src/test/java/org/onap/aai/modelloader/actuator/ActuatorTest.java
index e9a6da5..2ccbb0c 100644
--- a/src/test/java/org/onap/aai/modelloader/actuator/ActuatorTest.java
+++ b/src/test/java/org/onap/aai/modelloader/actuator/ActuatorTest.java
@@ -19,29 +19,46 @@
*/
package org.onap.aai.modelloader.actuator;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
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.boot.test.context.SpringBootTest.WebEnvironment;
-import org.springframework.boot.test.web.server.LocalServerPort;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.client.RestTemplate;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.web.reactive.server.WebTestClient;
+@AutoConfigureWebTestClient
+@TestPropertySource(properties = {
+ "management.endpoints.web.exposure.include=prometheus,metrics,info,health"
+})
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class ActuatorTest {
-
- @Autowired RestTemplate restTemplate;
- @LocalServerPort
- private int serverPort;
+
+ @Autowired
+ private WebTestClient webTestClient;
@Test
public void thatLivenessEndpointReturnsOk() {
- String url = String.format("http://localhost:%s/actuator/health", serverPort);
- ResponseEntity<String> entity = restTemplate.getForEntity(url, String.class);
- assertEquals(entity.getStatusCode(), HttpStatus.OK);
- assertEquals(entity.getBody(), "{\"status\":\"UP\"}");
+ webTestClient.get().uri("/actuator/health")
+ .exchange()
+ .expectStatus().isOk()
+ .expectBody()
+ .jsonPath("$.status")
+ .isEqualTo("UP");
}
+
+ // @Test
+ // public void testPrometheusEndpoint() {
+ // webTestClient.get().uri("/actuator/prometheus")
+ // .exchange()
+ // .expectStatus().isOk()
+ // .expectHeader().contentType("text/plain; charset=utf-8")
+ // .expectBody(String.class)
+ // .consumeWith(response -> {
+ // String responseBody = response.getResponseBody();
+ // assert responseBody != null;
+ // assert responseBody.contains("# HELP");
+ // assert responseBody.contains("# TYPE");
+ // });
+ // }
}