aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2019-11-07 15:06:03 +0000
committerGerrit Code Review <gerrit@onap.org>2019-11-07 15:06:03 +0000
commit9e374a0b49cdfd3594a32ff062e210765cad14ea (patch)
treec10cc6803dab6536ee6b3d64c41e40f99358c115 /ms/blueprintsprocessor
parent59d3681b80e9b5f9e69b4492138ab1f056a0351d (diff)
parent843d1f7ec7c45e3aad1d5198b776bb99a235448d (diff)
Merge "Update on Health-api"
Diffstat (limited to 'ms/blueprintsprocessor')
-rwxr-xr-xms/blueprintsprocessor/application/pom.xml11
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/actuator/indicator/BluePrintCustomIndicator.kt47
-rwxr-xr-xms/blueprintsprocessor/application/src/main/resources/application.properties23
-rw-r--r--ms/blueprintsprocessor/application/src/test/resources/application-test.properties14
-rw-r--r--ms/blueprintsprocessor/application/src/test/resources/application.properties4
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/.gitignore31
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/pom.xml51
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/BasicAuthRestClientServiceConfiguration.kt (renamed from ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/BasicAuthRestClientServiceConfiguration.kt)7
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/HealthCheckProperties.kt92
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/SecurityEncryptionConfiguration.kt63
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ActuatorCheckResponse.kt19
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ActuatorEndpointType.kt21
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ApplicationHealth.kt25
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthApiResponse.kt23
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthCheckStatus.kt22
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/Metrics.kt22
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/MetricsInfo.kt19
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/MetricsResponse.kt21
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceEndpoint.kt19
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceName.kt21
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServicesCheckResponse.kt22
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/WebClientEnpointResponse.kt22
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/EndPointExecution.kt70
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/AbstractHealthCheck.kt74
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/BluePrintProcessorHealthCheck.kt38
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/SDCListenerHealthCheck.kt46
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.kt167
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/SecurityConfigurationTest.kt34
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/resources/application-test.properties29
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/resources/logback.xml35
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker1
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/.gitignore31
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/pom.xml4
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedHealth.kt (renamed from ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/HealthCheckController.kt)26
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedMetrics.kt52
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthApiResponse.kt6
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthCheckResponse.kt6
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthCheckStatus.kt6
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceEndpoint.kt5
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedHealthService.kt58
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedMetricsService.kt72
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/HealthCheckService.kt91
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/utils/ObjectMappingUtils.kt13
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/main/resources/application.properties5
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckApplicationTests.kt25
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.java136
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/test/resources/application-test.properties25
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/health-api/src/test/resources/logback.xml30
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/pom.xml14
49 files changed, 1378 insertions, 320 deletions
diff --git a/ms/blueprintsprocessor/application/pom.xml b/ms/blueprintsprocessor/application/pom.xml
index 0ee6ac339..dc0e49fd7 100755
--- a/ms/blueprintsprocessor/application/pom.xml
+++ b/ms/blueprintsprocessor/application/pom.xml
@@ -84,12 +84,16 @@
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>configs-api</artifactId>
</dependency>
- <!--
- <dependency>
+ <dependency>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
<artifactId>health-api</artifactId>
+ <version>0.7.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
+ <artifactId>health-api-common</artifactId>
+ <version>0.7.0-SNAPSHOT</version>
</dependency>
- -->
<!-- Functions -->
<dependency>
@@ -180,6 +184,7 @@
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
+
</dependencies>
<build>
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/actuator/indicator/BluePrintCustomIndicator.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/actuator/indicator/BluePrintCustomIndicator.kt
new file mode 100644
index 000000000..66a19b2c5
--- /dev/null
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/actuator/indicator/BluePrintCustomIndicator.kt
@@ -0,0 +1,47 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.actuator.indicator
+
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthApiResponse
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthCheckStatus
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.health.BluePrintProcessorHealthCheck
+import org.springframework.boot.actuate.health.AbstractHealthIndicator
+import org.springframework.boot.actuate.health.Health
+import org.springframework.stereotype.Component
+
+/**
+ * Health Indicator for BluePrintProcessor.
+ * @author Shaaban Ebrahim
+ * @version 1.0
+ */
+@Component
+open class BluePrintCustomIndicator(private val bluePrintProcessorHealthCheck: BluePrintProcessorHealthCheck)
+ : AbstractHealthIndicator() {
+
+ @Throws(Exception::class)
+ override fun doHealthCheck(builder: Health.Builder) {
+ var result: HealthApiResponse? = bluePrintProcessorHealthCheck!!.retrieveEndpointExecutionStatus()
+ if (result?.status == HealthCheckStatus.UP) {
+ builder.up()
+ } else {
+ builder.down()
+ }
+ builder.withDetail("Services", result?.checks)
+ }
+
+
+}
diff --git a/ms/blueprintsprocessor/application/src/main/resources/application.properties b/ms/blueprintsprocessor/application/src/main/resources/application.properties
index b8f0d2344..6708dcf69 100755
--- a/ms/blueprintsprocessor/application/src/main/resources/application.properties
+++ b/ms/blueprintsprocessor/application/src/main/resources/application.properties
@@ -107,4 +107,25 @@ blueprintsprocessor.messageconsumer.self-service-api.pollMillSec=1000
blueprintsprocessor.messageproducer.self-service-api.type=kafka-basic-auth
blueprintsprocessor.messageproducer.self-service-api.bootstrapServers=127.0.0.1:9092
blueprintsprocessor.messageproducer.self-service-api.clientId=default-client-id
-blueprintsprocessor.messageproducer.self-service-api.topic=producer.t \ No newline at end of file
+blueprintsprocessor.messageproducer.self-service-api.topic=producer.t
+
+
+blueprintprocessor.remoteScriptCommand.enabled=true
+
+#Encrypted username and password for health check service
+endpoints.user.name=eHbVUbJAj4AG2522cSbrOQ==
+endpoints.user.password=eHbVUbJAj4AG2522cSbrOQ==
+
+#BaseUrls for health check blueprint processor services
+blueprintprocessor.healthcheck.baseUrl=http://localhost:8080/
+blueprintprocessor.healthcheck.mapping-service-name-with-service-link=[Execution service,/api/v1/execution-service/health-check],[Resources service,/api/v1/resources/health-check],[Template service,/api/v1/template/health-check]
+
+#BaseUrls for health check Cds Listener services
+cdslistener.healthcheck.baseUrl=http://cds-sdc-listener:8080/
+cdslistener.healthcheck.mapping-service-name-with-service-link=[SDC Listener service,/api/v1/sdclistener/healthcheck]
+
+#Actuator properties
+management.endpoints.web.exposure.include=*
+management.endpoint.health.show-details=always
+
+
diff --git a/ms/blueprintsprocessor/application/src/test/resources/application-test.properties b/ms/blueprintsprocessor/application/src/test/resources/application-test.properties
index 0f3457454..1d2565be3 100644
--- a/ms/blueprintsprocessor/application/src/test/resources/application-test.properties
+++ b/ms/blueprintsprocessor/application/src/test/resources/application-test.properties
@@ -48,3 +48,17 @@ blueprintsprocessor.cliExecutor.enabled=true
blueprintsprocessor.netconfExecutor.enabled=true
blueprintsprocessor.restconfEnabled=true
+
+
+#Encrypted username and password for health check service
+endpoints.user.name=eHbVUbJAj4AG2522cSbrOQ==
+endpoints.user.password=eHbVUbJAj4AG2522cSbrOQ==
+
+#BaseUrls for health check blueprint processor services
+blueprintprocessor.healthcheck.baseUrl=http://localhost:8080/
+blueprintprocessor.healthcheck.mapping-service-name-with-service-link=[Execution service,/api/v1/execution-service/health-check],[Resources service,/api/v1/resources/health-check],[Template service,/api/v1/template/health-check]
+
+#BaseUrls for health check Cds Listener services
+cdslistener.healthcheck.baseUrl=http://cds-sdc-listener:8080/
+cdslistener.healthcheck.mapping-service-name-with-service-link=[SDC Listener service,/api/v1/sdclistener/healthcheck]
+
diff --git a/ms/blueprintsprocessor/application/src/test/resources/application.properties b/ms/blueprintsprocessor/application/src/test/resources/application.properties
index 92d54f6f5..ea14c493a 100644
--- a/ms/blueprintsprocessor/application/src/test/resources/application.properties
+++ b/ms/blueprintsprocessor/application/src/test/resources/application.properties
@@ -79,5 +79,5 @@ blueprintsprocessor.messageclient.self-service-api.clientId=default-client-id
blueprintsprocessor.messageclient.self-service-api.kafkaEnable=false
-endpoints.user.name=ccsdkapps
-endpoints.user.password=ccsdkapps
+endpoints.user.name=eHbVUbJAj4AG2522cSbrOQ==
+endpoints.user.password=eHbVUbJAj4AG2522cSbrOQ==
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/.gitignore b/ms/blueprintsprocessor/modules/inbounds/health-api-common/.gitignore
new file mode 100644
index 000000000..a2a3040aa
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/.gitignore
@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/pom.xml b/ms/blueprintsprocessor/modules/inbounds/health-api-common/pom.xml
new file mode 100644
index 000000000..2bd6782a7
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/pom.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright © 2019-2020 Orange.
+
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
+ <artifactId>inbounds</artifactId>
+ <version>0.7.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>health-api-common</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Blueprints Processor Health API common </name>
+ <description>checking system check health endpoints</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
+ <artifactId>rest-lib</artifactId>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-actuator</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/BasicAuthRestClientServiceConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/BasicAuthRestClientServiceConfiguration.kt
index 0a97d37c5..0c6099a1a 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/BasicAuthRestClientServiceConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/BasicAuthRestClientServiceConfiguration.kt
@@ -25,7 +25,7 @@ import org.springframework.context.annotation.PropertySource
@Configuration
@PropertySource("classpath:application.properties")
-open class BasicAuthRestClientServiceConfiguration {
+open class BasicAuthRestClientServiceConfiguration(private val securityConfiguration: SecurityEncryptionConfiguration) {
@Value("\${endpoints.user.name}")
private val username: String? = null
@@ -36,8 +36,8 @@ open class BasicAuthRestClientServiceConfiguration {
@Bean
open fun getBasicAuthRestClientProperties(): BasicAuthRestClientProperties {
val basicAuthRestClientProperties = BasicAuthRestClientProperties()
- basicAuthRestClientProperties.username = username.toString()
- basicAuthRestClientProperties.password = password.toString()
+ basicAuthRestClientProperties.username = securityConfiguration.decrypt(username!!)!!
+ basicAuthRestClientProperties.password = securityConfiguration.decrypt(password!!)!!
return basicAuthRestClientProperties
}
@@ -46,5 +46,4 @@ open class BasicAuthRestClientServiceConfiguration {
return BasicAuthRestClientService(getBasicAuthRestClientProperties())
}
-
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/HealthCheckProperties.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/HealthCheckProperties.kt
new file mode 100644
index 000000000..c63952d80
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/HealthCheckProperties.kt
@@ -0,0 +1,92 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.configuration
+
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServiceEndpoint
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServiceName
+import org.springframework.beans.factory.annotation.Value
+import org.springframework.context.annotation.Configuration
+import org.springframework.context.annotation.PropertySource
+
+@Configuration
+@PropertySource("classpath:application.properties")
+open class HealthCheckProperties {
+
+ @Value("\${blueprintprocessor.healthcheck.baseUrl}")
+ private val bluePrintProcessorBaseURL: String? = null
+
+ @Value("#{'\${blueprintprocessor.healthcheck.mapping-service-name-with-service-link}'.split(']')}")
+ private val blueprintprocessorServiceMapping: List<String>? = null
+
+ @Value("\${cdslistener.healthcheck.baseUrl}")
+ private val cdsListenerBaseURL: String? = null
+
+ @Value("#{'\${cdslistener.healthcheck.mapping-service-name-with-service-link}'.split(']')}")
+ private val cdsListenerServiceMapping: List<String>? = null
+
+ open fun getBluePrintBaseURL(): String? {
+ return bluePrintProcessorBaseURL
+ }
+
+ open fun getCDSListenerBaseURL(): String? {
+ return cdsListenerBaseURL
+ }
+
+ open fun getBluePrintServiceInformation(): List<ServiceEndpoint> {
+ val serviceName = ServiceName.BLUEPRINT
+ return getListOfServiceEndPoints(blueprintprocessorServiceMapping, serviceName)
+ }
+
+ open fun getCDSListenerServiceInformation(): List<ServiceEndpoint> {
+ val serviceName = ServiceName.BLUEPRINT
+ return getListOfServiceEndPoints(cdsListenerServiceMapping, serviceName)
+
+ }
+
+ private fun getListOfServiceEndPoints(serviceMapping: List<String>?, serviceName: ServiceName): MutableList<ServiceEndpoint> {
+ val serviceEndpoints = mutableListOf<ServiceEndpoint>()
+ if (serviceMapping != null) {
+ for (element in serviceMapping) {
+ fillListOfService(serviceName, element, serviceEndpoints)
+ }
+ }
+ return serviceEndpoints
+ }
+
+ private fun fillListOfService(serviceName: ServiceName , element: String, listOfCDSListenerServiceEndpoint: MutableList<ServiceEndpoint>) {
+ val serviceEndpointInfo = element.split(",/")
+ val serviceEndpoint = getServiceEndpoint(serviceEndpointInfo)
+ if (serviceName.equals(ServiceName.CDSLISTENER))
+ serviceEndpoint.serviceLink = cdsListenerBaseURL + serviceEndpoint.serviceLink
+ else if (serviceName.equals(ServiceName.BLUEPRINT))
+ serviceEndpoint.serviceLink = bluePrintProcessorBaseURL + serviceEndpoint.serviceLink
+ listOfCDSListenerServiceEndpoint.add(serviceEndpoint)
+ }
+
+
+ private fun getServiceEndpoint(serviceEndpointInfo: List<String>): ServiceEndpoint {
+ return ServiceEndpoint(removeSpecialCharacter(serviceEndpointInfo.get(0))
+ , removeSpecialCharacter(serviceEndpointInfo.get(1))
+ )
+ }
+
+ private fun removeSpecialCharacter(value:String):String{
+ return value.replaceFirst(",[","")
+ .replace("[","")
+ .replace("]","")
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/SecurityEncryptionConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/SecurityEncryptionConfiguration.kt
new file mode 100644
index 000000000..94021207a
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/SecurityEncryptionConfiguration.kt
@@ -0,0 +1,63 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.configuration
+
+
+import org.apache.commons.net.util.Base64
+import org.springframework.stereotype.Component
+import org.springframework.stereotype.Service
+import javax.crypto.Cipher
+import javax.crypto.spec.IvParameterSpec
+import javax.crypto.spec.SecretKeySpec
+
+
+@Component
+class SecurityEncryptionConfiguration {
+ private val key = "aesEncryptionKey"
+ private val initVector = "encryptionIntVec"
+
+ fun encrypt(value: String): String? {
+ try {
+ val (iv, skeySpec, cipher) = initChiper()
+ cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv)
+ val encrypted = cipher.doFinal(value.toByteArray())
+ return Base64.encodeBase64String(encrypted)
+ } catch (ex: Exception) {
+ ex.printStackTrace()
+ }
+ return String()
+ }
+
+ open fun decrypt(encrypted: String): String? {
+ try {
+ val (iv, skeySpec, cipher) = initChiper()
+ cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv)
+ val original = cipher.doFinal(Base64.decodeBase64(encrypted))
+ return String(original)
+ } catch (ex: Exception) {
+ ex.printStackTrace()
+ }
+ return String()
+ }
+
+ private fun initChiper(): Triple<IvParameterSpec, SecretKeySpec, Cipher> {
+ val iv = IvParameterSpec(initVector.toByteArray(charset("UTF-8")))
+ val secretKeySpec = SecretKeySpec(key.toByteArray(charset("UTF-8")), "AES")
+ val cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING")
+ return Triple(iv, secretKeySpec, cipher)
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ActuatorCheckResponse.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ActuatorCheckResponse.kt
new file mode 100644
index 000000000..1b82083dd
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ActuatorCheckResponse.kt
@@ -0,0 +1,19 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
+
+data class ActuatorCheckResponse(val serviceName: String, val details: Any)
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ActuatorEndpointType.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ActuatorEndpointType.kt
new file mode 100644
index 000000000..ee186b1b9
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ActuatorEndpointType.kt
@@ -0,0 +1,21 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
+
+enum class ActuatorEndpointType {
+ METRICS(), LOGGERS(), MAPPING()
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ApplicationHealth.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ApplicationHealth.kt
new file mode 100644
index 000000000..f66e8774c
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ApplicationHealth.kt
@@ -0,0 +1,25 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
+
+import org.springframework.boot.actuate.health.Status
+
+data class ApplicationHealth(val status: Status?, val details: Map<String, Any>?) {
+ constructor() : this(null, HashMap())
+}
+
+
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthApiResponse.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthApiResponse.kt
new file mode 100644
index 000000000..61d8120d4
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthApiResponse.kt
@@ -0,0 +1,23 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
+
+
+data class HealthApiResponse(val status: HealthCheckStatus, val checks: List<ServicesCheckResponse>
+)
+
+
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthCheckStatus.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthCheckStatus.kt
new file mode 100644
index 000000000..b60669d01
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthCheckStatus.kt
@@ -0,0 +1,22 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
+
+enum class HealthCheckStatus {
+ UP,
+ DOWN
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/Metrics.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/Metrics.kt
new file mode 100644
index 000000000..d9f1c79d4
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/Metrics.kt
@@ -0,0 +1,22 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
+
+
+data class Metrics(val names: ArrayList<Any>?) {
+ constructor() : this(ArrayList())
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/MetricsInfo.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/MetricsInfo.kt
new file mode 100644
index 000000000..0c2779861
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/MetricsInfo.kt
@@ -0,0 +1,19 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
+
+data class MetricsInfo(val health: List<ActuatorCheckResponse>)
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/MetricsResponse.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/MetricsResponse.kt
new file mode 100644
index 000000000..b3796c91a
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/MetricsResponse.kt
@@ -0,0 +1,21 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
+
+data class MetricsResponse(val maps: HashMap<String, String>) {
+
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceEndpoint.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceEndpoint.kt
new file mode 100644
index 000000000..ce95a5c0c
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceEndpoint.kt
@@ -0,0 +1,19 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
+
+
+data class ServiceEndpoint(val serviceName: String, var serviceLink: String)
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceName.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceName.kt
new file mode 100644
index 000000000..1a78a5d10
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceName.kt
@@ -0,0 +1,21 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
+
+enum class ServiceName(s: String) {
+ BLUEPRINT("Blue Print service"),CDSLISTENER("CDS Listener service")
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServicesCheckResponse.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServicesCheckResponse.kt
new file mode 100644
index 000000000..391d7f38a
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServicesCheckResponse.kt
@@ -0,0 +1,22 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
+
+
+data class ServicesCheckResponse(val name: String, val status: HealthCheckStatus)
+
+
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/WebClientEnpointResponse.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/WebClientEnpointResponse.kt
new file mode 100644
index 000000000..03e864a9d
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/WebClientEnpointResponse.kt
@@ -0,0 +1,22 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
+
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
+
+data class WebClientEnpointResponse (val response:BlueprintWebClientService.WebClientResponse<String>?) {
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/EndPointExecution.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/EndPointExecution.kt
new file mode 100644
index 000000000..72fa6c849
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/EndPointExecution.kt
@@ -0,0 +1,70 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service
+
+
+import com.fasterxml.jackson.databind.ObjectMapper
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ApplicationHealth
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServiceEndpoint
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.WebClientEnpointResponse
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
+import org.slf4j.LoggerFactory
+import org.springframework.http.HttpMethod
+import org.springframework.stereotype.Service
+
+/**
+ * Service for executing services endpoint with rest-lib project .
+ *
+ * @author Shaaban Ebrahim
+ * @version 1.0
+ */
+@Service
+open class EndPointExecution(private val basicAuthRestClientService: BasicAuthRestClientService
+ , private val restClientProperties: BasicAuthRestClientProperties) {
+
+ private var logger = LoggerFactory.getLogger(EndPointExecution::class.java)
+
+ open fun retrieveWebClientResponse(serviceEndpoint: ServiceEndpoint): WebClientEnpointResponse? {
+ try {
+ addClientPropertiesConfiguration(serviceEndpoint)
+ val result = basicAuthRestClientService.exchangeResource(HttpMethod.GET.name, "", "")
+ if (result.status == 200)
+ return WebClientEnpointResponse(result)
+
+ } catch (e: Exception) {
+ logger.error("service name ${serviceEndpoint.serviceName} is down ${e.message}")
+ }
+ return WebClientEnpointResponse(BlueprintWebClientService.WebClientResponse(500,""))
+ }
+
+ private fun addClientPropertiesConfiguration(serviceEndpoint: ServiceEndpoint) {
+ restClientProperties.url = serviceEndpoint.serviceLink
+ }
+
+
+ open fun getHealthFromWebClientEnpointResponse(webClientEnpointResponse: WebClientEnpointResponse): ApplicationHealth? {
+ return mappingMetricsToDTO(webClientEnpointResponse?.response?.body.toString())
+
+ }
+
+ private fun mappingMetricsToDTO(body: String): ApplicationHealth {
+ return ObjectMapper().readValue(body, ApplicationHealth::class.java)
+ }
+}
+
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/AbstractHealthCheck.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/AbstractHealthCheck.kt
new file mode 100644
index 000000000..f793754e3
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/AbstractHealthCheck.kt
@@ -0,0 +1,74 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.health
+
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.*
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.EndPointExecution
+import org.slf4j.LoggerFactory
+
+/**
+ *Abstract class to execute provided Service Endpoint from class that extends it
+ * by implementing setupServiceEndpoint method
+ *
+ * @author Shaaban Ebrahim
+ * @version 1.0
+ */
+abstract class AbstractHealthCheck (private val endPointExecution: EndPointExecution) {
+
+ private var logger = LoggerFactory.getLogger(BluePrintProcessorHealthCheck::class.java)
+
+ private fun retrieveSystemStatus(list: List<ServiceEndpoint>): HealthApiResponse {
+ val healthApiResponse: HealthApiResponse
+ val listOfResponse = mutableListOf<ServicesCheckResponse>()
+ var systemStatus: HealthCheckStatus = HealthCheckStatus.UP
+
+ for (serviceEndpoint in list) {
+ val serviceStatus: HealthCheckStatus = retrieveServiceStatus(serviceEndpoint)
+ if (serviceStatus.equals(HealthCheckStatus.DOWN))
+ systemStatus = HealthCheckStatus.DOWN
+
+ listOfResponse.add(ServicesCheckResponse(serviceEndpoint.serviceName, serviceStatus))
+ }
+ healthApiResponse = HealthApiResponse(systemStatus, listOfResponse)
+ return healthApiResponse
+
+ }
+
+
+ private fun retrieveServiceStatus(serviceEndpoint: ServiceEndpoint): HealthCheckStatus {
+ var serviceStatus: HealthCheckStatus = HealthCheckStatus.UP
+ try {
+ val result: WebClientEnpointResponse? = endPointExecution?.retrieveWebClientResponse(serviceEndpoint)
+ if (result == null || result.response?.status != 200) {
+ serviceStatus = HealthCheckStatus.DOWN
+ }
+ } catch (e: Exception) {
+ logger.error("service name ${serviceEndpoint.serviceName} is down ${e.message}")
+ serviceStatus = HealthCheckStatus.DOWN
+
+ }
+ return serviceStatus
+ }
+
+
+ open fun retrieveEndpointExecutionStatus(): HealthApiResponse {
+ return retrieveSystemStatus(setupServiceEndpoint())
+ }
+
+ abstract fun setupServiceEndpoint(): List<ServiceEndpoint>
+
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/BluePrintProcessorHealthCheck.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/BluePrintProcessorHealthCheck.kt
new file mode 100644
index 000000000..d661b32b5
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/BluePrintProcessorHealthCheck.kt
@@ -0,0 +1,38 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.health
+
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.configuration.HealthCheckProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServiceEndpoint
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.EndPointExecution
+import org.springframework.stereotype.Service
+
+/**
+ * Service for checking health for other CDS services .
+ *
+ * @author Shaaban Ebrahim
+ * @version 1.0
+ */
+@Service
+open class BluePrintProcessorHealthCheck(private val endPointExecution: EndPointExecution
+ , private val healthCheckProperties: HealthCheckProperties)
+ : AbstractHealthCheck(endPointExecution) {
+
+ override fun setupServiceEndpoint(): List<ServiceEndpoint> {
+ return healthCheckProperties.getBluePrintServiceInformation()
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/SDCListenerHealthCheck.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/SDCListenerHealthCheck.kt
new file mode 100644
index 000000000..0a7c5e092
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/health/SDCListenerHealthCheck.kt
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.health
+
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.configuration.HealthCheckProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthApiResponse
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthCheckStatus
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServiceEndpoint
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServicesCheckResponse
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.EndPointExecution
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.stereotype.Service
+
+/**
+ * Service for checking health for other CDS listener services .
+ *
+ * @author Shaaban Ebrahim
+ * @version 1.0
+ */
+@Service
+open class SDCListenerHealthCheck (private val endPointExecution: EndPointExecution
+ ,private val healthCheckProperties: HealthCheckProperties)
+ : AbstractHealthCheck(endPointExecution) {
+
+ override fun setupServiceEndpoint(): List<ServiceEndpoint> {
+ return healthCheckProperties.getCDSListenerServiceInformation()
+ }
+
+
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.kt
new file mode 100644
index 000000000..c4a8d1235
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.kt
@@ -0,0 +1,167 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi
+
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertNotNull
+import org.mockito.ArgumentMatchers.any
+import org.mockito.ArgumentMatchers.eq
+import org.mockito.Mockito.anyString
+import org.mockito.Mockito.mock
+
+import java.util.Arrays
+import org.junit.Assert
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentMatchers
+import org.mockito.InjectMocks
+import org.mockito.Mock
+import org.mockito.Mockito
+import org.mockito.junit.MockitoJUnitRunner
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.configuration.HealthCheckProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthApiResponse
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthCheckStatus
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServiceEndpoint
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.EndPointExecution
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.health.BluePrintProcessorHealthCheck
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService.WebClientResponse
+import org.springframework.http.HttpMethod
+
+@RunWith(MockitoJUnitRunner::class)
+class HealthCheckServiceTest {
+
+ @Mock
+ private val basicAuthRestClientService: BasicAuthRestClientService? = null
+
+ @Mock
+ private val restClientProperties: BasicAuthRestClientProperties? = null
+
+ @Mock
+ private val healthCheckProperties: HealthCheckProperties? = null
+
+ @InjectMocks
+ private var endPointExecution: EndPointExecution? = null
+
+ private var bluePrintProcessorHealthCheck: BluePrintProcessorHealthCheck? = null
+
+
+ @Before
+ fun setup() {
+ endPointExecution = Mockito.spy(endPointExecution!!)
+ Mockito.`when`(healthCheckProperties!!.getBluePrintServiceInformation()).thenReturn(Arrays.asList(
+ ServiceEndpoint("Execution service ", "http://cds-blueprints-processor-http:8080/api/v1/execution-service/health-check"),
+ ServiceEndpoint("Resources service", "http://cds-blueprints-processor-http:8080/api/v1/resources/health-check"), ServiceEndpoint("Template service", "http://cds-blueprints-processor-http:8080/api/v1/template/health-check")
+ ))
+
+ bluePrintProcessorHealthCheck = BluePrintProcessorHealthCheck(endPointExecution!!, healthCheckProperties)
+ }
+
+ @Test
+ fun testSystemIsCompletelyDown() {
+
+ Mockito.`when`(basicAuthRestClientService!!.exchangeResource(
+ anyString(),
+ anyString(),
+ anyString())).thenThrow(RuntimeException())
+ val healthApiResponse = bluePrintProcessorHealthCheck!!.retrieveEndpointExecutionStatus()
+ assertNotNull(healthApiResponse)
+ Assert.assertEquals(HealthCheckStatus.DOWN, healthApiResponse.status)
+ healthApiResponse.checks.forEach { serviceEndpoint ->
+ assertNotNull(serviceEndpoint)
+ assertEquals(HealthCheckStatus.DOWN, serviceEndpoint.status)
+
+ }
+
+ }
+
+ @Test
+ fun testSystemIsUPAndRunning() {
+
+ Mockito.`when`(basicAuthRestClientService!!
+ .exchangeResource(
+ anyString(),
+ anyString(),
+ anyString())).thenReturn(BlueprintWebClientService.WebClientResponse(200, "Success"))
+ val healthApiResponse = bluePrintProcessorHealthCheck!!.retrieveEndpointExecutionStatus()
+ assertNotNull(healthApiResponse)
+ assertEquals(HealthCheckStatus.UP, healthApiResponse.status)
+ healthApiResponse.checks.forEach { serviceEndpoint ->
+ assertNotNull(serviceEndpoint)
+ assertEquals(HealthCheckStatus.UP, serviceEndpoint.status)
+
+ }
+
+ }
+
+ @Test
+ fun testServiceIsNotFound() {
+ Mockito.`when`(basicAuthRestClientService!!.exchangeResource(
+ anyString(),
+ anyString(),
+ anyString())).thenReturn(BlueprintWebClientService.WebClientResponse(404, "failure"))
+ val healthApiResponse = bluePrintProcessorHealthCheck!!.retrieveEndpointExecutionStatus()
+ assertNotNull(healthApiResponse)
+ assertEquals(HealthCheckStatus.DOWN, healthApiResponse.status)
+ healthApiResponse.checks.forEach { serviceEndpoint ->
+ assertNotNull(serviceEndpoint)
+ assertEquals(HealthCheckStatus.DOWN, serviceEndpoint.status)
+
+ }
+
+ }
+
+
+ @Test
+ fun testServiceInternalServerError() {
+ Mockito.`when`(basicAuthRestClientService!!.exchangeResource(
+ anyString(),
+ anyString(),
+ anyString()))
+ .thenReturn(BlueprintWebClientService.WebClientResponse(500, "failure"))
+ val healthApiResponse = bluePrintProcessorHealthCheck!!.retrieveEndpointExecutionStatus()
+ assertNotNull(healthApiResponse)
+ assertEquals(HealthCheckStatus.DOWN, healthApiResponse.status)
+ healthApiResponse.checks.forEach { serviceEndpoint ->
+ assertNotNull(serviceEndpoint)
+ assertEquals(HealthCheckStatus.DOWN, serviceEndpoint.status)
+
+ }
+
+ }
+
+ @Test
+ fun testServiceIsRedirected() {
+ Mockito.`when`(basicAuthRestClientService!!.
+ exchangeResource(
+ anyString(),
+ anyString(),
+ anyString()))
+ .thenReturn(BlueprintWebClientService.WebClientResponse(300, "failure"))
+ val healthApiResponse = bluePrintProcessorHealthCheck!!.retrieveEndpointExecutionStatus()
+ assertNotNull(healthApiResponse)
+ assertEquals(HealthCheckStatus.DOWN, healthApiResponse.status)
+ healthApiResponse.checks.forEach { serviceEndpoint ->
+ assertNotNull(serviceEndpoint)
+ assertEquals(HealthCheckStatus.DOWN, serviceEndpoint.status)
+
+ }
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/SecurityConfigurationTest.kt b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/SecurityConfigurationTest.kt
new file mode 100644
index 000000000..e1f7abdb7
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/SecurityConfigurationTest.kt
@@ -0,0 +1,34 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi
+
+import org.junit.Assert
+import org.junit.Test
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.configuration.SecurityEncryptionConfiguration
+
+
+class SecurityConfigurationTest {
+
+ @Test
+ fun testEncryption() {
+ val passWord = "ccsdkapps"
+ val securityConfiguration = SecurityEncryptionConfiguration()
+ val encryptedValue = securityConfiguration.encrypt(passWord)
+ println(encryptedValue)
+ Assert.assertEquals(passWord, securityConfiguration.decrypt(encryptedValue!!))
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/resources/application-test.properties b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/resources/application-test.properties
new file mode 100644
index 000000000..edf5760db
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/resources/application-test.properties
@@ -0,0 +1,29 @@
+#
+# Copyright © 2019-2020 Orange.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+#You may obtain a copy of the License at
+# http://www.apache.org/licenses/LICENSE-2.0
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the Licens
+blueprintsprocessor.db.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1
+blueprintsprocessor.db.username=sa
+blueprintsprocessor.db.password=
+blueprintsprocessor.db.driverClassName=org.h2.Driver
+blueprintsprocessor.db.hibernateHbm2ddlAuto=create-drop
+blueprintsprocessor.db.hibernateDDLAuto=update
+blueprintsprocessor.db.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy
+blueprintsprocessor.db.hibernateDialect=org.hibernate.dialect.H2Dialect
+# Controller Blueprints Core Configuration
+blueprintsprocessor.blueprintDeployPath=./target/blueprints/deploy
+blueprintsprocessor.blueprintWorkingPath=./target/blueprints/work
+blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive
+# Python executor
+blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints
+blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints
+server.socket=localhost:8080
+endpoints.user.name=eHbVUbJAj4AG2522cSbrOQ==
+endpoints.user.password=eHbVUbJAj4AG2522cSbrOQ==
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/resources/logback.xml b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/resources/logback.xml
new file mode 100644
index 000000000..0656cad76
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/resources/logback.xml
@@ -0,0 +1,35 @@
+<!--
+ /*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ -->
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <!-- encoders are assigned the type
+ ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <logger name="org.springframework" level="warn"/>
+ <logger name="org.hibernate" level="info"/>
+ <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/>
+
+ <root level="info">
+ <appender-ref ref="STDOUT"/>
+ </root>
+
+</configuration>
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
new file mode 100644
index 000000000..1f0955d45
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api-common/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
@@ -0,0 +1 @@
+mock-maker-inline
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/.gitignore b/ms/blueprintsprocessor/modules/inbounds/health-api/.gitignore
new file mode 100644
index 000000000..a2a3040aa
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/.gitignore
@@ -0,0 +1,31 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**
+!**/src/test/**
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+
+### VS Code ###
+.vscode/
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/health-api/pom.xml
index 01903a4c6..2635cfbb4 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/pom.xml
@@ -31,9 +31,11 @@
<description>checking system check health endpoints</description>
<dependencies>
+
<dependency>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
- <artifactId>rest-lib</artifactId>
+ <artifactId>health-api-common</artifactId>
+ <version>0.7.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/HealthCheckController.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedHealth.kt
index 1283ac5ac..54c85a0fc 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/HealthCheckController.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedHealth.kt
@@ -18,9 +18,8 @@ package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.controller
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
-import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthApiResponse
-import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.HealthCheckService
-import org.springframework.beans.factory.annotation.Autowired
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ApplicationHealth
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.CombinedHealthService
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.RequestMapping
@@ -28,21 +27,26 @@ import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.ResponseBody
import org.springframework.web.bind.annotation.RestController
+/**
+ * Exposes API for checking health for other services .
+ *
+ * @author Shaaban Ebrahim
+ * @version 1.0
+ */
@RestController
-@RequestMapping("/api/v1/health")
-@Api(value = "/api/v1/health",
+@RequestMapping("/api/v1/combinedHealth")
+@Api(value = "/api/v1/combinedHealth",
description = "gather all HealthCheckResponses for HealthChecks known to the runtime")
-open class HealthCheckController {
-
- @Autowired
- lateinit var healthApiService: HealthCheckService
+open class CombinedHealth(private val combinedHealthService: CombinedHealthService) {
@RequestMapping(path = [""],
method = [RequestMethod.GET],
produces = [MediaType.APPLICATION_JSON_VALUE])
@ResponseBody
@ApiOperation(value = "Health Check", hidden = true)
- fun getSystemHealthCheckResponse(): ResponseEntity<HealthApiResponse> {
- return ResponseEntity.ok().body(healthApiService.retrieveSystemStatus())
+ fun getSystemHealthCheckResponse(): ResponseEntity<List<ApplicationHealth?>> {
+ return ResponseEntity.ok().body(combinedHealthService.getCombinedHealthCheck())
+
}
}
+
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedMetrics.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedMetrics.kt
new file mode 100644
index 000000000..785def524
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/CombinedMetrics.kt
@@ -0,0 +1,52 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.controller
+
+import io.swagger.annotations.Api
+import io.swagger.annotations.ApiOperation
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.MetricsInfo
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.CombinedMetricsService
+import org.springframework.http.MediaType
+import org.springframework.http.ResponseEntity
+import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.RequestMethod
+import org.springframework.web.bind.annotation.ResponseBody
+import org.springframework.web.bind.annotation.RestController
+
+/**
+ * Exposes API for checking Metrics of BluePrint processor and CDSListener.
+ *
+ * @author Shaaban Ebrahim
+ * @version 1.0
+ */
+@RestController
+@RequestMapping("/api/v1/combinedMetrics")
+@Api(value = "/api/v1/combinedMetrics",
+ description = "gather all Metrics info from BluePrint and CDSListener")
+open class CombinedMetrics(private val combinedMetricsService: CombinedMetricsService) {
+
+ @RequestMapping(path = [""],
+ method = [RequestMethod.GET],
+ produces = [MediaType.APPLICATION_JSON_VALUE])
+ @ResponseBody
+ @ApiOperation(value = " Metrics Check", hidden = true)
+ fun getMetricsHealthCheckResponse(): ResponseEntity<MetricsInfo?> {
+ return ResponseEntity.ok().body(combinedMetricsService.metricsInfo)
+
+ }
+
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthApiResponse.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthApiResponse.kt
deleted file mode 100644
index 4dac178e5..000000000
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthApiResponse.kt
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
-
-
-data class HealthApiResponse(val status: HealthCheckStatus, val checks:List<HealthCheckResponse>)
-
-
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthCheckResponse.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthCheckResponse.kt
deleted file mode 100644
index acac867cb..000000000
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthCheckResponse.kt
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
-
-
-data class HealthCheckResponse(val name: String, val status: HealthCheckStatus)
-
-
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthCheckStatus.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthCheckStatus.kt
deleted file mode 100644
index a891a40d3..000000000
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthCheckStatus.kt
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
-
-enum class HealthCheckStatus {
- UP,
- DOWN
-} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceEndpoint.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceEndpoint.kt
deleted file mode 100644
index 8fbc33b47..000000000
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceEndpoint.kt
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain
-
-
-
-data class ServiceEndpoint(val serviceName: String, val serviceLink: String)
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedHealthService.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedHealthService.kt
new file mode 100644
index 000000000..786048ce4
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedHealthService.kt
@@ -0,0 +1,58 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service
+
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.configuration.HealthCheckProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ApplicationHealth
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServiceEndpoint
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.WebClientEnpointResponse
+import org.springframework.boot.actuate.health.Status
+import org.springframework.stereotype.Service
+
+
+/**
+ *Service for combined health (BluePrintProcessor and CDSListener)
+ *
+ * @author Shaaban Ebrahim
+ * @version 1.0
+ */
+@Service
+open class CombinedHealthService(private val endPointExecution: EndPointExecution
+ , private val healthCheckProperties: HealthCheckProperties) {
+
+ private fun setupServiceEndpoint(): List<ServiceEndpoint> {
+ return listOf(
+ ServiceEndpoint("BluePrintProcessor Health Check ", healthCheckProperties.getBluePrintBaseURL() + "actuator/health")
+ , ServiceEndpoint("CDSListener Health Check", healthCheckProperties.getCDSListenerBaseURL() + "actuator/health")
+ )
+ }
+
+ open fun getCombinedHealthCheck(): List<ApplicationHealth?> {
+ val listOfResponse = ArrayList<ApplicationHealth?>()
+ for (serviceEndpoint in setupServiceEndpoint().parallelStream()) {
+ val result: WebClientEnpointResponse? = endPointExecution?.retrieveWebClientResponse(serviceEndpoint)
+ if (result?.response != null &&
+ result.response!!.status?.equals(200)!!) {
+ listOfResponse.add(endPointExecution?.getHealthFromWebClientEnpointResponse(result))
+ } else {
+ listOfResponse.add(ApplicationHealth(Status.DOWN,
+ hashMapOf(serviceEndpoint.serviceLink to serviceEndpoint.serviceLink)))
+ }
+ }
+ return listOfResponse
+ }
+
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedMetricsService.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedMetricsService.kt
new file mode 100644
index 000000000..a23c9925b
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/CombinedMetricsService.kt
@@ -0,0 +1,72 @@
+/*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service
+
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.configuration.HealthCheckProperties
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.*
+import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.utils.ObjectMappingUtils
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
+import org.springframework.stereotype.Service
+
+/**
+ *Service for combined Metrics for CDS Listener and BluePrintProcessor
+ *
+ * @author Shaaban Ebrahim
+ * @version 1.0
+ */
+@Service
+open class CombinedMetricsService(private val endPointExecution: EndPointExecution
+ , private val healthCheckProperties: HealthCheckProperties
+ , private val objectMappingUtils: ObjectMappingUtils<Metrics>) {
+
+ private fun setupServiceEndpoint(): List<ServiceEndpoint> {
+ return listOf(
+ ServiceEndpoint("BluePrintProcessor metrics", healthCheckProperties.getBluePrintBaseURL() + "/actuator/metrics")
+ , ServiceEndpoint("CDS Listener metrics", healthCheckProperties.getCDSListenerBaseURL() + "/actuator/metrics")
+ )
+ }
+
+ open val metricsInfo: MetricsInfo
+ get() {
+ val containerHealthChecks = mutableListOf<ActuatorCheckResponse>()
+ for (serviceEndpoint in setupServiceEndpoint().parallelStream()) {
+ val webClientResponse = endPointExecution?.retrieveWebClientResponse(serviceEndpoint)
+ var actuatorsHealthResponse: ActuatorCheckResponse? = null
+ actuatorsHealthResponse = if (webClientResponse?.response != null &&
+ webClientResponse.response!!.status?.equals(200)!!) {
+ var body = gettingCustomizedBody(serviceEndpoint, webClientResponse.response!!)
+ ActuatorCheckResponse(serviceEndpoint.serviceName, body)
+ } else {
+ ActuatorCheckResponse(serviceEndpoint.serviceName, HealthCheckStatus.DOWN)
+ }
+ containerHealthChecks.add(actuatorsHealthResponse)
+ }
+ return MetricsInfo(containerHealthChecks)
+ }
+
+ private fun gettingCustomizedBody(serviceEndpoint: ServiceEndpoint?, webClientResponse: BlueprintWebClientService.WebClientResponse<String>): Any {
+ var body: Any
+ val metrics: Metrics = objectMappingUtils.getObjectFromBody(webClientResponse.body, Metrics::class.java)
+ val mapOfMetricsInfo = HashMap<String, String>()
+ for (name in metrics.names!!) {
+ mapOfMetricsInfo.put(name.toString(), serviceEndpoint?.serviceLink + "/" + name)
+ }
+ body = MetricsResponse(mapOfMetricsInfo)
+
+ return body
+ }
+}
+
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/HealthCheckService.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/HealthCheckService.kt
deleted file mode 100644
index 09fdb67f2..000000000
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/HealthCheckService.kt
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright © 2019-2020 Orange.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service
-
-import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthApiResponse
-import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthCheckResponse
-import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthCheckStatus
-import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServiceEndpoint
-import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties
-import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService
-import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
-import org.slf4j.LoggerFactory
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.http.HttpMethod
-import org.springframework.stereotype.Service
-
-
-@Service
-class HealthCheckService {
-
- private var logger = LoggerFactory.getLogger(HealthCheckService::class.java)
-
- @Autowired
- lateinit var basicAuthRestClientService: BasicAuthRestClientService
-
- @Autowired
- lateinit var restClientProperties: BasicAuthRestClientProperties
-
-
- open fun setupServiceEndpoint(): List<ServiceEndpoint> {
- return listOf(ServiceEndpoint("Execution service", "http://cds-blueprints-processor-http:8080/api/v1/execution-service/health-check"),
- ServiceEndpoint("Template service", "http://cds-blueprints-processor-http:8080/api/v1/template/health-check"),
- ServiceEndpoint("Resources service", "http://cds-blueprints-processor-http:8080/api/v1/resources/health-check"),
- ServiceEndpoint("SDC Listener service", "http://cds-sdc-listener:8080/api/v1/sdclistener/health-check")
- )
- }
-
- fun retrieveSystemStatus(): HealthApiResponse {
- logger.info("Retrieve System Status")
- var healthApiResponse: HealthApiResponse
- val listOfResponse = mutableListOf<HealthCheckResponse>()
- var systemStatus: HealthCheckStatus = HealthCheckStatus.UP
-
- for (serviceEndpoint in setupServiceEndpoint().parallelStream()) {
- var serviceStatus: HealthCheckStatus = retrieveServiceStatus(serviceEndpoint)
- if (serviceStatus.equals(HealthCheckStatus.DOWN))
- systemStatus = HealthCheckStatus.DOWN
-
- listOfResponse.add(HealthCheckResponse(serviceEndpoint.serviceName, serviceStatus))
- }
- healthApiResponse = HealthApiResponse(systemStatus, listOfResponse)
- return healthApiResponse
- }
-
- private fun retrieveServiceStatus(serviceEndpoint: ServiceEndpoint): HealthCheckStatus {
- var serviceStatus: HealthCheckStatus = HealthCheckStatus.UP
- try {
- addClientPropertiesConfiguration(serviceEndpoint)
- val result: BlueprintWebClientService.WebClientResponse<String> = basicAuthRestClientService.exchangeResource(HttpMethod.GET.name, "", "")
- if (result == null || result.status != 200) {
- serviceStatus = HealthCheckStatus.DOWN
-
- }
- } catch (e: Exception) {
- logger.error("service is down" + e)
- serviceStatus = HealthCheckStatus.DOWN
-
- }
- return serviceStatus
- }
-
- private fun addClientPropertiesConfiguration(serviceEndpoint: ServiceEndpoint) {
- restClientProperties.url = serviceEndpoint.serviceLink
- }
-
-
-}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/utils/ObjectMappingUtils.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/utils/ObjectMappingUtils.kt
new file mode 100644
index 000000000..9964c4518
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/utils/ObjectMappingUtils.kt
@@ -0,0 +1,13 @@
+package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.utils
+
+import com.fasterxml.jackson.databind.ObjectMapper
+import org.springframework.stereotype.Service
+
+@Service
+class ObjectMappingUtils<T> {
+
+ @Throws(java.io.IOException::class)
+ open fun getObjectFromBody(body: String, mappingClass: Class<T>): T {
+ return ObjectMapper().readValue(body, mappingClass) as T
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/resources/application.properties b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/resources/application.properties
index aca95b481..de4b8f8f9 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/resources/application.properties
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/resources/application.properties
@@ -13,6 +13,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
-endpoints.user.name=ccsdkapps
-endpoints.user.password=ccsdkapps
+#endpoints.user.name=eHbVUbJAj4AG2522cSbrOQ==
+#endpoints.user.password=eHbVUbJAj4AG2522cSbrOQ==
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckApplicationTests.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckApplicationTests.kt
index cd02b65dc..b1d629da7 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckApplicationTests.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckApplicationTests.kt
@@ -20,7 +20,9 @@ package org.onap.ccsdk.cds.blueprintsprocessor.healthapi
import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentScriptExecutor
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.security.SecurityProperties
import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest
@@ -30,25 +32,36 @@ import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
import org.springframework.test.web.reactive.server.WebTestClient
-
+/**
+ *Unit tests for making sure that two endpoints is up and running
+ *
+ * @author Shaaban Ebrahim
+ * @version 1.0
+ */
@RunWith(SpringRunner::class)
@WebFluxTest
-@ContextConfiguration(classes = [BluePrintCoreConfiguration::class,
- BluePrintCatalogService::class, SecurityProperties::class])
+@ContextConfiguration(classes = [BluePrintRuntimeService::class, BluePrintCoreConfiguration::class,
+ BluePrintCatalogService::class, SecurityProperties::class, ComponentScriptExecutor::class])
@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"])
@TestPropertySource(locations = ["classpath:application-test.properties"])
class HealthCheckApplicationTests {
-
@Autowired
lateinit var webTestClient: WebTestClient
@Test
fun testHealthApiUp() {
- val result = webTestClient.get().uri("/api/v1/health")
+ webTestClient.get().uri("/api/v1/combinedHealth")
+ .exchange()
+ .expectStatus().is2xxSuccessful
+
+ }
+
+ @Test
+ fun testMetricsApiUp() {
+ webTestClient.get().uri("/api/v1/combinedMetrics")
.exchange()
.expectStatus().is2xxSuccessful
- println(result)
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.java b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.java
deleted file mode 100644
index 128c80adf..000000000
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright © 2019-2020 Orange.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.cds.blueprintsprocessor.healthapi;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthApiResponse;
-import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthCheckStatus;
-import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.HealthCheckService;
-import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties;
-import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService;
-import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService.WebClientResponse;
-import org.springframework.http.HttpMethod;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.anyString;
-
-@RunWith(MockitoJUnitRunner.class)
-public class HealthCheckServiceTest {
-
- @Mock
- private BasicAuthRestClientService basicAuthRestClientService;
-
- @Mock
- private BasicAuthRestClientProperties restClientProperties;
-
- @InjectMocks
- private HealthCheckService healthCheckService = new HealthCheckService();
-
- @Before
- public void setup() {
- }
-
- @Test
- public void testSystemIsCompletelyDown() {
-
- Mockito.when(basicAuthRestClientService.exchangeResource(anyString(), anyString(), anyString())).
- thenThrow(new RuntimeException());
- HealthApiResponse healthApiResponse = healthCheckService.retrieveSystemStatus();
- assertNotNull(healthApiResponse);
- Assert.assertEquals(healthApiResponse.getStatus(), HealthCheckStatus.DOWN);
- healthApiResponse.getChecks().stream().forEach(serviceEndpoint -> {
- assertNotNull(serviceEndpoint);
- assertEquals(serviceEndpoint.getStatus(), HealthCheckStatus.DOWN);
-
- });
-
- }
-
-
- @Test
- public void testSystemIsUPAndRunning() {
-
- Mockito.when(basicAuthRestClientService.exchangeResource(eq(HttpMethod.GET.name()), anyString(), anyString())).
- thenReturn(new WebClientResponse<>(200, "Success"));
- HealthApiResponse healthApiResponse = healthCheckService.retrieveSystemStatus();
- assertNotNull(healthApiResponse);
- assertEquals(healthApiResponse.getStatus(), HealthCheckStatus.UP);
- healthApiResponse.getChecks().stream().forEach(serviceEndpoint -> {
- assertNotNull(serviceEndpoint);
- assertEquals(serviceEndpoint.getStatus(), HealthCheckStatus.UP);
-
- });
-
- }
-
- @Test
- public void testServiceIsNotFound() {
- Mockito.when(basicAuthRestClientService.exchangeResource(eq(HttpMethod.GET.name()), any(), anyString())).
- thenReturn(new WebClientResponse<>(404, "failure"));
- HealthApiResponse healthApiResponse = healthCheckService.retrieveSystemStatus();
- assertNotNull(healthApiResponse);
- assertEquals(healthApiResponse.getStatus(), HealthCheckStatus.DOWN);
- healthApiResponse.getChecks().stream().forEach(serviceEndpoint -> {
- assertNotNull(serviceEndpoint);
- assertEquals(serviceEndpoint.getStatus(), HealthCheckStatus.DOWN);
-
- });
-
- }
-
-
- @Test
- public void testServiceInternalServerError() {
- Mockito.when(basicAuthRestClientService.exchangeResource(eq(HttpMethod.GET.name()), any(), anyString()))
- .thenReturn(new WebClientResponse<>(500, "failure"));
- HealthApiResponse healthApiResponse = healthCheckService.retrieveSystemStatus();
- assertNotNull(healthApiResponse);
- assertEquals(healthApiResponse.getStatus(), HealthCheckStatus.DOWN);
- healthApiResponse.getChecks().stream().forEach(serviceEndpoint -> {
- assertNotNull(serviceEndpoint);
- assertEquals(serviceEndpoint.getStatus(), HealthCheckStatus.DOWN);
-
- });
-
- }
-
- @Test
- public void testServiceIsRedirected() {
- Mockito.when(basicAuthRestClientService.exchangeResource(eq(HttpMethod.GET.name()), any(), anyString()))
- .thenReturn(new WebClientResponse<>(300, "failure"));
- HealthApiResponse healthApiResponse = healthCheckService.retrieveSystemStatus();
- assertNotNull(healthApiResponse);
- assertEquals(healthApiResponse.getStatus(), HealthCheckStatus.DOWN);
- healthApiResponse.getChecks().stream().forEach(serviceEndpoint -> {
- assertNotNull(serviceEndpoint);
- assertEquals(serviceEndpoint.getStatus(), HealthCheckStatus.DOWN);
-
- });
-
- }
-
-}
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/resources/application-test.properties b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/resources/application-test.properties
index c9a5700c1..8eb6db352 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/resources/application-test.properties
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/resources/application-test.properties
@@ -1,16 +1,14 @@
-# Copyright © 2019 Bell Canada.
#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
+# Copyright © 2019-2020 Orange.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+#You may obtain a copy of the License at
+# http://www.apache.org/licenses/LICENSE-2.0
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
blueprintsprocessor.db.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1
blueprintsprocessor.db.username=sa
@@ -24,8 +22,9 @@ blueprintsprocessor.db.hibernateDialect=org.hibernate.dialect.H2Dialect
blueprintsprocessor.blueprintDeployPath=./target/blueprints/deploy
blueprintsprocessor.blueprintWorkingPath=./target/blueprints/work
blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive
-
# Python executor
blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints
blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints
server.socket=localhost:8080
+endpoints.user.name=eHbVUbJAj4AG2522cSbrOQ==
+endpoints.user.password=eHbVUbJAj4AG2522cSbrOQ==
diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/resources/logback.xml b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/resources/logback.xml
index c97e1cd29..11582a301 100644
--- a/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/resources/logback.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/resources/logback.xml
@@ -1,23 +1,23 @@
<!--
- ~ Copyright © 2019 Bell Canada
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
+ /*
+ * Copyright © 2019-2020 Orange.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
-->
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <!-- encoders are assigned the type
- ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>
</encoder>
diff --git a/ms/blueprintsprocessor/modules/inbounds/pom.xml b/ms/blueprintsprocessor/modules/inbounds/pom.xml
index 81ffea176..6dc39a7ff 100644
--- a/ms/blueprintsprocessor/modules/inbounds/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/pom.xml
@@ -35,7 +35,8 @@
<module>designer-api</module>
<module>resource-api</module>
<module>selfservice-api</module>
- <!--<module>health-api</module>-->
+ <module>health-api</module>
+ <module>health-api-common</module>
</modules>
<dependencies>
@@ -51,16 +52,7 @@
<groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
<artifactId>resource-resolution</artifactId>
</dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+
<!-- Test Dependencies -->
<dependency>