aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sources/hv-collector-core/pom.xml5
-rw-r--r--sources/hv-collector-ct/pom.xml22
-rw-r--r--sources/hv-collector-dcae-app-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/impl/DcaeAppSimulator.kt9
-rw-r--r--sources/hv-collector-dcae-app-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/impl/MessageStreamValidation.kt20
-rw-r--r--sources/hv-collector-dcae-app-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/impl/adapters/DcaeAppApiServer.kt30
-rw-r--r--sources/hv-collector-dcae-app-simulator/src/main/resources/logback.xml2
-rw-r--r--sources/hv-collector-ssl/pom.xml9
-rw-r--r--sources/hv-collector-test-utils/pom.xml5
-rw-r--r--sources/hv-collector-test-utils/src/main/resources/logback-test.xml35
-rw-r--r--sources/hv-collector-utils/pom.xml10
-rw-r--r--sources/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/http/ratpack.kt2
-rw-r--r--sources/hv-collector-utils/src/test/resources/logback-test.xml35
-rw-r--r--sources/hv-collector-ves-message-generator/pom.xml10
-rw-r--r--sources/hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/MessageParametersParserImpl.kt7
-rw-r--r--sources/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/adapters/XnfApiServer.kt10
15 files changed, 164 insertions, 47 deletions
diff --git a/sources/hv-collector-core/pom.xml b/sources/hv-collector-core/pom.xml
index 7f7922e1..ae781742 100644
--- a/sources/hv-collector-core/pom.xml
+++ b/sources/hv-collector-core/pom.xml
@@ -127,11 +127,6 @@
<artifactId>javax.json</artifactId>
<scope>runtime</scope>
</dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git a/sources/hv-collector-ct/pom.xml b/sources/hv-collector-ct/pom.xml
index 61ac426b..47b707a6 100644
--- a/sources/hv-collector-ct/pom.xml
+++ b/sources/hv-collector-ct/pom.xml
@@ -74,22 +74,11 @@
<artifactId>hv-collector-test-utils</artifactId>
<version>${project.parent.version}</version>
</dependency>
-
-
<dependency>
<groupId>io.arrow-kt</groupId>
<artifactId>arrow-syntax</artifactId>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- </dependency>
-
- <dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
@@ -109,7 +98,14 @@
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
-
-
</project> \ No newline at end of file
diff --git a/sources/hv-collector-dcae-app-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/impl/DcaeAppSimulator.kt b/sources/hv-collector-dcae-app-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/impl/DcaeAppSimulator.kt
index 490cde4a..417183fb 100644
--- a/sources/hv-collector-dcae-app-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/impl/DcaeAppSimulator.kt
+++ b/sources/hv-collector-dcae-app-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/impl/DcaeAppSimulator.kt
@@ -40,10 +40,11 @@ class DcaeAppSimulator(private val consumerFactory: ConsumerFactory,
fun listenToTopics(topicsString: String) = listenToTopics(extractTopics(topicsString))
fun listenToTopics(topics: Set<String>): IO<Unit> = IO.monadError().bindingCatch {
- if (topics.any { it.isBlank() })
- throw IllegalArgumentException("Topic list cannot contain empty elements")
- if (topics.isEmpty())
- throw IllegalArgumentException("Topic list cannot be empty")
+ if (topics.isEmpty() || topics.any { it.isBlank() }) {
+ val message = "Topic list cannot be empty or contain empty elements, topics: $topics"
+ logger.info { message }
+ throw IllegalArgumentException(message)
+ }
logger.info("Received new configuration. Creating consumer for topics: $topics")
consumerState.set(consumerFactory.createConsumerForTopics(topics).bind())
diff --git a/sources/hv-collector-dcae-app-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/impl/MessageStreamValidation.kt b/sources/hv-collector-dcae-app-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/impl/MessageStreamValidation.kt
index e423191d..20c0f592 100644
--- a/sources/hv-collector-dcae-app-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/impl/MessageStreamValidation.kt
+++ b/sources/hv-collector-dcae-app-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/impl/MessageStreamValidation.kt
@@ -19,13 +19,16 @@
*/
package org.onap.dcae.collectors.veshv.simulators.dcaeapp.impl
+import arrow.core.getOrElse
import arrow.effects.IO
import arrow.effects.fix
import arrow.effects.instances.io.monadError.monadError
+import arrow.instances.option.foldable.fold
import arrow.typeclasses.bindingCatch
import org.onap.dcae.collectors.veshv.domain.ByteData
import org.onap.dcae.collectors.veshv.domain.WireFrameMessage
import org.onap.dcae.collectors.veshv.utils.arrow.asIo
+import org.onap.dcae.collectors.veshv.utils.logging.Logger
import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageGenerator
import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageParameters
import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageParametersParser
@@ -41,6 +44,7 @@ class MessageStreamValidation(
fun validate(jsonDescription: InputStream, consumedMessages: List<ByteArray>): IO<Boolean> =
IO.monadError().bindingCatch {
val messageParams = parseMessageParams(jsonDescription)
+ logger.debug { "Parsed message parameters: $messageParams" }
val expectedEvents = generateEvents(messageParams).bind()
val actualEvents = decodeConsumedEvents(consumedMessages)
if (shouldValidatePayloads(messageParams)) {
@@ -55,10 +59,17 @@ class MessageStreamValidation(
val messageParams = messageParametersParser.parse(expectations)
return messageParams.fold(
- { throw IllegalArgumentException("Parsing error: " + it.message) },
{
- if (it.isEmpty())
- throw IllegalArgumentException("Message param list cannot be empty")
+ logger.warn { "Error while parsing message parameters: ${it::class.qualifiedName} : ${it.message}" }
+ logger.debug { "Detailed stack trace: ${it}" }
+ throw IllegalArgumentException("Parsing error: " + it.message)
+ },
+ {
+ if (it.isEmpty()) {
+ val message = "Message param list cannot be empty"
+ logger.warn(message)
+ throw IllegalArgumentException(message)
+ }
it
}
)
@@ -85,4 +96,7 @@ class MessageStreamValidation(
private fun decodeConsumedEvents(consumedMessages: List<ByteArray>) =
consumedMessages.map(VesEventOuterClass.VesEvent::parseFrom)
+ companion object {
+ private val logger = Logger(MessageStreamValidation::class)
+ }
}
diff --git a/sources/hv-collector-dcae-app-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/impl/adapters/DcaeAppApiServer.kt b/sources/hv-collector-dcae-app-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/impl/adapters/DcaeAppApiServer.kt
index 1eca9317..a6ee1122 100644
--- a/sources/hv-collector-dcae-app-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/impl/adapters/DcaeAppApiServer.kt
+++ b/sources/hv-collector-dcae-app-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/dcaeapp/impl/adapters/DcaeAppApiServer.kt
@@ -26,6 +26,7 @@ import org.onap.dcae.collectors.veshv.utils.http.HttpStatus
import org.onap.dcae.collectors.veshv.utils.http.Responses
import org.onap.dcae.collectors.veshv.utils.http.sendAndHandleErrors
import org.onap.dcae.collectors.veshv.utils.http.sendOrError
+import org.onap.dcae.collectors.veshv.utils.logging.Logger
import ratpack.handling.Chain
import ratpack.server.RatpackServer
import ratpack.server.ServerConfig
@@ -38,14 +39,14 @@ class DcaeAppApiServer(private val simulator: DcaeAppSimulator) {
private val responseValid by lazy {
Responses.statusResponse(
name = "valid",
- message = "validation succeeded"
+ message = VALID_RESPONSE_MESSAGE
)
}
private val responseInvalid by lazy {
Responses.statusResponse(
name = "invalid",
- message = "validation failed",
+ message = INVALID_RESPONSE_MESSAGE,
httpStatus = HttpStatus.BAD_REQUEST
)
}
@@ -70,12 +71,18 @@ class DcaeAppApiServer(private val simulator: DcaeAppSimulator) {
}
.delete("messages") { ctx ->
ctx.response.contentType(CONTENT_TEXT)
+ logger.info("Resetting simulator state")
ctx.response.sendOrError(simulator.resetState())
}
.get("messages/all/count") { ctx ->
+ logger.info("Processing request for count of received messages")
simulator.state().fold(
- { ctx.response.status(HttpConstants.STATUS_NOT_FOUND) },
{
+ ctx.response.status(HttpConstants.STATUS_NOT_FOUND)
+ logger.warn("Error - number of messages could not be specified")
+ },
+ {
+ logger.info { "Returned number of received messages: ${it.messagesCount}" }
ctx.response
.contentType(CONTENT_TEXT)
.send(it.messagesCount.toString())
@@ -83,19 +90,32 @@ class DcaeAppApiServer(private val simulator: DcaeAppSimulator) {
}
.post("messages/all/validate") { ctx ->
ctx.request.body.then { body ->
+ logger.info("Processing request for message validation")
val response = simulator.validate(body.inputStream)
.map { isValid ->
- if (isValid) responseValid else responseInvalid
+ if (isValid) {
+ logger.info { "Comparison result: $VALID_RESPONSE_MESSAGE" }
+ responseValid
+ } else {
+ logger.info { "Comparison result: $INVALID_RESPONSE_MESSAGE" }
+ responseInvalid
+ }
}
ctx.response.sendAndHandleErrors(response)
}
}
.get("healthcheck") { ctx ->
- ctx.response.status(HttpConstants.STATUS_OK).send()
+ val status = HttpConstants.STATUS_OK
+ logger.info { "Healthcheck OK, returning status: $status" }
+ ctx.response.status(status).send()
}
}
companion object {
private const val CONTENT_TEXT = "text/plain"
+ private const val VALID_RESPONSE_MESSAGE = "validation passed"
+ private const val INVALID_RESPONSE_MESSAGE = "consumed messages don't match data from validation request"
+ private val logger = Logger(DcaeAppApiServer::class)
}
}
+
diff --git a/sources/hv-collector-dcae-app-simulator/src/main/resources/logback.xml b/sources/hv-collector-dcae-app-simulator/src/main/resources/logback.xml
index 09ac3573..4d12b113 100644
--- a/sources/hv-collector-dcae-app-simulator/src/main/resources/logback.xml
+++ b/sources/hv-collector-dcae-app-simulator/src/main/resources/logback.xml
@@ -26,7 +26,7 @@
</rollingPolicy>
</appender>
- <logger name="org.onap.dcae.collectors.veshv" level="INFO"/>
+ <logger name="org.onap.dcae.collectors.veshv" level="DEBUG"/>
<!--<logger name="reactor.netty" level="DEBUG"/>-->
<root level="INFO">
diff --git a/sources/hv-collector-ssl/pom.xml b/sources/hv-collector-ssl/pom.xml
index 6001ba94..98c07f42 100644
--- a/sources/hv-collector-ssl/pom.xml
+++ b/sources/hv-collector-ssl/pom.xml
@@ -93,10 +93,6 @@
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- </dependency>
- <dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
@@ -112,6 +108,11 @@
<groupId>org.jetbrains.spek</groupId>
<artifactId>spek-junit-platform-engine</artifactId>
</dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
diff --git a/sources/hv-collector-test-utils/pom.xml b/sources/hv-collector-test-utils/pom.xml
index aebdd654..3c340828 100644
--- a/sources/hv-collector-test-utils/pom.xml
+++ b/sources/hv-collector-test-utils/pom.xml
@@ -81,5 +81,10 @@
<artifactId>mockito-kotlin</artifactId>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
</project> \ No newline at end of file
diff --git a/sources/hv-collector-test-utils/src/main/resources/logback-test.xml b/sources/hv-collector-test-utils/src/main/resources/logback-test.xml
new file mode 100644
index 00000000..9a4eacfe
--- /dev/null
+++ b/sources/hv-collector-test-utils/src/main/resources/logback-test.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+ <property name="LOG_FILE"
+ value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}ves-hv.log}"/>
+ <property name="FILE_LOG_PATTERN" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC} %-5level [%-40.40logger{10}] - %msg%n"/>
+
+ <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>
+ %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC} %highlight(%-5level) [%-40.40logger{10}] - %msg%n
+ </pattern>
+ </encoder>
+ </appender>
+
+ <appender name="ROLLING-FILE"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <encoder>
+ <pattern>${FILE_LOG_PATTERN}</pattern>
+ </encoder>
+ <file>${LOG_FILE}</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.log</fileNamePattern>
+ <maxFileSize>50MB</maxFileSize>
+ <maxHistory>30</maxHistory>
+ <totalSizeCap>10GB</totalSizeCap>
+ </rollingPolicy>
+ </appender>
+
+ <logger name="org.onap.dcae.collectors.veshv" level="TRACE"/>
+
+ <root level="INFO">
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="ROLLING-FILE"/>
+ </root>
+</configuration>
diff --git a/sources/hv-collector-utils/pom.xml b/sources/hv-collector-utils/pom.xml
index 66879ff7..2490767e 100644
--- a/sources/hv-collector-utils/pom.xml
+++ b/sources/hv-collector-utils/pom.xml
@@ -103,6 +103,11 @@
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
@@ -127,11 +132,6 @@
<artifactId>mockito-kotlin</artifactId>
</dependency>
<dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<scope>provided</scope>
diff --git a/sources/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/http/ratpack.kt b/sources/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/http/ratpack.kt
index 0282d0c7..5a733f24 100644
--- a/sources/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/http/ratpack.kt
+++ b/sources/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/http/ratpack.kt
@@ -42,7 +42,7 @@ fun ratpack.http.Response.sendOrError(action: IO<Unit>) {
}
fun <A> ratpack.http.Response.sendEitherErrorOrResponse(response: Either<A, Response>) {
- when(response) {
+ when (response) {
is Either.Left -> send(errorResponse(response.a.toString()))
is Either.Right -> sendAndHandleErrors(IO.just(response.b))
}
diff --git a/sources/hv-collector-utils/src/test/resources/logback-test.xml b/sources/hv-collector-utils/src/test/resources/logback-test.xml
new file mode 100644
index 00000000..9a4eacfe
--- /dev/null
+++ b/sources/hv-collector-utils/src/test/resources/logback-test.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+ <property name="LOG_FILE"
+ value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}ves-hv.log}"/>
+ <property name="FILE_LOG_PATTERN" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC} %-5level [%-40.40logger{10}] - %msg%n"/>
+
+ <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>
+ %d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC} %highlight(%-5level) [%-40.40logger{10}] - %msg%n
+ </pattern>
+ </encoder>
+ </appender>
+
+ <appender name="ROLLING-FILE"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <encoder>
+ <pattern>${FILE_LOG_PATTERN}</pattern>
+ </encoder>
+ <file>${LOG_FILE}</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.log</fileNamePattern>
+ <maxFileSize>50MB</maxFileSize>
+ <maxHistory>30</maxHistory>
+ <totalSizeCap>10GB</totalSizeCap>
+ </rollingPolicy>
+ </appender>
+
+ <logger name="org.onap.dcae.collectors.veshv" level="TRACE"/>
+
+ <root level="INFO">
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="ROLLING-FILE"/>
+ </root>
+</configuration>
diff --git a/sources/hv-collector-ves-message-generator/pom.xml b/sources/hv-collector-ves-message-generator/pom.xml
index c5ce7f65..29e32f46 100644
--- a/sources/hv-collector-ves-message-generator/pom.xml
+++ b/sources/hv-collector-ves-message-generator/pom.xml
@@ -64,6 +64,11 @@
</dependency>
<dependency>
<groupId>${project.parent.groupId}</groupId>
+ <artifactId>hv-collector-utils</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
<artifactId>hv-collector-test-utils</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
@@ -101,11 +106,6 @@
<artifactId>reactor-test</artifactId>
</dependency>
<dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
</dependency>
diff --git a/sources/hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/MessageParametersParserImpl.kt b/sources/hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/MessageParametersParserImpl.kt
index 6ef6d53a..88cc47a6 100644
--- a/sources/hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/MessageParametersParserImpl.kt
+++ b/sources/hv-collector-ves-message-generator/src/main/kotlin/org/onap/dcae/collectors/veshv/ves/message/generator/impl/MessageParametersParserImpl.kt
@@ -22,6 +22,7 @@ package org.onap.dcae.collectors.veshv.ves.message.generator.impl
import arrow.core.Option
import arrow.core.Try
import arrow.core.identity
+import org.onap.dcae.collectors.veshv.utils.logging.Logger
import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageParameters
import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageParametersParser
import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageType
@@ -40,6 +41,7 @@ internal class MessageParametersParserImpl(
Try {
request
.map { it.asJsonObject() }
+ .onEach { logger.info { "Parsing MessageParameters body: $it" } }
.map { json ->
val commonEventHeader = commonEventHeaderParser
.parse(json.getJsonObject("commonEventHeader"))
@@ -54,4 +56,9 @@ internal class MessageParametersParserImpl(
ex.message ?: "Unable to parse message parameters",
Option.fromNullable(ex))
}
+
+ companion object {
+ private val logger = Logger(MessageParametersParserImpl::class)
+ }
+
}
diff --git a/sources/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/adapters/XnfApiServer.kt b/sources/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/adapters/XnfApiServer.kt
index 06f1cffe..16019384 100644
--- a/sources/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/adapters/XnfApiServer.kt
+++ b/sources/hv-collector-xnf-simulator/src/main/kotlin/org/onap/dcae/collectors/veshv/simulators/xnf/impl/adapters/XnfApiServer.kt
@@ -20,6 +20,7 @@
package org.onap.dcae.collectors.veshv.simulators.xnf.impl.adapters
import arrow.core.Either
+import arrow.core.getOrElse
import arrow.effects.IO
import org.onap.dcae.collectors.veshv.simulators.xnf.impl.OngoingSimulations
import org.onap.dcae.collectors.veshv.simulators.xnf.impl.XnfSimulator
@@ -64,9 +65,13 @@ internal class XnfApiServer(
}
private fun startSimulationHandler(ctx: Context) {
- logger.info("Starting asynchronous scenario")
+ logger.info("Attempting to start asynchronous scenario")
ctx.request.body.then { body ->
val id = startSimulation(body)
+ when (id) {
+ is Either.Left -> logger.warn { "Failed to start scenario, ${id.a}"}
+ is Either.Right -> logger.info { "Scenario started, details: ${id.b}" }
+ }
ctx.response.sendEitherErrorOrResponse(id)
}
}
@@ -78,9 +83,12 @@ internal class XnfApiServer(
}
private fun simulatorStatusHandler(ctx: Context) {
+ logger.debug("Checking task status")
val id = UUID.fromString(ctx.pathTokens["id"])
+ logger.debug { "Checking status for id: $id" }
val status = ongoingSimulations.status(id)
val response = Responses.statusResponse(status.toString(), status.message)
+ logger.info { "Task $id status: $response" }
ctx.response.sendAndHandleErrors(IO.just(response))
}