From c1b5c67f788ec8c937859b9e16cbfe9488589e3f Mon Sep 17 00:00:00 2001 From: malar Date: Wed, 13 Jul 2022 05:41:41 +0000 Subject: Enhancements to KPI Computation MS for Kohn Release - 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 Change-Id: Ie9672bb11a5e98aa681bd1c7c7db59ea2be46112 --- components/kpi-computation-ms/Changelog.md | 4 + components/kpi-computation-ms/pom.xml | 4 +- .../dcaegen2/kpi/computation/KpiComputation.java | 27 ++- .../kpi/computation/RatioKpiComputation.java | 5 + .../kpi/computation/SumRatioKpiComputation.java | 5 + .../kpi/computation/KpiComputationTest.java | 15 ++ .../src/test/resources/kpi/RAN.xml | 117 +++++++++ .../src/test/resources/kpi/kpi_config_slicing.json | 17 ++ .../test/resources/kpi/ves_message_slicing.json | 270 +++++++++++++++++++++ components/kpi-computation-ms/version.properties | 3 +- 10 files changed, 452 insertions(+), 15 deletions(-) create mode 100644 components/kpi-computation-ms/src/test/resources/kpi/RAN.xml create mode 100644 components/kpi-computation-ms/src/test/resources/kpi/kpi_config_slicing.json create mode 100644 components/kpi-computation-ms/src/test/resources/kpi/ves_message_slicing.json diff --git a/components/kpi-computation-ms/Changelog.md b/components/kpi-computation-ms/Changelog.md index a094d17b..5c9c4f0b 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.5] +### Changed +* Enhancements to KPI Computation MS for Kohn Release (DCAEGEN2-3193) + ## [1.0.4] ### Changed * Fix security vulnerability issues (DCAEGEN2-3047) diff --git a/components/kpi-computation-ms/pom.xml b/components/kpi-computation-ms/pom.xml index c67ece88..1defef1f 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.4-SNAPSHOT + 1.0.5-SNAPSHOT dcaegen2-services-kpi-computation-ms Kpi ms jar @@ -297,7 +297,7 @@ openpojo 0.8.10 - + ch.qos.logback logback-core 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 d3493528..5e6c5a41 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 @@ -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 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 measValuesList = m.getMeasValuesList(); + for ( MeasValues measValues : measValuesList) { + List 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"); + } } } } 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 96559a4c..754c3573 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 @@ -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; } } diff --git a/components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/computation/SumRatioKpiComputation.java b/components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/computation/SumRatioKpiComputation.java index a031abde..1c7436aa 100644 --- a/components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/computation/SumRatioKpiComputation.java +++ b/components/kpi-computation-ms/src/main/java/org/onap/dcaegen2/kpi/computation/SumRatioKpiComputation.java @@ -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; } } 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 1ed65572..4320981b 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 @@ -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 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 index 00000000..9b8da644 --- /dev/null +++ b/components/kpi-computation-ms/src/test/resources/kpi/RAN.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + SM.PduSessionCreationSucc.0011-0010 + SM.PduSessionCreationReq.0011-0010 + SM.PduSessionCreationFail.0 + + 5813.0 + 3679.0 + 1333.0 + false + + + 5637.0 + 3406.0 + 1333.0 + false + + + 5130.0 + 3083.0 + 1333.0 + false + + + 6020.0 + 3956.0 + 1333.0 + false + + + 5527.0 + 4117.0 + false + + + 5086.0 + 3206.0 + false + + + 1655.0 + 1183.0 + false + + + 2587.0 + 1900.0 + false + + + 1668.0 + 1217.0 + false + + + 4904.0 + 3155.0 + false + + + 5357.0 + 3577.0 + false + + + 2177.0 + 1438.0 + false + + + 2480.0 + 1615.0 + false + + + 1730.0 + 1174.0 + false + + + 2227.0 + 1341.0 + false + + + + + + + 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 index 00000000..bbc7fb2a --- /dev/null +++ b/components/kpi-computation-ms/src/test/resources/kpi/kpi_config_slicing.json @@ -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 index 00000000..41a8f91c --- /dev/null +++ b/components/kpi-computation-ms/src/test/resources/kpi/ves_message_slicing.json @@ -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" + } + ] + } + ] + } + ] + } + } + } +} diff --git a/components/kpi-computation-ms/version.properties b/components/kpi-computation-ms/version.properties index ada000a6..be3c3ddd 100644 --- a/components/kpi-computation-ms/version.properties +++ b/components/kpi-computation-ms/version.properties @@ -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 -- cgit 1.2.3-korg