aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
Diffstat (limited to 'sources')
-rw-r--r--sources/hv-collector-configuration/src/main/kotlin/org/onap/dcae/collectors/veshv/config/api/ConfigurationModule.kt2
-rw-r--r--sources/hv-collector-configuration/src/main/kotlin/org/onap/dcae/collectors/veshv/config/impl/ConfigurationValidator.kt8
-rw-r--r--sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/ConfigurationValidatorTest.kt53
-rw-r--r--sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/FileConfigurationReaderTest.kt12
-rw-r--r--sources/hv-collector-main/Dockerfile5
-rw-r--r--sources/hv-collector-main/src/main/docker/base.json27
-rwxr-xr-xsources/hv-collector-main/src/main/docker/entry.sh (renamed from sources/hv-collector-main/src/main/scripts/entry.sh)0
-rwxr-xr-xsources/hv-collector-main/src/main/docker/healthcheck.sh (renamed from sources/hv-collector-main/src/main/scripts/healthcheck.sh)0
8 files changed, 103 insertions, 4 deletions
diff --git a/sources/hv-collector-configuration/src/main/kotlin/org/onap/dcae/collectors/veshv/config/api/ConfigurationModule.kt b/sources/hv-collector-configuration/src/main/kotlin/org/onap/dcae/collectors/veshv/config/api/ConfigurationModule.kt
index 5b547a28..9f8c552b 100644
--- a/sources/hv-collector-configuration/src/main/kotlin/org/onap/dcae/collectors/veshv/config/api/ConfigurationModule.kt
+++ b/sources/hv-collector-configuration/src/main/kotlin/org/onap/dcae/collectors/veshv/config/api/ConfigurationModule.kt
@@ -37,7 +37,7 @@ class ConfigurationModule {
fun hvVesConfigurationUpdates(args: Array<String>): Flux<HvVesConfiguration> =
Flux.just(cmd.parse(args))
.throwOnLeft { MissingArgumentException(it.message, it.cause) }
- .map { configReader.loadConfig(it.reader()) }
+ .map { it.reader().use(configReader::loadConfig) }
.map { configValidator.validate(it) }
.throwOnLeft { ValidationException(it.message) }
}
diff --git a/sources/hv-collector-configuration/src/main/kotlin/org/onap/dcae/collectors/veshv/config/impl/ConfigurationValidator.kt b/sources/hv-collector-configuration/src/main/kotlin/org/onap/dcae/collectors/veshv/config/impl/ConfigurationValidator.kt
index 6c74c33f..83f56924 100644
--- a/sources/hv-collector-configuration/src/main/kotlin/org/onap/dcae/collectors/veshv/config/impl/ConfigurationValidator.kt
+++ b/sources/hv-collector-configuration/src/main/kotlin/org/onap/dcae/collectors/veshv/config/impl/ConfigurationValidator.kt
@@ -53,7 +53,7 @@ internal class ConfigurationValidator {
.let { createCbsConfiguration(it).bind() }
val securityConfiguration = partialConfig.security.bind()
- .let { createSecurityConfiguration(it).bind() }
+ .let { createSecurityConfiguration(it) }
val collectorConfiguration = partialConfig.collector.bind()
.let { createCollectorConfig(it).bind() }
@@ -94,7 +94,11 @@ internal class ConfigurationValidator {
}
private fun createSecurityConfiguration(partial: PartialSecurityConfig) =
- partial.keys.map { SecurityConfiguration(Some(it)) }
+ partial.keys
+ .fold(
+ { SecurityConfiguration(None) },
+ { SecurityConfiguration(Some(it)) }
+ )
private fun createCollectorConfig(partial: PartialCollectorConfig) =
partial.mapBinding {
diff --git a/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/ConfigurationValidatorTest.kt b/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/ConfigurationValidatorTest.kt
index 12396d23..beb5df61 100644
--- a/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/ConfigurationValidatorTest.kt
+++ b/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/ConfigurationValidatorTest.kt
@@ -20,6 +20,7 @@
package org.onap.dcae.collectors.veshv.config.impl
import arrow.core.None
+import arrow.core.Option
import arrow.core.Some
import com.nhaarman.mockitokotlin2.mock
import org.assertj.core.api.Assertions.assertThat
@@ -134,5 +135,57 @@ internal object ConfigurationValidatorTest : Spek({
)
}
}
+
+ describe("validating configuration with security disabled") {
+ val idleTimeoutSec = 10
+ val firstReqDelaySec = 10
+ val securityKeys: Option<SecurityKeys> = None
+ val routing = routing { }.build()
+
+ val config = PartialConfiguration(
+ Some(PartialServerConfig(
+ Some(1),
+ Some(idleTimeoutSec),
+ Some(2)
+ )),
+ Some(PartialCbsConfig(
+ Some(firstReqDelaySec),
+ Some(3)
+ )),
+ Some(PartialSecurityConfig(
+ securityKeys
+ )),
+ Some(PartialCollectorConfig(
+ Some(true),
+ Some(4),
+ Some(emptyList()),
+ Some(routing)
+ )),
+ Some(LogLevel.INFO)
+ )
+
+ it("should create valid configuration") {
+ val result = cut.validate(config)
+ result.fold(
+ {
+ fail("Configuration should have been created successfully but was $it")
+ },
+ {
+ assertThat(it.server.idleTimeout)
+ .isEqualTo(Duration.ofSeconds(idleTimeoutSec.toLong()))
+
+ assertThat(it.security.keys)
+ .isEqualTo(securityKeys)
+
+ assertThat(it.cbs.firstRequestDelay)
+ .isEqualTo(Duration.ofSeconds(firstReqDelaySec.toLong()))
+
+ assertThat(it.collector.routing)
+ .isEqualTo(routing)
+ }
+ )
+ }
+ }
+
}
})
diff --git a/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/FileConfigurationReaderTest.kt b/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/FileConfigurationReaderTest.kt
index ab99f13c..8267e304 100644
--- a/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/FileConfigurationReaderTest.kt
+++ b/sources/hv-collector-configuration/src/test/kotlin/org/onap/dcae/collectors/veshv/config/impl/FileConfigurationReaderTest.kt
@@ -103,6 +103,18 @@ internal object FileConfigurationReaderTest : Spek({
}
}
+ it("parses disabled security configuration") {
+ val input = """{
+ "security": {
+ }
+ }""".trimIndent()
+ val config = cut.loadConfig(StringReader(input))
+
+ assertThat(config.security.nonEmpty()).isTrue()
+ val security = config.security.orNull() as PartialSecurityConfig
+ assertThat(security.keys.nonEmpty()).isFalse()
+ }
+
it("parses invalid log level string to empty option") {
val input = """{
"logLevel": something
diff --git a/sources/hv-collector-main/Dockerfile b/sources/hv-collector-main/Dockerfile
index 3322059c..a1e89a73 100644
--- a/sources/hv-collector-main/Dockerfile
+++ b/sources/hv-collector-main/Dockerfile
@@ -12,8 +12,11 @@ RUN apt-get update \
WORKDIR /opt/ves-hv-collector
ENTRYPOINT ["./entry.sh"]
+CMD ["--configuration-file /etc/ves-hv/configuration/base.json"]
COPY target/libs/external/* ./
COPY target/libs/internal/* ./
-COPY src/main/scripts/*.sh ./
+COPY src/main/docker/*.sh ./
+COPY src/main/docker/base.json /etc/ves-hv/configuration/base.json
+
COPY target/hv-collector-main-*.jar ./
diff --git a/sources/hv-collector-main/src/main/docker/base.json b/sources/hv-collector-main/src/main/docker/base.json
new file mode 100644
index 00000000..7f88cb6e
--- /dev/null
+++ b/sources/hv-collector-main/src/main/docker/base.json
@@ -0,0 +1,27 @@
+{
+ "logLevel": "INFO",
+ "server": {
+ "listenPort": 6061,
+ "idleTimeoutSec": 60,
+ "maxPayloadSizeBytes": 1048576
+ },
+ "cbs": {
+ "firstRequestDelaySec": 10,
+ "requestIntervalSec": 5
+ },
+ "security": {
+ },
+ "collector": {
+ "dummyMode": false,
+ "maxRequestSizeBytes": 1048576,
+ "kafkaServers": [
+ "message-router-kafka:9092"
+ ],
+ "routing": [
+ {
+ "fromDomain": "perf3gpp",
+ "toTopic": "HV_VES_PERF3GPP"
+ }
+ ]
+ }
+}
diff --git a/sources/hv-collector-main/src/main/scripts/entry.sh b/sources/hv-collector-main/src/main/docker/entry.sh
index a612e393..a612e393 100755
--- a/sources/hv-collector-main/src/main/scripts/entry.sh
+++ b/sources/hv-collector-main/src/main/docker/entry.sh
diff --git a/sources/hv-collector-main/src/main/scripts/healthcheck.sh b/sources/hv-collector-main/src/main/docker/healthcheck.sh
index db62eece..db62eece 100755
--- a/sources/hv-collector-main/src/main/scripts/healthcheck.sh
+++ b/sources/hv-collector-main/src/main/docker/healthcheck.sh