Fix Common Event Header fields validation 09/73009/7
authorJakub Dudycz <jakub.dudycz@nokia.com>
Thu, 15 Nov 2018 12:45:44 +0000 (13:45 +0100)
committerJakub Dudycz <jakub.dudycz@nokia.com>
Tue, 27 Nov 2018 08:42:57 +0000 (09:42 +0100)
- "sequence" is no longer a required parameter,
  since deafult value "0" is acceptable
- "vesEventListenerVersion" has to match the regular expression "7\.[0-9].*"

Change-Id: I784f13c0a35a25beca29f4ae756df3586ddddd5b
Signed-off-by: Jakub Dudycz <jakub.dudycz@nokia.com>
Issue-ID: DCAEGEN2-976

19 files changed:
hv-collector-analysis/pom.xml
hv-collector-core/pom.xml
hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidator.kt
hv-collector-core/src/test/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidatorTest.kt
hv-collector-coverage/pom.xml
hv-collector-ct/pom.xml
hv-collector-dcae-app-simulator/pom.xml
hv-collector-domain/pom.xml
hv-collector-domain/src/main/kotlin/org/onap/dcae/collectors/veshv/domain/validation.kt
hv-collector-domain/src/main/proto/event/VesEvent.proto
hv-collector-health-check/pom.xml
hv-collector-main/pom.xml
hv-collector-ssl/pom.xml
hv-collector-test-utils/pom.xml
hv-collector-test-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/tests/utils/vesEvents.kt
hv-collector-utils/pom.xml
hv-collector-ves-message-generator/pom.xml
hv-collector-xnf-simulator/pom.xml
pom.xml

index 8ea6600..6c45a9f 100644 (file)
@@ -32,7 +32,7 @@
 
     <groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
     <artifactId>hv-collector-analysis</artifactId>
-    <version>1.0.1-SNAPSHOT</version>
+    <version>1.0.2-SNAPSHOT</version>
     <description>VES HighVolume Collector :: Code analysis configuration</description>
 
     <build>
index a893dad..5a098cc 100644 (file)
@@ -33,7 +33,7 @@
     <parent>
         <groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
         <artifactId>ves-hv-collector</artifactId>
-        <version>1.0.1-SNAPSHOT</version>
+        <version>1.0.2-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
index a4a4374..05221e4 100644 (file)
@@ -20,6 +20,7 @@
 package org.onap.dcae.collectors.veshv.impl
 
 import org.onap.dcae.collectors.veshv.domain.headerRequiredFieldDescriptors
+import org.onap.dcae.collectors.veshv.domain.vesEventListenerVersionRegex
 import org.onap.dcae.collectors.veshv.model.VesMessage
 import org.onap.ves.VesEventOuterClass.CommonEventHeader
 
@@ -32,4 +33,5 @@ internal object MessageValidator {
     private fun allMandatoryFieldsArePresent(header: CommonEventHeader) =
             headerRequiredFieldDescriptors
                     .all { fieldDescriptor -> header.hasField(fieldDescriptor) }
+                    .and(vesEventListenerVersionRegex.matches(header.vesEventListenerVersion))
 }
index 443dfa2..872e67e 100644 (file)
@@ -29,10 +29,7 @@ import org.onap.dcae.collectors.veshv.domain.VesEventDomain
 import org.onap.dcae.collectors.veshv.model.VesMessage
 import org.onap.dcae.collectors.veshv.tests.utils.commonHeader
 import org.onap.dcae.collectors.veshv.tests.utils.vesEventBytes
-
-import org.onap.ves.VesEventOuterClass.CommonEventHeader.Priority
-import org.onap.ves.VesEventOuterClass.CommonEventHeader.getDefaultInstance
-import org.onap.ves.VesEventOuterClass.CommonEventHeader.newBuilder
+import org.onap.ves.VesEventOuterClass.CommonEventHeader.*
 
 internal object MessageValidatorTest : Spek({
 
@@ -96,5 +93,36 @@ internal object MessageValidatorTest : Spek({
                 assertThat(cut.isValid(vesMessage)).describedAs("message validation result").isFalse()
             }
         }
+
+        on("ves hv message including header.vesEventListenerVersion with non-string major part") {
+            val commonHeader = commonHeader(vesEventListenerVersion = "sample-version")
+            val rawMessageBytes = vesEventBytes(commonHeader)
+
+
+            it("should not accept message header") {
+                val vesMessage = VesMessage(commonHeader, rawMessageBytes)
+                assertThat(cut.isValid(vesMessage)).describedAs("message validation result").isFalse()
+            }
+        }
+
+        on("ves hv message including header.vesEventListenerVersion with major part != 7") {
+            val commonHeader = commonHeader(vesEventListenerVersion = "1.2.3")
+            val rawMessageBytes = vesEventBytes(commonHeader)
+
+            it("should not accept message header") {
+                val vesMessage = VesMessage(commonHeader, rawMessageBytes)
+                assertThat(cut.isValid(vesMessage)).describedAs("message validation result").isFalse()
+            }
+        }
+
+        on("ves hv message including header.vesEventListenerVersion with minor part not starting with a digit") {
+            val commonHeader = commonHeader(vesEventListenerVersion = "7.test")
+            val rawMessageBytes = vesEventBytes(commonHeader)
+
+            it("should not accept message header") {
+                val vesMessage = VesMessage(commonHeader, rawMessageBytes)
+                assertThat(cut.isValid(vesMessage)).describedAs("message validation result").isFalse()
+            }
+        }
     }
 })
