Fix bug in wrong SNSSAI value being appended with MeasType string 90/132090/5 1.0.11-kpi-computation-ms
authormalar <malarvizhi.44@wipro.com>
Wed, 9 Nov 2022 10:26:31 +0000 (10:26 +0000)
committermalar <malarvizhi.44@wipro.com>
Thu, 17 Nov 2022 08:25:56 +0000 (08:25 +0000)
The SNSSAI can be a alphanumeric also, so modified the code acording to that.

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

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/test/java/org/onap/dcaegen2/kpi/computation/KpiComputationTest.java
components/kpi-computation-ms/src/test/resources/kpi/ves_message_slicing.json
components/kpi-computation-ms/src/test/resources/kpi/ves_message_slicing_multiplesnssai.json
components/kpi-computation-ms/version.properties

index e96d788..3031990 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.11]
+### Changed
+* Fix bug in wrong SNSSAI value being appended with MeasType string (DCAEGEN2-3310)
+
 ## [1.0.10]
 ### Changed
 * Revert commit - KPI MS - Switch from Cambria library to dmaap-client library (dcaegen2/sdk) (DCAEGEN2-3180)
index 8ee8280..e60d12a 100644 (file)
@@ -29,7 +29,7 @@
 
     <groupId>org.onap.dcaegen2.services.components</groupId>
     <artifactId>kpi-ms</artifactId>
-    <version>1.0.10-SNAPSHOT</version>
+    <version>1.0.11-SNAPSHOT</version>
     <name>dcaegen2-services-kpi-computation-ms</name>
     <description>Kpi ms</description>
     <packaging>jar</packaging>
