Enhancements to KPI Computation MS for Kohn Release 99/129899/9
authormalar <malarvizhi.44@wipro.com>
Wed, 13 Jul 2022 05:41:41 +0000 (05:41 +0000)
committermalar <malarvizhi.44@wipro.com>
Wed, 27 Jul 2022 13:48:39 +0000 (13:48 +0000)
- Changes to support two types of PM XML schema
- Throw an exception for Ratio and SumRatio computation when
  minimum operand size is not satisfied

Issue-ID: DCAEGEN2-3193
Signed-off-by: Malarvizhi Paramasivam <malarvizhi.44@wipro.com>
Change-Id: Ie9672bb11a5e98aa681bd1c7c7db59ea2be46112

components/kpi-computation-ms/Changelog.md
components/kpi-computation-ms/pom.xml
components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/computation/KpiComputation.java
components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/computation/RatioKpiComputation.java
components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/computation/SumRatioKpiComputation.java
components/kpi-computation-ms/src/test/java/org/onap/dcaegen2/kpi/computation/KpiComputationTest.java
components/kpi-computation-ms/src/test/resources/kpi/RAN.xml [new file with mode: 0644]
components/kpi-computation-ms/src/test/resources/kpi/kpi_config_slicing.json [new file with mode: 0644]
components/kpi-computation-ms/src/test/resources/kpi/ves_message_slicing.json [new file with mode: 0644]
components/kpi-computation-ms/version.properties

index a094d17..5c9c4f0 100644 (file)
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
 The format is based on [Keep a Changelog](http://keepachangelog.com/)
 and this project adheres to [Semantic Versioning](http://semver.org/).
 
+## [1.0.5]
+### Changed
+* Enhancements to KPI Computation MS for Kohn Release (DCAEGEN2-3193)
+
 ## [1.0.4]
 ### Changed
 * Fix security vulnerability issues (DCAEGEN2-3047)
index c67ece8..1defef1 100644 (file)
@@ -29,7 +29,7 @@
 
     <groupId>org.onap.dcaegen2.services.components</groupId>
     <artifactId>kpi-ms</artifactId>
-    <version>1.0.4-SNAPSHOT</version>
+    <version>1.0.5-SNAPSHOT</version>
     <name>dcaegen2-services-kpi-computation-ms</name>
     <description>Kpi ms</description>
     <packaging>jar</packaging>
             <artifactId>openpojo</artifactId>
             <version>0.8.10</version>
         </dependency>
-       <!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-core -->
+        <!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-core -->
         <dependency>
             <groupId>ch.qos.logback</groupId>
             <artifactId>logback-core</artifactId>
index d349352..5e6c5a4 100644 (file)
@@ -2,6 +2,7 @@
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 China Mobile.
  *  Copyright (C) 2021 Deutsche Telekom AG. All rights reserved.
+ *  Copyright (C) 2022 Wipro Limited. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -169,18 +170,20 @@ public class KpiComputation {
                 if (measValue != null) {
                     key = new StringBuilder().append(operand).toString();
                     int index = measTypesList.indexOf(measValue);
-                    MeasValues measValues = m.getMeasValuesList().stream().findFirst().orElse(null);
-                    List<MeasResult> measResults = measValues.getMeasResults();
-                    String measObjInstId = measValues.getMeasObjInstId();
-                    MeasResult measResult = measResults.stream()
-                            .filter(v -> v.getPvalue() == (index + 1))
-                            .findFirst()
-                            .orElse(null);
-                    if (measResult != null) {
-                        KpiOperand newKpiOperand = new KpiOperand(measObjInstId, new BigDecimal(measResult.getSvalue()));
-                        kpiOperands.add(newKpiOperand);
-                    } else {
-                        logger.info("measResults mis-matched - incorrect ves msg construction");
+                    List<MeasValues> measValuesList = m.getMeasValuesList();
+                    for ( MeasValues measValues : measValuesList) {
+                         List<MeasResult> measResults = measValues.getMeasResults();
+                         String measObjInstId = measValues.getMeasObjInstId();
+                         MeasResult measResult = measResults.stream()
+                                 .filter(v -> v.getPvalue() == (index + 1))
+                                 .findFirst()
+                                 .orElse(null);
+                         if (measResult != null) {
+                             KpiOperand newKpiOperand = new KpiOperand(measObjInstId, new BigDecimal(measResult.getSvalue()));
+                             kpiOperands.add(newKpiOperand);
+                         } else {
+                             logger.info("measResults mis-matched - incorrect ves msg construction");
+                         }
                     }
                 }
             }
index 96559a4..754c357 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  * Copyright (C) 2021 Deutsche Telekom AG. All rights reserved.
+ * Copyright (C) 2022 Wipro Limited. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,6 +31,7 @@ import java.util.Map;
 import java.util.UUID;
 
 import org.onap.dcaegen2.kpi.config.ControlLoopSchemaType;
+import org.onap.dcaegen2.kpi.exception.KpiComputationException;
 import org.onap.dcaegen2.kpi.models.CommonEventHeader;
 import org.onap.dcaegen2.kpi.models.KpiOperand;
 import org.onap.dcaegen2.kpi.models.MeasDataCollection;
@@ -76,6 +78,9 @@ public class RatioKpiComputation extends BaseKpiComputation {
                 }
             }
         }
+        else {
+           throw new KpiComputationException("Insufficient number of operands to perform Ratio computation");
+        }
         return vesEvents;
     }
 }
