diff options
author | 2021-11-22 19:18:36 +0000 | |
---|---|---|
committer | 2021-11-22 19:18:36 +0000 | |
commit | 039d58e49ec70ed3356757fcbee35c4c68c69401 (patch) | |
tree | 56382fe78479a133fe7dcdfd606376f16fe80f4d /components/kpi-computation-ms/src/test | |
parent | 1685b700294ee0c1eaa1365d67a42861af0fe721 (diff) | |
parent | 2299aa41af51f45e5110f42ae036e68a87a9ab35 (diff) |
Merge "[DCAEGEN2] Improvements to kpi-computation-ms Microservice"
Diffstat (limited to 'components/kpi-computation-ms/src/test')
7 files changed, 53 insertions, 10 deletions
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 0bb3b184..69494ab5 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 @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 China Mobile. + * Copyright (C) 2021 Deutsche Telekom AG. 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. @@ -31,10 +32,14 @@ import org.onap.dcaegen2.kpi.computation.KpiComputation; import org.onap.dcaegen2.kpi.models.Configuration; import org.onap.dcaegen2.kpi.models.VesEvent; +import java.math.BigDecimal; +import java.math.RoundingMode; + 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"; @Test public void testKpiComputation() { @@ -53,4 +58,16 @@ public class KpiComputationTest { .getMeasValuesList().get(0).getMeasResults().get(0).getSvalue(), "40"); } + @Test + public void testKpiComputationRatio() { + String strKpiConfigRatio = FileUtils.getFileContents(KPI_CONFIG_RATIO_FILE); + String vesMessage = FileUtils.getFileContents(VES_MESSAGE_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(), "50"); + } + } diff --git a/components/kpi-computation-ms/src/test/java/org/onap/dcaegen2/kpi/computation/KpiTest.java b/components/kpi-computation-ms/src/test/java/org/onap/dcaegen2/kpi/computation/KpiTest.java index 94aca96a..236a15c4 100644 --- a/components/kpi-computation-ms/src/test/java/org/onap/dcaegen2/kpi/computation/KpiTest.java +++ b/components/kpi-computation-ms/src/test/java/org/onap/dcaegen2/kpi/computation/KpiTest.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2021 China Mobile. + * Copyright (C) 2021 Deutsche Telekom AG. 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. @@ -32,6 +33,7 @@ public class KpiTest { 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"; @Test public void testKpiConfigValidate() { @@ -51,4 +53,11 @@ public class KpiTest { assertEquals(vesEvent.getEvent().getCommonEventHeader().getDomain(), "perf3gpp"); } + @Test + public void testKpiConfigRatioValidate() { + String strKpiConfig = FileUtils.getFileContents(KPI_CONFIG_RATIO_FILE); + KpiConfig kpiConfig = KpiJsonConversion.convertKpiConfig(strKpiConfig); + assertEquals(kpiConfig.getDomain(), "measurementsForKpi"); + } + } diff --git a/components/kpi-computation-ms/src/test/resources/config_all.json b/components/kpi-computation-ms/src/test/resources/config_all.json index eb84e0d8..eec10029 100644 --- a/components/kpi-computation-ms/src/test/resources/config_all.json +++ b/components/kpi-computation-ms/src/test/resources/config_all.json @@ -32,7 +32,7 @@ } }, "aafPassword": "demo123456!", - "kpi.policy": "{\"domain\":\"measurementsForKpi\",\"methodForKpi\":[{\"eventName\":\"perf3gpp_CORE-AMF_pmMeasResult\",\"controlLoopSchemaType\":\"SLICE\",\"policyScope\":\"resource=networkSlice;type=configuration\",\"policyName\":\"configuration.dcae.microservice.pm-mapper.xml\",\"policyVersion\":\"v0.0.1\",\"kpis\":[{\"measType\":\"AMFRegNbr\",\"operation\":\"SUM\",\"operands\":\"RM.RegisteredSubNbrMean\"}]},{\"eventName\":\"perf3gpp_AcmeNode-Acme_pmMeasResult\",\"controlLoopSchemaType\":\"SLICE\",\"policyScope\":\"resource=networkSlice;type=configuration\",\"policyName\":\"configuration.dcae.microservice.pm-mapper.xml\",\"policyVersion\":\"v0.0.1\",\"kpis\":[{\"measType\":\"UpstreamThr\",\"operation\":\"SUM\",\"operands\":\"GTP.InDataOctN3UPF\"},{\"measType\":\"DownstreamThr\",\"operation\":\"SUM\",\"operands\":\"GTP.OutDataOctN3UPF\"}]}]}", + "kpi.policy": "{\"domain\":\"measurementsForKpi\",\"methodForKpi\":[{\"eventName\":\"perf3gpp_CORE-AMF_pmMeasResult\",\"controlLoopSchemaType\":\"SLICE\",\"policyScope\":\"resource=networkSlice;type=configuration\",\"policyName\":\"configuration.dcae.microservice.pm-mapper.xml\",\"policyVersion\":\"v0.0.1\",\"kpis\":[{\"measType\":\"AMFRegNbr\",\"operation\":\"SUM\",\"operands\":[\"RM.RegisteredSubNbrMean\"]}]},{\"eventName\":\"perf3gpp_AcmeNode-Acme_pmMeasResult\",\"controlLoopSchemaType\":\"SLICE\",\"policyScope\":\"resource=networkSlice;type=configuration\",\"policyName\":\"configuration.dcae.microservice.pm-mapper.xml\",\"policyVersion\":\"v0.0.1\",\"kpis\":[{\"measType\":\"UpstreamThr\",\"operation\":\"SUM\",\"operands\":[\"GTP.InDataOctN3UPF\"]},{\"measType\":\"DownstreamThr\",\"operation\":\"SUM\",\"operands\":[\"GTP.OutDataOctN3UPF\"]}]}]}", "dmaap.server": ["message-router"] }, "policies": { @@ -86,4 +86,4 @@ } }] } -}
\ No newline at end of file +} diff --git a/components/kpi-computation-ms/src/test/resources/kpi/cbs_config1.json b/components/kpi-computation-ms/src/test/resources/kpi/cbs_config1.json index bb763db1..9dea5012 100644 --- a/components/kpi-computation-ms/src/test/resources/kpi/cbs_config1.json +++ b/components/kpi-computation-ms/src/test/resources/kpi/cbs_config1.json @@ -32,7 +32,7 @@ } }, "aafPassword": "demo123456!", - "kpi.policy": "{\"domain\":\"measurementsForKpi\",\"methodForKpi\":[{\"eventName\":\"perf3gpp_CORE-AMF_pmMeasResult\",\"controlLoopSchemaType\":\"SLICE\",\"policyScope\":\"resource=networkSlice;type=configuration\",\"policyName\":\"configuration.dcae.microservice.pm-mapper.xml\",\"policyVersion\":\"v0.0.1\",\"kpis\":[{\"measType\":\"AMFRegNbr\",\"operation\":\"SUM\",\"operands\":\"RM.RegisteredSubNbrMean\"}]},{\"eventName\":\"perf3gpp_AcmeNode-Acme_pmMeasResult\",\"controlLoopSchemaType\":\"SLICE\",\"policyScope\":\"resource=networkSlice;type=configuration\",\"policyName\":\"configuration.dcae.microservice.pm-mapper.xml\",\"policyVersion\":\"v0.0.1\",\"kpis\":[{\"measType\":\"UpstreamThr\",\"operation\":\"SUM\",\"operands\":\"GTP.InDataOctN3UPF\"},{\"measType\":\"DownstreamThr\",\"operation\":\"SUM\",\"operands\":\"GTP.OutDataOctN3UPF\"}]}]}", + "kpi.policy": "{\"domain\":\"measurementsForKpi\",\"methodForKpi\":[{\"eventName\":\"perf3gpp_CORE-AMF_pmMeasResult\",\"controlLoopSchemaType\":\"SLICE\",\"policyScope\":\"resource=networkSlice;type=configuration\",\"policyName\":\"configuration.dcae.microservice.pm-mapper.xml\",\"policyVersion\":\"v0.0.1\",\"kpis\":[{\"measType\":\"AMFRegNbr\",\"operation\":\"SUM\",\"operands\":[\"RM.RegisteredSubNbrMean\"]}]},{\"eventName\":\"perf3gpp_AcmeNode-Acme_pmMeasResult\",\"controlLoopSchemaType\":\"SLICE\",\"policyScope\":\"resource=networkSlice;type=configuration\",\"policyName\":\"configuration.dcae.microservice.pm-mapper.xml\",\"policyVersion\":\"v0.0.1\",\"kpis\":[{\"measType\":\"UpstreamThr\",\"operation\":\"SUM\",\"operands\":[\"GTP.InDataOctN3UPF\"]},{\"measType\":\"DownstreamThr\",\"operation\":\"SUM\",\"operands\":[\"GTP.OutDataOctN3UPF\"]}]}]}", "dmaap.server": ["message-router"] } -}
\ No newline at end of file +} diff --git a/components/kpi-computation-ms/src/test/resources/kpi/cbs_config2.json b/components/kpi-computation-ms/src/test/resources/kpi/cbs_config2.json index bb763db1..d69c89c4 100644 --- a/components/kpi-computation-ms/src/test/resources/kpi/cbs_config2.json +++ b/components/kpi-computation-ms/src/test/resources/kpi/cbs_config2.json @@ -32,7 +32,7 @@ } }, "aafPassword": "demo123456!", - "kpi.policy": "{\"domain\":\"measurementsForKpi\",\"methodForKpi\":[{\"eventName\":\"perf3gpp_CORE-AMF_pmMeasResult\",\"controlLoopSchemaType\":\"SLICE\",\"policyScope\":\"resource=networkSlice;type=configuration\",\"policyName\":\"configuration.dcae.microservice.pm-mapper.xml\",\"policyVersion\":\"v0.0.1\",\"kpis\":[{\"measType\":\"AMFRegNbr\",\"operation\":\"SUM\",\"operands\":\"RM.RegisteredSubNbrMean\"}]},{\"eventName\":\"perf3gpp_AcmeNode-Acme_pmMeasResult\",\"controlLoopSchemaType\":\"SLICE\",\"policyScope\":\"resource=networkSlice;type=configuration\",\"policyName\":\"configuration.dcae.microservice.pm-mapper.xml\",\"policyVersion\":\"v0.0.1\",\"kpis\":[{\"measType\":\"UpstreamThr\",\"operation\":\"SUM\",\"operands\":\"GTP.InDataOctN3UPF\"},{\"measType\":\"DownstreamThr\",\"operation\":\"SUM\",\"operands\":\"GTP.OutDataOctN3UPF\"}]}]}", + "kpi.policy": "{\"domain\":\"measurementsForKpi\",\"methodForKpi\":[{\"eventName\":\"perf3gpp_CORE-AMF_pmMeasResult\",\"controlLoopSchemaType\":\"SLICE\",\"policyScope\":\"resource=networkSlice;type=configuration\",\"policyName\":\"configuration.dcae.microservice.pm-mapper.xml\",\"policyVersion\":\"v0.0.1\",\"kpis\":[{\"measType\":\"AMFRegNbr\",\"operation\":\"SUM\",\"operands\":[\"RM.RegisteredSubNbrMean\"]}]},{\"eventName\":\"perf3gpp_AcmeNode-Acme_pmMeasResult\",\"controlLoopSchemaType\":\"SLICE\",\"policyScope\":\"resource=networkSlice;type=configuration\",\"policyName\":\"configuration.dcae.microservice.pm-mapper.xml\",\"policyVersion\":\"v0.0.1\",\"kpis\":[{\"measType\":\"RatioUpstreamDownStream\",\"operation\":\"RATIO\",\"operands\":[\"GTP.InDataOctN3UPF\",\"GTP.OutDataOctN3UPF\"]}]}]}", "dmaap.server": ["message-router"] } -}
\ No newline at end of file +} diff --git a/components/kpi-computation-ms/src/test/resources/kpi/kpi_config.json b/components/kpi-computation-ms/src/test/resources/kpi/kpi_config.json index 64e426cf..85487cb5 100644 --- a/components/kpi-computation-ms/src/test/resources/kpi/kpi_config.json +++ b/components/kpi-computation-ms/src/test/resources/kpi/kpi_config.json @@ -9,7 +9,7 @@ "kpis": [{ "measType": "AMFRegNbr", "operation": "SUM", - "operands": "RM.RegisteredSubNbrMean" + "operands": ["RM.RegisteredSubNbrMean"] }] }, { @@ -21,15 +21,15 @@ "kpis": [{ "measType": "UpstreamThr", "operation": "SUM", - "operands": "GTP.InDataOctN3UPF" + "operands": ["GTP.InDataOctN3UPF"] }, { "measType": "DownstreamThr", "operation": "SUM", - "operands": "GTP.OutDataOctN3UPF" + "operands": ["GTP.OutDataOctN3UPF"] } ] } ] -}
\ No newline at end of file +} diff --git a/components/kpi-computation-ms/src/test/resources/kpi/kpi_config_ratio.json b/components/kpi-computation-ms/src/test/resources/kpi/kpi_config_ratio.json new file mode 100644 index 00000000..3f6828a9 --- /dev/null +++ b/components/kpi-computation-ms/src/test/resources/kpi/kpi_config_ratio.json @@ -0,0 +1,17 @@ +{ + "domain": "measurementsForKpi", + "methodForKpi": [{ + "eventName": "perf3gpp_AcmeNode-Acme_pmMeasResult", + "controlLoopSchemaType": "SLICE", + "policyScope": "resource=networkSlice;type=configuration", + "policyName": "configuration.dcae.microservice.pm-mapper.xml", + "policyVersion": "v0.0.1", + "kpis": [{ + "measType": "RatioUpstreamDownstream", + "operation": "RATIO", + "operands": ["GTP.InDataOctN3UPF","GTP.OutDataOctN3UPF"] + } + ] + } + ] +} |