index 8a7b9e0..4dd2601 100644 (file)
@@ -65,6 +65,7 @@ import org.slf4j.LoggerFactory;
 public class KpiComputation {
 
     private static Logger logger = LoggerFactory.getLogger(KpiComputation.class);
+    String value = "";
 
     /**
      * do KPI computation.
@@ -112,23 +113,26 @@ public class KpiComputation {
                  .map(MeasDataCollection::getMeasInfoList)
                  .orElseThrow(() -> new KpiComputationException("Required Field: MeasInfoList not present"));
 
+  
         StringBuilder sb = new StringBuilder();
         for(MeasInfo measInfo: measInfoList){
            List<String> measTypes = measInfo.getMeasTypes().getMeasTypesList();
            if(!measTypes.isEmpty()){
               String anyString = measTypes.get(0);
-              char[] chars = anyString.toCharArray();
-              for(char c : chars){
-                 if(Character.isDigit(c)){
-                    sb.append(c);
-                 }
+              if(anyString.contains("."))
+              {
+                 value = anyString.substring(anyString.lastIndexOf(".")+ 1);
+                 logger.info("The value string is {}",value);
+              }
+              else {
+                 logger.info( "MeasType does not contain Snssai separated by a dot");
               }
            }
            else{
               logger.info("MeasTypesList is empty");
            }
         }
-        String snssai = sb.toString();
+
         // Do computation for each KPI
         List<VesEvent> events = new LinkedList<>();
         List<Kpi> kpis = methodForKpi.getKpis();
@@ -140,7 +144,12 @@ public class KpiComputation {
             }
 
             ControlLoopSchemaType schemaType = methodForKpi.getControlLoopSchemaType();
-            String measType = k.getMeasType() + "." + snssai;
+            sb.append(k.getMeasType());
+            sb.append(".");
+            sb.append(value);
+            String measType = sb.toString();
+            logger.info("measType is {}", measType);
+     
             Operation operation = k.getOperation();
 
             List<VesEvent> kpiVesEvent = CommandHandler.handle(operation.value, pmEvent, schemaType,
index c228b59..8fbbb1d 100644 (file)
@@ -106,35 +106,21 @@ public class RatioKpiComputation extends BaseKpiComputation {
                    }
                }
 
-                StringBuilder sb = new StringBuilder();
-                if(!operand.isEmpty()){
-                   char[] chars = operand.toCharArray();
-                   for(char c : chars){
-                      if(Character.isDigit(c)){
-                         sb.append(c);
-                      }
-                   }
+                String snssai = "";
+                if(!operand.isEmpty() && operand.contains(".")){
+                  snssai = operand.substring(operand.lastIndexOf(".") + 1);
                 }
                 else{
                    logger.info("operand is empty");
                 }
 
-                String snssai = sb.toString();
-
-                StringBuilder sb1 = new StringBuilder();
+                String meas = "";
                 if(!measType.isEmpty()){
-                   char[] chars = measType.toCharArray();
-                   for(char c : chars){
-                      if(!Character.isDigit(c)){
-                        sb1.append(c);
-                      }
-                   }
+                   meas = measType.substring( 0, measType.lastIndexOf(".") + 1);
                 }
                 else{
                    logger.info("measType is empty");
                 }
-
-                String meas = sb1.toString();
                 String measTypes = meas + snssai;
 
                 if (myK2.getValue().compareTo(BigDecimal.ZERO) != 0) {
index 79f7e49..c5e0dc3 100644 (file)
@@ -108,7 +108,7 @@ public class KpiComputationTest {
         List<VesEvent> vesList = new KpiComputation().checkAndDoComputation(vesMessage, config);
         VesEvent vesEvent = vesList.get(0);
         assertEquals(vesEvent.getEvent().getPerf3gppFields().getMeasDataCollection().getMeasInfoList().get(0)
-                .getMeasTypes().getMeasTypesList().get(0), "PDUSessionEstSR.00110010");
+                .getMeasTypes().getMeasTypesList().get(0), "PDUSessionEstSR.01-B989BD");
     }
 
     @Test
@@ -121,9 +121,9 @@ public class KpiComputationTest {
         VesEvent vesEvent = vesList.get(0);
         VesEvent anotherVesEvent = vesList.get(18);
         assertEquals(vesEvent.getEvent().getPerf3gppFields().getMeasDataCollection().getMeasInfoList().get(0)
-                .getMeasTypes().getMeasTypesList().get(0), "PDUSessionEstSR.00110010");
+                .getMeasTypes().getMeasTypesList().get(0), "PDUSessionEstSR.01-B989BD");
         assertEquals(anotherVesEvent.getEvent().getPerf3gppFields().getMeasDataCollection().getMeasInfoList().get(0)
-                      .getMeasTypes().getMeasTypesList().get(0), "PDUSessionEstSR.00101110");
+                      .getMeasTypes().getMeasTypesList().get(0), "PDUSessionEstSR.01-B989BD");
     }
     
     @Test
index 41a8f91..2081b06 100644 (file)
@@ -28,8 +28,8 @@
           },
           "measTypes": {
       "sMeasTypesList": [
-        "SM.PduSessionCreationSucc.0011-0010",
-        "SM.PduSessionCreationReq.0011-0010",
+        "SM.PduSessionCreationSucc.01-B989BD",
+        "SM.PduSessionCreationReq.01-B989BD",
         "SM.PduSessionCreationFail.0"
       ]
           },
index fe87d1a..1a3e5e8 100644 (file)
@@ -1 +1 @@
-{  "event": {    "commonEventHeader": {      "domain": "perf3gpp",      "eventId": "42b8917b-aa11-49aa-84ca-084147ca7a3c",      "sequence": 0,      "eventName": "perf3gpp_CORE-cucpserver2_pmMeasResult",      "sourceName": "oteNB5309",      "reportingEntityName": "",      "priority": "Normal",      "startEpochMicrosec": 1606743157914,      "lastEpochMicrosec": 1606743157915,      "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.PduSessionCreationReq.0011-0010",                "SM.PduSessionCreationSucc.0011-0010",                "SM.PduSessionCreationReq.0010-1110",                "SM.PduSessionCreationSucc.0010-1110",                "SM.PduSessionSetupFail.0"              ]            },            "measValuesList": [              {                "measObjInstId": "10896",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "1400.0"                  },                  {                    "p": 2,                    "sValue": "1008.0"                  },                  {                    "p": 4,                    "sValue": "2853.0"                  },                  {                    "p": 5,                    "sValue": "1819.0"                  },                  {                    "p": 3,                    "sValue": "1297.0"                  }                ]              },              {                "measObjInstId": "10897",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "1765.0"                  },                  {                    "p": 2,                    "sValue": "1105.0"                  },                  {                    "p": 4,                    "sValue": "2757.0"                  },                  {                    "p": 5,                    "sValue": "1684.0"                  },                  {                    "p": 3,                    "sValue": "1612.0"                  }                ]              },              {                "measObjInstId": "11561",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "2113.0"                  },                  {                    "p": 2,                    "sValue": "1442.0"                  },                  {                    "p": 4,                    "sValue": "3550.0"                  },                  {                    "p": 5,                    "sValue": "2298.0"                  },                  {                    "p": 3,                    "sValue": "1731.0"                  }                ]              },              {                "measObjInstId": "11562",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "1414.0"                  },                  {                    "p": 2,                    "sValue": "1020.0"                  },                  {                    "p": 4,                    "sValue": "2778.0"                  },                  {                    "p": 5,                    "sValue": "1753.0"                  },                  {                    "p": 3,                    "sValue": "1299.0"                  }                ]              },              {                "measObjInstId": "11568",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "2338.0"                  },                  {                    "p": 2,                    "sValue": "1469.0"                  },                  {                    "p": 4,                    "sValue": "3140.0"                  },                  {                    "p": 5,                    "sValue": "2264.0"                  },                  {                    "p": 3,                    "sValue": "1635.0"                  }                ]              },              {                "measObjInstId": "11569",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "2200.0"                  },                  {                    "p": 2,                    "sValue": "1486.0"                  },                  {                    "p": 4,                    "sValue": "2297.0"                  },                  {                    "p": 5,                    "sValue": "1485.0"                  },                  {                    "p": 3,                    "sValue": "1447.0"                  }                ]              },              {                "measObjInstId": "13905",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "4541.0"                  },                  {                    "p": 2,                    "sValue": "3054.0"                  },                  {                    "p": 4,                    "sValue": "7301.0"                  },                  {                    "p": 5,                    "sValue": "5351.0"                  },                  {                    "p": 3,                    "sValue": "3209.0"                  }                ]              },              {                "measObjInstId": "13910",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "4699.0"                  },                  {                    "p": 2,                    "sValue": "3104.0"                  },                  {                    "p": 4,                    "sValue": "7467.0"                  },                  {                    "p": 5,                    "sValue": "5141.0"                  },                  {                    "p": 3,                    "sValue": "3532.0"                  }                ]              },              {                "measObjInstId": "14427",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "5840.0"                  },                  {                    "p": 2,                    "sValue": "4264.0"                  },                  {                    "p": 4,                    "sValue": "7445.0"                  },                  {                    "p": 5,                    "sValue": "4974.0"                  },                  {                    "p": 3,                    "sValue": "3746.0"                  }                ]              },              {                "measObjInstId": "14655",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "2536.0"                  },                  {                    "p": 2,                    "sValue": "1895.0"                  },                  {                    "p": 4,                    "sValue": "3227.0"                  },                  {                    "p": 5,                    "sValue": "2113.0"                  },                  {                    "p": 3,                    "sValue": "1618.0"                  }                ]              },              {                "measObjInstId": "14656",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "2322.0"                  },                  {                    "p": 2,                    "sValue": "1520.0"                  },                  {                    "p": 4,                    "sValue": "1889.0"                  },                  {                    "p": 5,                    "sValue": "1212.0"                  },                  {                    "p": 3,                    "sValue": "1374.0"                  }                ]              },              {                "measObjInstId": "15360",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "5859.0"                  },                  {                    "p": 2,                    "sValue": "3894.0"                  },                  {                    "p": 4,                    "sValue": "6347.0"                  },                  {                    "p": 5,                    "sValue": "3922.0"                  },                  {                    "p": 3,                    "sValue": "4080.0"                  }                ]              },              {                "measObjInstId": "15361",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "5753.0"                  },                  {                    "p": 2,                    "sValue": "4194.0"                  },                  {                    "p": 4,                    "sValue": "8075.0"                  },                  {                    "p": 5,                    "sValue": "5585.0"                  },                  {                    "p": 3,                    "sValue": "3746.0"                  }                ]              },              {                "measObjInstId": "15548",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "4562.0"                  },                  {                    "p": 2,                    "sValue": "2896.0"                  },                  {                    "p": 4,                    "sValue": "6591.0"                  },                  {                    "p": 5,                    "sValue": "4534.0"                  },                  {                    "p": 3,                    "sValue": "3504.0"                  }                ]              },              {                "measObjInstId": "15549",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "4918.0"                  },                  {                    "p": 2,                    "sValue": "3244.0"                  },                  {                    "p": 4,                    "sValue": "6916.0"                  },                  {                    "p": 5,                    "sValue": "4883.0"                  },                  {                    "p": 3,                    "sValue": "3491.0"                  }                ]              }            ]          }        ]      }    }  }}
+{  "event": {    "commonEventHeader": {      "domain": "perf3gpp",      "eventId": "42b8917b-aa11-49aa-84ca-084147ca7a3c",      "sequence": 0,      "eventName": "perf3gpp_CORE-cucpserver2_pmMeasResult",      "sourceName": "oteNB5309",      "reportingEntityName": "",      "priority": "Normal",      "startEpochMicrosec": 1606743157914,      "lastEpochMicrosec": 1606743157915,      "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.PduSessionCreationReq.01-B989BD",                "SM.PduSessionCreationSucc.01-B989BD",                "SM.PduSessionCreationReq.01-B989BD",                "SM.PduSessionCreationSucc.01-B989BD",                "SM.PduSessionSetupFail.0"              ]            },            "measValuesList": [              {                "measObjInstId": "10896",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "1400.0"                  },                  {                    "p": 2,                    "sValue": "1008.0"                  },                  {                    "p": 4,                    "sValue": "2853.0"                  },                  {                    "p": 5,                    "sValue": "1819.0"                  },                  {                    "p": 3,                    "sValue": "1297.0"                  }                ]              },              {                "measObjInstId": "10897",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "1765.0"                  },                  {                    "p": 2,                    "sValue": "1105.0"                  },                  {                    "p": 4,                    "sValue": "2757.0"                  },                  {                    "p": 5,                    "sValue": "1684.0"                  },                  {                    "p": 3,                    "sValue": "1612.0"                  }                ]              },              {                "measObjInstId": "11561",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "2113.0"                  },                  {                    "p": 2,                    "sValue": "1442.0"                  },                  {                    "p": 4,                    "sValue": "3550.0"                  },                  {                    "p": 5,                    "sValue": "2298.0"                  },                  {                    "p": 3,                    "sValue": "1731.0"                  }                ]              },              {                "measObjInstId": "11562",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "1414.0"                  },                  {                    "p": 2,                    "sValue": "1020.0"                  },                  {                    "p": 4,                    "sValue": "2778.0"                  },                  {                    "p": 5,                    "sValue": "1753.0"                  },                  {                    "p": 3,                    "sValue": "1299.0"                  }                ]              },              {                "measObjInstId": "11568",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "2338.0"                  },                  {                    "p": 2,                    "sValue": "1469.0"                  },                  {                    "p": 4,                    "sValue": "3140.0"                  },                  {                    "p": 5,                    "sValue": "2264.0"                  },                  {                    "p": 3,                    "sValue": "1635.0"                  }                ]              },              {                "measObjInstId": "11569",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "2200.0"                  },                  {                    "p": 2,                    "sValue": "1486.0"                  },                  {                    "p": 4,                    "sValue": "2297.0"                  },                  {                    "p": 5,                    "sValue": "1485.0"                  },                  {                    "p": 3,                    "sValue": "1447.0"                  }                ]              },              {                "measObjInstId": "13905",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "4541.0"                  },                  {                    "p": 2,                    "sValue": "3054.0"                  },                  {                    "p": 4,                    "sValue": "7301.0"                  },                  {                    "p": 5,                    "sValue": "5351.0"                  },                  {                    "p": 3,                    "sValue": "3209.0"                  }                ]              },              {                "measObjInstId": "13910",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "4699.0"                  },                  {                    "p": 2,                    "sValue": "3104.0"                  },                  {                    "p": 4,                    "sValue": "7467.0"                  },                  {                    "p": 5,                    "sValue": "5141.0"                  },                  {                    "p": 3,                    "sValue": "3532.0"                  }                ]              },              {                "measObjInstId": "14427",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "5840.0"                  },                  {                    "p": 2,                    "sValue": "4264.0"                  },                  {                    "p": 4,                    "sValue": "7445.0"                  },                  {                    "p": 5,                    "sValue": "4974.0"                  },                  {                    "p": 3,                    "sValue": "3746.0"                  }                ]              },              {                "measObjInstId": "14655",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "2536.0"                  },                  {                    "p": 2,                    "sValue": "1895.0"                  },                  {                    "p": 4,                    "sValue": "3227.0"                  },                  {                    "p": 5,                    "sValue": "2113.0"                  },                  {                    "p": 3,                    "sValue": "1618.0"                  }                ]              },              {                "measObjInstId": "14656",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "2322.0"                  },                  {                    "p": 2,                    "sValue": "1520.0"                  },                  {                    "p": 4,                    "sValue": "1889.0"                  },                  {                    "p": 5,                    "sValue": "1212.0"                  },                  {                    "p": 3,                    "sValue": "1374.0"                  }                ]              },              {                "measObjInstId": "15360",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "5859.0"                  },                  {                    "p": 2,                    "sValue": "3894.0"                  },                  {                    "p": 4,                    "sValue": "6347.0"                  },                  {                    "p": 5,                    "sValue": "3922.0"                  },                  {                    "p": 3,                    "sValue": "4080.0"                  }                ]              },              {                "measObjInstId": "15361",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "5753.0"                  },                  {                    "p": 2,                    "sValue": "4194.0"                  },                  {                    "p": 4,                    "sValue": "8075.0"                  },                  {                    "p": 5,                    "sValue": "5585.0"                  },                  {                    "p": 3,                    "sValue": "3746.0"                  }                ]              },              {                "measObjInstId": "15548",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "4562.0"                  },                  {                    "p": 2,                    "sValue": "2896.0"                  },                  {                    "p": 4,                    "sValue": "6591.0"                  },                  {                    "p": 5,                    "sValue": "4534.0"                  },                  {                    "p": 3,                    "sValue": "3504.0"                  }                ]              },              {                "measObjInstId": "15549",                "suspectFlag": "false",                "measResults": [                  {                    "p": 1,                    "sValue": "4918.0"                  },                  {                    "p": 2,                    "sValue": "3244.0"                  },                  {                    "p": 4,                    "sValue": "6916.0"                  },                  {                    "p": 5,                    "sValue": "4883.0"                  },                  {                    "p": 3,                    "sValue": "3491.0"                  }                ]              }            ]          }        ]      }    }  }}
index db099b7..0018358 100644 (file)
@@ -21,7 +21,7 @@
 ###############################################################################
 major=1
 minor=0
-patch=10
+patch=11
 base_version=${major}.${minor}.${patch}
 release_version=${base_version}
 snapshot_version=${base_version}-SNAPSHOT