index a031abd..1c7436a 100644 (file)
@@ -1,6 +1,7 @@
 /*-
 * ============LICENSE_START=======================================================
 * Copyright (C) 2022 Deutsche Telekom AG. All rights reserved.
+* Copyright (C) 2022 Wipro Limited. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -29,6 +30,7 @@ import java.util.ListIterator;
 import java.util.Map;
 
 import org.onap.dcaegen2.kpi.config.ControlLoopSchemaType;
+import org.onap.dcaegen2.kpi.exception.KpiComputationException;
 import org.onap.dcaegen2.kpi.models.CommonEventHeader;
 import org.onap.dcaegen2.kpi.models.KpiOperand;
 import org.onap.dcaegen2.kpi.models.MeasDataCollection;
@@ -78,6 +80,9 @@ public class SumRatioKpiComputation extends BaseKpiComputation {
             BigDecimal result =  sumK1.multiply(new BigDecimal("100")).divide(sumK2, 0, RoundingMode.HALF_UP);
             vesEvents.add(generateVesEvent(pmEvent, schemaType.toString(), result, measType));
         }
+        else {
+            throw new KpiComputationException("Insufficient number of operands to perform SumRatio computation");
+        }
         return vesEvents;
     }
 }
index 1ed6557..4320981 100644 (file)
@@ -2,6 +2,7 @@
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 China Mobile.
  *  Copyright (C) 2022 Deutsche Telekom AG. All rights reserved.
+ *  Copyright (C) 2022 Wipro Limited. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,9 +41,11 @@ public class KpiComputationTest {
     private static final String KPI_CONFIG_FILE = "kpi/kpi_config.json";
     private static final String VES_MESSAGE_FILE = "kpi/ves_message.json";
     private static final String KPI_CONFIG_RATIO_FILE = "kpi/kpi_config_ratio.json";
+    private static final String KPI_CONFIG_SLICING_RATIO_FILE = "kpi/kpi_config_slicing.json";
     private static final String KPI_CONFIG_SUMRATIO_FILE = "kpi/kpi_config_sumratio.json";
     private static final String VES_MESSAGE_EMPTY_FILE = "kpi/ves_message_empty.json";
     private static final String VES_MESSAGE_NULL_FILE = "kpi/ves_message_null.json";
+    private static final String VES_MESSAGE_SLICING_FILE = "kpi/ves_message_slicing.json";
     private static final String VES_MESSAGE_EVENTNAME_FILE = "kpi/ves_message_eventname.json";
 
     @Test
@@ -74,6 +77,18 @@ public class KpiComputationTest {
                  .getMeasValuesList().get(0).getMeasResults().get(0).getSvalue(), "50");
     }
 
+    @Test
+    public void testKpiComputationSlicingRatio() {
+        String strKpiConfigRatio = FileUtils.getFileContents(KPI_CONFIG_SLICING_RATIO_FILE);
+        String vesMessage = FileUtils.getFileContents(VES_MESSAGE_SLICING_FILE);
+        Configuration config = mock(Configuration.class);
+        when(config.getKpiConfig()).thenReturn(strKpiConfigRatio);
+        List<VesEvent> vesList = new KpiComputation().checkAndDoComputation(vesMessage, config);
+        VesEvent vesEvent = vesList.get(0);
+        assertEquals(vesEvent.getEvent().getPerf3gppFields().getMeasDataCollection().getMeasInfoList().get(0)
+                     .getMeasValuesList().get(0).getMeasResults().get(0).getSvalue(), "158");
+    }
+
     @Test
     public void testKpiComputationSumRatio() {
 
diff --git a/components/kpi-computation-ms/src/test/resources/kpi/RAN.xml b/components/kpi-computation-ms/src/test/resources/kpi/RAN.xml
new file mode 100644 (file)
index 0000000..9b8da64
--- /dev/null
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ ============LICENSE_START=======================================================
+~ Copyright (c) 2022 Wipro Limited. All rights reserved.
+~ ================================================================================ 
+~ Licensed under the Apache License, Version 2.0 (the "License");
+~ you may not use this file except in compliance with the License.
+~ You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing, software
+~ distributed under the License is distributed on an "AS IS" BASIS,
+~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~ See the License for the specific language governing permissions and
+~ limitations under the License.
+~ ============LICENSE_END=========================================================
+-->
+<measCollecFile xmlns="http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec">
+  <fileHeader dnPrefix="Prefix" fileFormatVersion="32.435 V10.0" vendorName="Acme Ltd">
+    <fileSender localDn="cucpserver2"/>
+    <measCollec beginTime="2021-01-15T05:46:30.387"/>
+  </fileHeader>
+  <measData>
+    <managedElement localDn="cucpserver2" swVersion="r0.1"/>
+    <measInfo measInfoId="measInfoIsVal">
+      <job jobId="7836"/>
+      <granPeriod duration="PT900S" endTime="2021-01-15T05:46:30.387"/>
+      <repPeriod duration="PT900S"/>
+      <measType p="1">SM.PduSessionCreationSucc.0011-0010</measType>
+      <measType p="2">SM.PduSessionCreationReq.0011-0010</measType>
+      <measType p="3">SM.PduSessionCreationFail.0</measType>
+      <measValue measObjLdn="10896">
+        <r p="1">5813.0</r>
+        <r p="2">3679.0</r>
+        <r p="3">1333.0</r>
+        <suspect>false</suspect>
+      </measValue>
+      <measValue measObjLdn="10897">
+        <r p="1">5637.0</r>
+        <r p="2">3406.0</r>
+        <r p="3">1333.0</r>
+        <suspect>false</suspect>
+      </measValue>
+      <measValue measObjLdn="11561">
+        <r p="1">5130.0</r>
+        <r p="2">3083.0</r>
+        <r p="3">1333.0</r>
+        <suspect>false</suspect>
+      </measValue>
+      <measValue measObjLdn="11562">
+        <r p="1">6020.0</r>
+        <r p="2">3956.0</r>
+        <r p="3">1333.0</r>
+        <suspect>false</suspect>
+      </measValue>
+      <measValue measObjLdn="11568">
+        <r p="1">5527.0</r>
+        <r p="2">4117.0</r>
+        <suspect>false</suspect>
+      </measValue>
+      <measValue measObjLdn="11569">
+        <r p="1">5086.0</r>
+        <r p="2">3206.0</r>
+        <suspect>false</suspect>
+      </measValue>
+      <measValue measObjLdn="13905">
+        <r p="1">1655.0</r>
+        <r p="2">1183.0</r>
+        <suspect>false</suspect>
+      </measValue>
+      <measValue measObjLdn="13910">
+        <r p="1">2587.0</r>
+        <r p="2">1900.0</r>
+        <suspect>false</suspect>
+      </measValue>
+      <measValue measObjLdn="14427">
+        <r p="1">1668.0</r>
+        <r p="2">1217.0</r>
+        <suspect>false</suspect>
+      </measValue>
+      <measValue measObjLdn="14655">
+        <r p="1">4904.0</r>
+        <r p="2">3155.0</r>
+        <suspect>false</suspect>
+      </measValue>
+      <measValue measObjLdn="14656">
+        <r p="1">5357.0</r>
+        <r p="2">3577.0</r>
+        <suspect>false</suspect>
+      </measValue>
+      <measValue measObjLdn="15360">
+        <r p="1">2177.0</r>
+        <r p="2">1438.0</r>
+        <suspect>false</suspect>
+      </measValue>
+      <measValue measObjLdn="15361">
+        <r p="1">2480.0</r>
+        <r p="2">1615.0</r>
+        <suspect>false</suspect>
+      </measValue>
+      <measValue measObjLdn="15548">
+        <r p="1">1730.0</r>
+        <r p="2">1174.0</r>
+        <suspect>false</suspect>
+      </measValue>
+      <measValue measObjLdn="15549">
+        <r p="1">2227.0</r>
+        <r p="2">1341.0</r>
+        <suspect>false</suspect>
+      </measValue>
+    </measInfo>
+  </measData>
+  <fileFooter>
+    <measCollec endTime="2021-01-15T05:46:30.387"/>
+  </fileFooter>
+</measCollecFile>
diff --git a/components/kpi-computation-ms/src/test/resources/kpi/kpi_config_slicing.json b/components/kpi-computation-ms/src/test/resources/kpi/kpi_config_slicing.json
new file mode 100644 (file)
index 0000000..bbc7fb2
--- /dev/null
@@ -0,0 +1,17 @@
+{
+    "domain": "measurementsForKpi",
+    "methodForKpi": [{
+            "eventName": "perf3gpp_CORE-cucpserver2_pmMeasResult",
+            "controlLoopSchemaType": "SLICE",
+            "policyScope": "resource=networkSlice;type=configuration",
+            "policyName": "configuration.dcae.microservice.pm-mapper.xml",
+            "policyVersion": "v0.0.1",
+            "kpis": [{
+                    "measType": "PDUSessionEstSR",
+                    "operation": "RATIO",
+                    "operands": ["SM.PduSessionCreationSucc","SM.PduSessionCreationReq"]
+                }
+            ]
+        }
+    ]
+}
diff --git a/components/kpi-computation-ms/src/test/resources/kpi/ves_message_slicing.json b/components/kpi-computation-ms/src/test/resources/kpi/ves_message_slicing.json
new file mode 100644 (file)
index 0000000..41a8f91
--- /dev/null
@@ -0,0 +1,270 @@
+{
+   "event": {
+      "commonEventHeader": {
+    "domain": "perf3gpp",
+    "eventId": "243f63f4-bb54-4f65-8aab-d254cd5b026d",
+    "sequence": 0,
+    "eventName": "perf3gpp_CORE-cucpserver2_pmMeasResult",
+    "sourceName": "oteNB5309",
+    "reportingEntityName": "",
+    "priority": "Normal",
+    "startEpochMicrosec": 1610689590387,
+    "lastEpochMicrosec": 1610689590387,
+    "version": "4.0",
+    "vesEventListenerVersion": "7.1",
+    "timeZoneOffset": "UTC+05:00"
+      },
+      "perf3gppFields": {
+        "perf3gppFieldsVersion": "1.0",
+        "measDataCollection": {
+      "granularityPeriod": 900,
+      "measuredEntityUserName": "",
+      "measuredEntityDn": "cucpserver2",
+      "measuredEntitySoftwareVersion": "r0.1",
+      "measInfoList": [
+        {
+          "measInfoId": {
+      "sMeasInfoId": "measInfoIsVal"
+          },
+          "measTypes": {
+      "sMeasTypesList": [
+        "SM.PduSessionCreationSucc.0011-0010",
+        "SM.PduSessionCreationReq.0011-0010",
+        "SM.PduSessionCreationFail.0"
+      ]
+          },
+          "measValuesList": [
+       {
+         "measObjInstId": "10896",
+         "suspectFlag": "false",
+         "measResults": [
+           {
+         "p": 1,
+         "sValue": "5813.0"
+           },
+           {
+         "p": 2,
+         "sValue": "3679.0"
+           },
+           {
+         "p": 3,
+         "sValue": "1333.0"
+           }
+         ]
+       },
+       {
+                     "measObjInstId": "10897",
+         "suspectFlag": "false",
+         "measResults": [
+                 {
+             "p": 1,
+             "sValue": "5637.0"
+           },
+           {
+             "p": 2,
+             "sValue": "3406.0"
+           },
+           {
+             "p": 3,
+             "sValue": "1333.0"
+           }
+         ]
+       },
+       {
+         "measObjInstId": "11561",
+         "suspectFlag": "false",
+         "measResults": [
+           {
+             "p": 1,
+             "sValue": "5130.0"
+           },
+           {
+             "p": 2,
+             "sValue": "3083.0"
+           },
+           {
+             "p": 3,
+             "sValue": "1333.0"
+           }
+         ]
+       },
+       {
+         "measObjInstId": "11562",
+         "suspectFlag": "false",
+         "measResults": [
+           {
+             "p": 1,
+             "sValue": "6020.0"
+           },
+           {
+             "p": 2,
+             "sValue": "3956.0"
+           },
+           {
+             "p": 3,
+             "sValue": "1333.0"
+           }
+      
+         ]   
+       },
+       {
+         "measObjInstId": "11568",
+         "suspectFlag": "false",
+         "measResults": [
+           {
+             "p": 1,
+             "sValue": "5527.0"
+           },
+           {
+             "p": 2,
+             "sValue": "4117.0"
+           }
+         ]
+       },
+       {
+         "measObjInstId": "11569",
+         "suspectFlag": "false",
+         "measResults": [
+           {
+             "p": 1,
+             "sValue": "5086.0"
+           },
+           {
+             "p": 2,
+             "sValue": "3206.0"
+           }
+         ]
+       },
+       {
+         "measObjInstId": "13905",
+         "suspectFlag": "false",
+         "measResults": [
+           {
+             "p": 1,
+             "sValue": "1655.0"
+           },
+           {
+             "p": 2,
+             "sValue": "1183.0"
+           }
+         ]
+       },
+       {
+         "measObjInstId": "13910",
+         "suspectFlag": "false",
+         "measResults": [
+           {
+             "p": 1,
+             "sValue": "2587.0"
+           },
+           {
+             "p": 2,
+             "sValue": "1900.0"
+           }
+         ]
+       },
+       {
+         "measObjInstId": "14427",
+         "suspectFlag": "false",
+         "measResults": [
+           {
+             "p": 1,
+             "sValue": "1668.0"
+           },
+           {
+             "p": 2,
+             "sValue": "1217.0"
+           }
+         ]
+       },
+       {
+         "measObjInstId": "14655",
+         "suspectFlag": "false",
+         "measResults": [
+                 {
+             "p": 1,
+             "sValue": "4904.0"
+           },
+           {
+             "p": 2,
+             "sValue": "3155.0"
+           }
+         ]
+       },
+       {
+         "measObjInstId": "14656",
+         "suspectFlag": "false",
+         "measResults": [
+           {
+             "p": 1,
+             "sValue": "5357.0"
+           },
+           {
+             "p": 2,
+             "sValue": "3577.0"
+           }
+         ]
+       },
+       {
+         "measObjInstId": "15360",
+         "suspectFlag": "false",
+         "measResults": [
+           {
+             "p": 1,
+             "sValue": "2177.0"
+           },
+           {
+             "p": 2,
+             "sValue": "1438.0"
+           }
+         ]
+       },
+       {
+         "measObjInstId": "15361",
+         "suspectFlag": "false",
+         "measResults": [
+           {
+             "p": 1,
+             "sValue": "2480.0"
+                 },
+           {
+             "p": 2,
+             "sValue": "1615.0"
+           }
+         ]
+       },
+       {
+         "measObjInstId": "15548",
+         "suspectFlag": "false",
+         "measResults": [
+           {
+             "p": 1,
+             "sValue": "1730.0"
+           },
+           {
+             "p": 2,
+             "sValue": "1174.0"
+           }
+         ]
+       },
+       {
+         "measObjInstId": "15549",
+         "suspectFlag": "false",
+         "measResults": [
+           {
+             "p": 1,                          
+                    "sValue": "2227.0"
+           },
+           {
+             "p": 2,
+             "sValue": "1341.0"
+           }
+         ]
+       }
+         ]
+        }
+          ]
+        }
+      }
+   }
+}
index ada000a..be3c3dd 100644 (file)
@@ -3,6 +3,7 @@
 #  kpi-ms
 #  ================================================================================
 #   Copyright (C) 2021 China Mobile.
+#   Copyright (C) 2022 Wipro Limited. All rights reserved.
 #   ==============================================================================
 #     Licensed under the Apache License, Version 2.0 (the "License");
 #     you may not use this file except in compliance with the License.
@@ -20,7 +21,7 @@
 ###############################################################################
 major=1
 minor=0
-patch=4
+patch=5
 base_version=${major}.${minor}.${patch}
 release_version=${base_version}
 snapshot_version=${base_version}-SNAPSHOT