summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--development/configuration/base.json (renamed from development/configuration/configuration.json)1
-rw-r--r--development/docker-compose.yml1
-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
10 files changed, 103 insertions, 6 deletions
diff --git a/development/configuration/configuration.json b/development/configuration/base.json
index 8e55cf39..5233f02c 100644
--- a/development/configuration/configuration.json
+++ b/development/configuration/base.json
@@ -10,7 +10,6 @@
"requestIntervalSec": 5
},
"security": {
- "sslDisable": false,
"keys": {
"keyStoreFile": "/etc/ves-hv/ssl/server.p12",
"keyStorePassword": "onaponap",
diff --git a/development/docker-compose.yml b/development/docker-compose.yml
index 85500cbb..df00dcd5 100644
--- a/development/docker-compose.yml
+++ b/development/docker-compose.yml
@@ -73,7 +73,6 @@ services:
ports:
- "6060:6060"
- "6061:6061/tcp"
- command: ["--configuration-file /etc/ves-hv/configuration/configuration.json"]
environment:
JAVA_OPTS: "-Dio.netty.leakDetection.level=paranoid -Dlogback.configurationFile=/etc/ONAP/dcae-hv-ves-collector/logback.xml"
CONSUL_HOST: "consul-server"
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