aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidator.kt4
-rw-r--r--hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidatorTest.kt73
-rw-r--r--hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/adapters/ConsulConfigurationProviderTest.kt4
-rw-r--r--hv-collector-domain/src/main/proto/VesEvent-v5.proto32
4 files changed, 78 insertions, 35 deletions
diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidator.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidator.kt
index 4586d30c..543d7dc6 100644
--- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidator.kt
+++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidator.kt
@@ -27,11 +27,11 @@ internal object MessageValidator {
private val requiredFieldDescriptors = listOf(
"version",
"eventName",
- // "domain", TODO to be restored back when GPB schema will include default value
+ "domain",
"eventId",
"sourceName",
"reportingEntityName",
- // "priority", TODO to be restored back when GPB schema will include default value
+ "priority",
"startEpochMicrosec",
"lastEpochMicrosec",
"sequence")
diff --git a/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidatorTest.kt b/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidatorTest.kt
index a2a26b31..eb8971c3 100644
--- a/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidatorTest.kt
+++ b/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidatorTest.kt
@@ -49,18 +49,7 @@ internal object MessageValidatorTest : Spek({
val cut = MessageValidator
on("ves hv message including header with fully initialized fields") {
- val commonHeader = newBuilder()
- .setVersion("1.9")
- .setEventName("Sample event name")
- .setDomain(Domain.HVRANMEAS)
- .setEventId("Sample event Id")
- .setSourceName("Sample Source")
- .setReportingEntityName(ByteString.copyFromUtf8("Sample byte String"))
- .setPriority(Priority.MEDIUM)
- .setStartEpochMicrosec(120034455)
- .setLastEpochMicrosec(120034459)
- .setSequence(2)
- .build()
+ val commonHeader = createInitializedHeaderBuilder().build()
it("should accept message with fully initialized message header") {
val vesMessage = VesMessage(commonHeader, vesMessageBytes(commonHeader))
@@ -68,9 +57,9 @@ internal object MessageValidatorTest : Spek({
}
Domain.values()
- .filter { it != Domain.UNRECOGNIZED }
- .forEach {domain ->
- it("should accept message with $domain domain"){
+ .filter { (it != Domain.UNRECOGNIZED && it != Domain.DOMAIN_UNDEFINED) }
+ .forEach { domain ->
+ it("should accept message with $domain domain") {
val header = newBuilder(commonHeader).setDomain(domain).build()
val vesMessage = VesMessage(header, vesMessageBytes(header))
assertThat(cut.isValid(vesMessage))
@@ -87,6 +76,45 @@ internal object MessageValidatorTest : Spek({
}
+ val domainTestCases = mapOf(
+ Domain.DOMAIN_UNDEFINED to false,
+ Domain.FAULT to true
+ )
+
+ domainTestCases.forEach { value, expectedResult ->
+ on("ves hv message including header with domain $value") {
+ val commonEventHeader = createInitializedHeaderBuilder()
+ .setDomain(value)
+ .build()
+ val vesMessage = VesMessage(commonEventHeader, vesMessageBytes(commonEventHeader))
+
+ it("should resolve validation result") {
+ assertThat(cut.isValid(vesMessage)).describedAs("message validation results")
+ .isEqualTo(expectedResult)
+ }
+ }
+ }
+
+ val priorityTestCases = mapOf(
+ Priority.PRIORITY_UNDEFINED to false,
+ Priority.HIGH to true
+ )
+
+ priorityTestCases.forEach { value, expectedResult ->
+ on("ves hv message including header with priority $value") {
+ val commonEventHeader = createInitializedHeaderBuilder()
+ .setPriority(value)
+ .build()
+ val vesMessage = VesMessage(commonEventHeader, vesMessageBytes(commonEventHeader))
+
+ it("should resolve validation result") {
+ assertThat(cut.isValid(vesMessage)).describedAs("message validation results")
+ .isEqualTo(expectedResult)
+ }
+ }
+ }
+
+
on("ves hv message including header with not initialized fields") {
val commonHeader = newBuilder()
.setVersion("1.9")
@@ -106,4 +134,17 @@ internal object MessageValidatorTest : Spek({
}
}
}
-}) \ No newline at end of file
+})
+
+private fun createInitializedHeaderBuilder(): CommonEventHeader.Builder =
+ newBuilder()
+ .setVersion("1.9")
+ .setEventName("Sample event name")
+ .setDomain(Domain.HVRANMEAS)
+ .setEventId("Sample event Id")
+ .setSourceName("Sample Source")
+ .setReportingEntityName(ByteString.copyFromUtf8("Sample byte String"))
+ .setPriority(Priority.MEDIUM)
+ .setStartEpochMicrosec(120034455)
+ .setLastEpochMicrosec(120034459)
+ .setSequence(2) \ No newline at end of file
diff --git a/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/adapters/ConsulConfigurationProviderTest.kt b/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/adapters/ConsulConfigurationProviderTest.kt
index 808a6fcc..f4c527a4 100644
--- a/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/adapters/ConsulConfigurationProviderTest.kt
+++ b/hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/adapters/ConsulConfigurationProviderTest.kt
@@ -68,11 +68,11 @@ internal object ConsulConfigurationProviderTest : Spek({
assertEquals("kafka:9093", it.kafkaBootstrapServers)
val route1 = it.routing.routes[0]
- assertEquals(Domain.HEARTBEAT, route1.domain)
+ assertEquals(Domain.FAULT, route1.domain)
assertEquals("test-topic-1", route1.targetTopic)
val route2 = it.routing.routes[1]
- assertEquals(Domain.MEASUREMENTS_FOR_VF_SCALING, route2.domain)
+ assertEquals(Domain.HEARTBEAT, route2.domain)
assertEquals("test-topic-2", route2.targetTopic)
}.verifyComplete()
diff --git a/hv-collector-domain/src/main/proto/VesEvent-v5.proto b/hv-collector-domain/src/main/proto/VesEvent-v5.proto
index 022cce4e..340133b2 100644
--- a/hv-collector-domain/src/main/proto/VesEvent-v5.proto
+++ b/hv-collector-domain/src/main/proto/VesEvent-v5.proto
@@ -30,27 +30,29 @@ message VesEvent {
message CommonEventHeader {
string version = 1; // required, "version of the event header"
enum Domain {
- FAULT = 0;
- HEARTBEAT = 1;
- MEASUREMENTS_FOR_VF_SCALING = 2;
- MOBILE_FLOW = 3;
- SIP_SIGNALING = 4;
- STATE_CHANGE = 5;
- SYSLOG = 6;
- THRESHOLD_CROSSING_ALERT = 7;
- VOICE_QUALITY = 8;
- OTHER = 9;
- HVRANMEAS = 10;
+ DOMAIN_UNDEFINED = 0;
+ FAULT = 1;
+ HEARTBEAT = 2;
+ MEASUREMENTS_FOR_VF_SCALING = 3;
+ MOBILE_FLOW = 4;
+ SIP_SIGNALING = 5;
+ STATE_CHANGE = 6;
+ SYSLOG = 7;
+ THRESHOLD_CROSSING_ALERT = 8;
+ VOICE_QUALITY = 9;
+ OTHER = 10;
+ HVRANMEAS = 11;
}
Domain domain = 2; // required, "the eventing domain associated with the event" [map to string]
uint32 sequence = 3; // required, "ordering of events communicated by an event source instance or 0 if not needed"
enum Priority {
- HIGH = 0;
- MEDIUM = 1;
- NORMAL = 2;
- LOW = 3;
+ PRIORITY_UNDEFINED = 0;
+ HIGH = 1;
+ MEDIUM = 2;
+ NORMAL = 3;
+ LOW = 4;
}
Priority priority = 4; // required, "processing priority"