index 9005fde..5ecc6f4 100644 (file)
@@ -33,7 +33,7 @@
     <parent>
         <groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
         <artifactId>ves-hv-collector</artifactId>
-        <version>1.0.1-SNAPSHOT</version>
+        <version>1.0.2-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
index adb9a69..4fd021e 100644 (file)
@@ -33,7 +33,7 @@
     <parent>
         <groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
         <artifactId>ves-hv-collector</artifactId>
-        <version>1.0.1-SNAPSHOT</version>
+        <version>1.0.2-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
index 5cece3d..21ab2e5 100644 (file)
@@ -33,7 +33,7 @@
     <parent>
         <groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
         <artifactId>ves-hv-collector</artifactId>
-        <version>1.0.1-SNAPSHOT</version>
+        <version>1.0.2-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
index afc75ed..e0cd206 100644 (file)
@@ -33,7 +33,7 @@
     <parent>
         <groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
         <artifactId>ves-hv-collector</artifactId>
-        <version>1.0.1-SNAPSHOT</version>
+        <version>1.0.2-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
index 339a652..1eb6239 100644 (file)
@@ -24,7 +24,7 @@ import org.onap.ves.VesEventOuterClass
 val headerRequiredFieldDescriptors = listOf(
         "version",
         "domain",
-        "sequence",
+        /* field "sequence" has been removed from validation, since default value "0" is acceptable */
         "priority",
         "eventId",
         "eventName",
@@ -34,3 +34,5 @@ val headerRequiredFieldDescriptors = listOf(
         "sourceName",
         "vesEventListenerVersion")
         .map { fieldName -> VesEventOuterClass.CommonEventHeader.getDescriptor().findFieldByName(fieldName) }
+
+val vesEventListenerVersionRegex = """7\.[0-9].*""".toRegex()
index dbe0aa3..6d4c230 100644 (file)
@@ -25,21 +25,20 @@ message VesEvent                            // top-level message, currently the
     CommonEventHeader commonEventHeader=1;  // required
 
     bytes eventFields=2;                    // required, payload
-        // this field contains a domain-specific GPB message
-        // the field being opaque (bytes), the decoding of the payload occurs in a separate step
-        // the name of the GPB message for domain XYZ is XyzFields
-        // e.g. for domain==perf3gpp, the GPB message is Perf3gppFields
+    // this field contains a domain-specific GPB message
+    // the field being opaque (bytes), the decoding of the payload occurs in a separate step
+    // the name of the GPB message for domain XYZ is XyzFields
+    // e.g. for domain==perf3gpp, the GPB message is Perf3gppFields
 }
 
 // VES CommonEventHeader adapted to GPB (Google Protocol Buffers)
