From 584f29be579cd483c8f9bd888a747b2ebbeea7f1 Mon Sep 17 00:00:00 2001 From: malar Date: Wed, 9 Nov 2022 10:26:31 +0000 Subject: Fix bug in wrong SNSSAI value being appended with MeasType string The SNSSAI can be a alphanumeric also, so modified the code acording to that. Issue-ID: DCAEGEN2-3310 Signed-off-by: Malarvizhi Paramasivam Change-Id: Iac3e66e8d12a817681c15100ba80d2efee8e0498 --- components/kpi-computation-ms/Changelog.md | 4 ++++ components/kpi-computation-ms/pom.xml | 2 +- .../dcaegen2/kpi/computation/KpiComputation.java | 23 ++++++++++++++------- .../kpi/computation/RatioKpiComputation.java | 24 +++++----------------- .../kpi/computation/KpiComputationTest.java | 6 +++--- .../test/resources/kpi/ves_message_slicing.json | 4 ++-- .../kpi/ves_message_slicing_multiplesnssai.json | 2 +- components/kpi-computation-ms/version.properties | 2 +- 8 files changed, 33 insertions(+), 34 deletions(-) (limited to 'components') diff --git a/components/kpi-computation-ms/Changelog.md b/components/kpi-computation-ms/Changelog.md index e96d7884..30319907 100644 --- a/components/kpi-computation-ms/Changelog.md +++ b/components/kpi-computation-ms/Changelog.md @@ -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) diff --git a/components/kpi-computation-ms/pom.xml b/components/kpi-computation-ms/pom.xml index 8ee82800..e60d12a0 100644 --- a/components/kpi-computation-ms/pom.xml +++ b/components/kpi-computation-ms/pom.xml @@ -29,7 +29,7 @@ org.onap.dcaegen2.services.components kpi-ms - 1.0.10-SNAPSHOT + 1.0.11-SNAPSHOT dcaegen2-services-kpi-computation-ms Kpi ms jar diff --git a/components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/computation/KpiComputation.java b/components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/computation/KpiComputation.java index 8a7b9e06..4dd2601e 100644 --- a/components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/computation/KpiComputation.java +++ b/components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/computation/KpiComputation.java @@ -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 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 events = new LinkedList<>(); List 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 kpiVesEvent = CommandHandler.handle(operation.value, pmEvent, schemaType, diff --git a/components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/computation/RatioKpiComputation.java b/components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/computation/RatioKpiComputation.java index c228b595..8fbbb1d9 100644 --- a/components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/computation/RatioKpiComputation.java +++ b/components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/computation/RatioKpiComputation.java @@ -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) { diff --git a/components/kpi-computation-ms/src/test/java/org/onap/dcaegen2/kpi/computation/KpiComputationTest.java b/components/kpi-computation-ms/src/test/java/org/onap/dcaegen2/kpi/computation/KpiComputationTest.java index 79f7e498..c5e0dc31 100644 --- a/components/kpi-computation-ms/src/test/java/org/onap/dcaegen2/kpi/computation/KpiComputationTest.java +++ b/components/kpi-computation-ms/src/test/java/org/onap/dcaegen2/kpi/computation/KpiComputationTest.java @@ -108,7 +108,7 @@ public class KpiComputationTest { List 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 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 index 41a8f91c..2081b06d 100644 --- 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 @@ -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" ] }, diff --git a/components/kpi-computation-ms/src/test/resources/kpi/ves_message_slicing_multiplesnssai.json b/components/kpi-computation-ms/src/test/resources/kpi/ves_message_slicing_multiplesnssai.json index fe87d1a6..1a3e5e87 100644 --- a/components/kpi-computation-ms/src/test/resources/kpi/ves_message_slicing_multiplesnssai.json +++ b/components/kpi-computation-ms/src/test/resources/kpi/ves_message_slicing_multiplesnssai.json @@ -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" } ] } ] } ] } } }} diff --git a/components/kpi-computation-ms/version.properties b/components/kpi-computation-ms/version.properties index db099b7f..00183588 100644 --- a/components/kpi-computation-ms/version.properties +++ b/components/kpi-computation-ms/version.properties @@ -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 -- cgit 1.2.3-korg