From 0abbf5c36e027b2cd5cb2beccda88dedeb042441 Mon Sep 17 00:00:00 2001 From: Ljupcho Palashevski Date: Fri, 20 Oct 2023 10:41:00 +0200 Subject: [PATCH] Remove actuator unit-test. Signed-off-by: Ljupcho Palashevski --- .../server-chassis-spring/build.gradle | 2 - .../actuator/ActuatorEndpointsTest.java | 100 ----------- .../resources/application-test.properties | 157 +----------------- 3 files changed, 1 insertion(+), 258 deletions(-) delete mode 100644 open-metadata-implementation/server-chassis/server-chassis-spring/src/test/java/org/odpi/openmetadata/serverchassis/springboot/actuator/ActuatorEndpointsTest.java diff --git a/open-metadata-implementation/server-chassis/server-chassis-spring/build.gradle b/open-metadata-implementation/server-chassis/server-chassis-spring/build.gradle index dc99453e82d..57ab4a20125 100644 --- a/open-metadata-implementation/server-chassis/server-chassis-spring/build.gradle +++ b/open-metadata-implementation/server-chassis/server-chassis-spring/build.gradle @@ -106,8 +106,6 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter-api' testImplementation 'org.springframework.boot:spring-boot-test' testImplementation 'org.springframework.boot:spring-boot-starter-test' - testImplementation 'com.vaadin.external.google:android-json:0.0.20131108.vaadin1' - testImplementation 'org.junit.jupiter:junit-jupiter-params' testImplementation 'org.springframework:spring-test' } diff --git a/open-metadata-implementation/server-chassis/server-chassis-spring/src/test/java/org/odpi/openmetadata/serverchassis/springboot/actuator/ActuatorEndpointsTest.java b/open-metadata-implementation/server-chassis/server-chassis-spring/src/test/java/org/odpi/openmetadata/serverchassis/springboot/actuator/ActuatorEndpointsTest.java deleted file mode 100644 index 6a9ee27787b..00000000000 --- a/open-metadata-implementation/server-chassis/server-chassis-spring/src/test/java/org/odpi/openmetadata/serverchassis/springboot/actuator/ActuatorEndpointsTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -/* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.serverchassis.springboot.actuator; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; -import org.odpi.openmetadata.serverchassis.springboot.OMAGServer; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.web.server.LocalManagementPort; -import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatusCode; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.TestPropertySource; -import org.springframework.web.client.HttpClientErrorException; - -import static org.junit.jupiter.api.Assertions.*; - -@SpringBootTest( - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - classes = { - OMAGServer.class - }) -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -@TestPropertySource(properties = "spring.config.additional-location=classpath:application-test.properties") -public class ActuatorEndpointsTest { - public static final String URL = "http://localhost:"; - public static final String MANAGMENT_CONTEXT_PATH = "/observability/actuator"; - - @Autowired - RestTemplateBuilder restTemplateBuilder; - - @LocalManagementPort - int managementPort; - - @Test - public void testMetricsActuator() throws JSONException { - - ResponseEntity response = restTemplateBuilder - .rootUri(URL + managementPort + MANAGMENT_CONTEXT_PATH) - .build().exchange("/metrics", HttpMethod.GET, new HttpEntity<>(null), String.class); - - assertInstanceOf(ResponseEntity.class, response); - assertEquals(HttpStatusCode.valueOf(200), response.getStatusCode()); - - JSONObject body = new JSONObject(response.getBody()); - assertNotNull(body); - - JSONArray metricsNamesArray = (JSONArray) body.get("names"); - assertEquals(49, metricsNamesArray.length()); - - } - - @ParameterizedTest - @ValueSource(strings = { - "/metrics/application.started.time", - "/metrics/application.ready.time", - "/health"}) - public void testMetricsActuatorCustomisableHealthEndpoint(String args) throws JSONException { - - ResponseEntity response = restTemplateBuilder - .rootUri(URL + managementPort + MANAGMENT_CONTEXT_PATH) - .build().exchange(args, HttpMethod.GET, new HttpEntity<>(null), String.class); - - assertInstanceOf(ResponseEntity.class, response); - assertEquals(HttpStatusCode.valueOf(200), response.getStatusCode()); - - JSONObject body = new JSONObject(response.getBody()); - assertNotNull(body); - - } - - @Test - public void testMetricsActuatorBeans() throws JSONException { - - assertThrows(HttpClientErrorException.class, () -> { - restTemplateBuilder - .rootUri(URL + managementPort + MANAGMENT_CONTEXT_PATH) - .build().exchange("/beans", HttpMethod.GET, new HttpEntity<>(null), String.class); - }); - } - - @Test - public void testMetricsActuatorContexts() throws JSONException { - - assertThrows(HttpClientErrorException.class, () -> { - restTemplateBuilder - .rootUri(URL + managementPort + MANAGMENT_CONTEXT_PATH) - .build().exchange("/contexts", HttpMethod.GET, new HttpEntity<>(null), String.class); - }); - } - -} diff --git a/open-metadata-implementation/server-chassis/server-chassis-spring/src/test/resources/application-test.properties b/open-metadata-implementation/server-chassis/server-chassis-spring/src/test/resources/application-test.properties index 3fb1a269448..815a72fbdea 100644 --- a/open-metadata-implementation/server-chassis/server-chassis-spring/src/test/resources/application-test.properties +++ b/open-metadata-implementation/server-chassis/server-chassis-spring/src/test/resources/application-test.properties @@ -1,159 +1,4 @@ # SPDX-License-Identifier: Apache-2.0 # Copyright Contributors to the ODPi Egeria project. -omag.server-config-file=classpath:samples/metadata-repository-server.json -server.port=8001 -server.servlet.context-path=/actuator - -security.basic.enable: false -security.ignored=/** - - -################################################ -### startup servers configuration -################################################ -scan.packages=com.org.odpi.openmetadata.* -#userId used to startup the list of configured servers default is 'system' -startup.user=system -# Comma separated names of servers to be started -startup.server.list= -# Comma separated values of http headers to be added to ThreadLocal -header.name.list= - -################################################ -# PROFILES -################################################ -spring.profiles.active=local,mutual - -################################################ -# APPLICATION SETTINGS (SpringApplication) -################################################ -#spring.main.sources= -spring.banner.location=classpath:banner.txt -spring.output.ansi.enabled=always -#spring.main....= # see class for all properties - -################################################ -# LOGGING -################################################ -logging.level.root=debug -logging.level.org.odpi.openmetadata.frameworks.auditlog=INFO -logging.level.org.odpi.openmetadata.repositoryservices=info - -logging.level.org.odpi.openmetadata.server=debug -logging.level.org.springframework.web=info - -#logging.file.path=/var/logs -#logging.file.name=egeria.log -#logging.level.*=INFO - -logging.level.org.springframework=error -#logging.level.org.odpi.openmetadata.commonservices=DEBUG -#logging.level.org.odpi.openmetadata.accessservices.subjectarea.handlers=DEBUG -logging.level.org.springframework.boot.web.embedded.tomcat=INFO -logging.level.org.odpi.openmetadata.serverchassis.springboot=INFO - - -# OPEN_API -#springdoc.packagesToScan=package1, package2 -#springdoc.pathsToMatch=/v1, /api/balance/** - -################################################ -### Swagger Docs -################################################ -springdoc.version='@springdoc.version@' -springdoc.api-docs.enabled=true -springdoc.api-docs.path=/v3/api-docs -springdoc.swagger-ui.path=/swagger-ui.html -springdoc.swagger-ui.displayRequestDuration=true -springdoc.swagger-ui.tagsSorter=alpha -springdoc.swagger-ui.operationsSorter=alpha -springdoc.swagger-ui.docExpansion=none - -# ---------------------------------------- -# ACTUATOR PROPERTIES -# ---------------------------------------- - -# MANAGEMENT HTTP SERVER (ManagementServerProperties) -management.server.port=8001 -springdoc.use-management-port=true -management.server.base-path=/observability - -management.server.ssl.enabled=false - -management.endpoints.enabled-by-default=true -#management.endpoints.web.path-mapping.health=egeria.chasis.health # if health endpoint would be customized -management.add-application-context-header=true - -#management.endpoint.info.enabled=true - -#management.endpoints.web.exposure.include= health, openapi, swaggerui -#management.endpoints.web.base-path=/myapp - -### BLACKLISTING -#management.endpoints.web.exposure.include=* -#management.endpoints.web.exposure.exclude=threaddump - -### WHITELISTING -management.endpoints.web.exposure.include=metrics,health,probes -management.endpoint.health.show-details=always -management.endpoints.health.probes.enabled=true - -management.endpoints.web.discovery.enabled=true - -#management.endpoint.health.group.custom.show-components=always -#management.endpoint.health.group.custom.show-details=always -#management.endpoint.health.group.custom.include=diskSpace,ping - -management.health.cassandra.enabled=false - -#management.endpoints.jmx.exposure.include=health,info -#management.endpoints.web.exposure.exclude=env,beans - -# ENDPOINTS (AbstractEndpoint subclasses) -#endpoints.autoconfig.id=autoconfig -#endpoints.autoconfig.sensitive=true -#endpoints.autoconfig.enabled=true -#endpoints.beans.id=beans -#endpoints.beans.sensitive=true -#endpoints.beans.enabled=true -#endpoints.configprops.id=configprops -#endpoints.configprops.sensitive=true -#endpoints.configprops.enabled=true -#endpoints.configprops.keys-to-sanitize=password,secret -#endpoints.dump.id=dump -#endpoints.dump.sensitive=true -#endpoints.dump.enabled=true -#endpoints.env.id=env -#endpoints.env.sensitive=true -#endpoints.env.enabled=true -#endpoints.health.id=health -#endpoints.health.sensitive=false -#endpoints.health.enabled=true -#endpoints.info.id=info -#endpoints.info.sensitive=false -#endpoints.info.enabled=true -#endpoints.metrics.id=metrics -#endpoints.metrics.sensitive=true -#endpoints.metrics.enabled=true -#endpoints.shutdown.id=shutdown -#endpoints.shutdown.sensitive=true -#endpoints.shutdown.enabled=false -#endpoints.trace.id=trace -#endpoints.trace.sensitive=true -#endpoints.trace.enabled=true - -# For Exemplars to work we need histogram buckets -management.metrics.distribution.percentiles-histogram.http.server.requests=true - -################################################ -### Problem details -################################################ -spring.mvc.problemdetails.enabled=true - -################################################ -### Instancio -################################################ -implementation 'org.instancio:instancio-core:2.7.0' - -testImplementation 'org.instancio:instancio-junit:2.16.0' +omag.server-config-file=classpath:samples/metadata-repository-server.json \ No newline at end of file