-// Aligned with VES 7.0.1 schema, and extending to Performance Domain.
 
 message CommonEventHeader
 {
     string version = 1;                     // required, "version of the gpb common event header", current value "1.0"
     string domain = 2;                      // required, "the eventing domain associated with the event", allowed values:
-                                            // fault, heartbeat, measurement, mobileFlow, other, pnfRegistration, sipSignaling,
-                                            // stateChange, syslog, thresholdCrossingAlert, voiceQuality, perf3gpp
+    // fault, heartbeat, measurement, mobileFlow, other, pnfRegistration, sipSignaling,
+    // stateChange, syslog, thresholdCrossingAlert, voiceQuality, perf3gpp
 
     uint32 sequence = 3;                    // required, "ordering of events communicated by an event source instance or 0 if not needed"
 
@@ -69,7 +68,7 @@ message CommonEventHeader
     bytes sourceId = 15;                    // "UUID identifying the entity experiencing the event issue; must be populated by the ATT enrichment process"
     string sourceName = 16;                 // required, "name of the entity experiencing the event issued use A&AI entry"
     string timeZoneOffset = 17;             // "Offset to GMT to indicate local time zone for the device"
-    string vesEventListenerVersion = 18;    // required, "Version of the VesEvent Listener", current value "7.0.2"
+    string vesEventListenerVersion = 18;    // required, "Version of the VesEvent Listener", current value "7.2"
 
     reserved "InternalHeaderFields";        // "enrichment fields for internal VES Event Listener service use only, not supplied by event sources"
     reserved 100;
index f66fe9f..7fbe342 100644 (file)
@@ -19,7 +19,7 @@
     <parent>
         <groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
         <artifactId>ves-hv-collector</artifactId>
-        <version>1.0.1-SNAPSHOT</version>
+        <version>1.0.2-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
index c07323a..08a9eea 100644 (file)
@@ -33,7 +33,7 @@
     <parent>
         <groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
         <artifactId>ves-hv-collector</artifactId>
-        <version>1.0.1-SNAPSHOT</version>
+        <version>1.0.2-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
index df3d56e..9c0a015 100644 (file)
@@ -33,7 +33,7 @@
     <parent>
         <groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
         <artifactId>ves-hv-collector</artifactId>
-        <version>1.0.1-SNAPSHOT</version>
+        <version>1.0.2-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
index 063cf7e..c751fc3 100644 (file)
@@ -14,7 +14,7 @@
     <parent>
         <groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
         <artifactId>ves-hv-collector</artifactId>
-        <version>1.0.1-SNAPSHOT</version>
+        <version>1.0.2-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
index 20d0c50..f3a12ca 100644 (file)
@@ -44,7 +44,8 @@ fun vesEvent(commonEventHeader: CommonEventHeader,
 
 fun commonHeader(domain: VesEventDomain = PERF3GPP,
                  id: String = randomUUID().toString(),
-                 priority: Priority = Priority.NORMAL): CommonEventHeader =
+                 priority: Priority = Priority.NORMAL,
+                 vesEventListenerVersion: String = "7.2"): CommonEventHeader =
         CommonEventHeader.newBuilder()
                 .setVersion("sample-version")
                 .setDomain(domain.domainName)
@@ -63,10 +64,10 @@ fun commonHeader(domain: VesEventDomain = PERF3GPP,
                 .setSourceId(ByteString.copyFromUtf8("sample-source-id"))
                 .setSourceName("sample-source-name")
                 .setTimeZoneOffset("+1")
-                .setVesEventListenerVersion("another-version")
+                .setVesEventListenerVersion(vesEventListenerVersion)
                 .build()
 
 fun vesEventBytes(commonHeader: CommonEventHeader, byteString: ByteString = ByteString.EMPTY): ByteData =
         vesEvent(commonHeader, byteString).toByteData()
 
-fun MessageLite.toByteData(): ByteData = ByteData(toByteArray())
\ No newline at end of file
+fun MessageLite.toByteData(): ByteData = ByteData(toByteArray())
index f60ff9b..55be001 100644 (file)
@@ -37,7 +37,7 @@
     <parent>
         <groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
         <artifactId>ves-hv-collector</artifactId>
-        <version>1.0.1-SNAPSHOT</version>
+        <version>1.0.2-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
index 28d407e..45096fc 100644 (file)
@@ -33,7 +33,7 @@
     <parent>
         <groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
         <artifactId>ves-hv-collector</artifactId>
-        <version>1.0.1-SNAPSHOT</version>
+        <version>1.0.2-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
index 4bfd5ee..83bd19e 100644 (file)
@@ -33,7 +33,7 @@
     <parent>
         <groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
         <artifactId>ves-hv-collector</artifactId>
-        <version>1.0.1-SNAPSHOT</version>
+        <version>1.0.2-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 
diff --git a/pom.xml b/pom.xml
index 3a57732..e328543 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -38,7 +38,7 @@
 
     <groupId>org.onap.dcaegen2.collectors.hv-ves</groupId>
     <artifactId>ves-hv-collector</artifactId>
-    <version>1.0.1-SNAPSHOT</version>
+    <version>1.0.2-SNAPSHOT</version>
     <name>dcaegen2-collectors-veshv</name>
     <description>VES HighVolume Collector</description>
     <packaging>pom</packaging>
@@ -60,7 +60,6 @@
     </modules>
 
     <properties>
-
         <kotlin.version>1.2.70</kotlin.version>
         <arrow.version>0.7.3</arrow.version>
         <maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
@@ -90,7 +89,6 @@
         <docker-image.registry>${onap.nexus.dockerregistry.daily}</docker-image.registry>
         <docker-image.namespace>onap</docker-image.namespace>
         <docker-image.name>${project.groupId}.${project.artifactId}</docker-image.name>
-        <docker-image.latest>1.0-SNAPSHOT</docker-image.latest>
         <docker.http_proxy/>
 
     </properties>
                     <dependency>
                         <groupId>${project.groupId}</groupId>
                         <artifactId>hv-collector-analysis</artifactId>
-                        <version>1.0.1-SNAPSHOT</version>
+                        <version>1.0.2-SNAPSHOT</version>
                     </dependency>
                 </dependencies>
             </plugin>
                                             <tags>
                                                 <tag>${project.version}-${maven.build.timestamp}Z</tag>
                                                 <tag>${project.version}</tag>
-                                                <tag>${docker-image.latest}</tag>
+                                                <tag>latest</tag>
                                             </tags>
                                         </build>
                                     </image>