summaryrefslogtreecommitdiffstats
path: root/components/slice-analysis-ms/src/test
diff options
context:
space:
mode:
authorqingshuting <qingshuting1@huawei.com>2022-09-14 12:05:19 +0800
committerqingshuting <qingshuting1@huawei.com>2022-09-20 23:14:48 +0800
commitf5db5bd223d369a1186c94f43ab642e9c4d69709 (patch)
tree1acf6e5cdeff298622d6f6fad8c1431d0e90b43a /components/slice-analysis-ms/src/test
parent3a0de968e2c5a32a2fa43f791c78455db1c3e641 (diff)
[SLICEMS] Add bw decrease logics and enhance runtime config feature
Add closed loop assurance decrease bw logics. Add a thread transfers latest data from cbs client configs to corresponding value. Add runtime configuration function. Fix the bug that cll service info didn't get updated when a cll service is deleted. Issue-ID: DCAEGEN2-3240 Issue-ID: DCAEGEN2-3264 Issue-ID: DCAEGEN2-3255 Issue-ID: DCAEGEN2-3238 Signed-off-by: qingshuting <qingshuting1@huawei.com> Change-Id: Id611d10973fca1e1715e9e220819dfcf51bbd1ba
Diffstat (limited to 'components/slice-analysis-ms/src/test')
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/AaiEventNotificationCallbackTest.java4
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/VesNotificationCallbackTest.java20
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigurationTest.java9
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/ccvpn/CCVPNPmDatastoreTest.java27
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/ccvpn/FlexibleThresholdStrategyTest.java69
-rw-r--r--components/slice-analysis-ms/src/test/resources/config_all.json3
6 files changed, 128 insertions, 4 deletions
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/AaiEventNotificationCallbackTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/AaiEventNotificationCallbackTest.java
index 16745193..9fce12f1 100644
--- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/AaiEventNotificationCallbackTest.java
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/AaiEventNotificationCallbackTest.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2022 Huawei Canada Limited.
* Copyright (C) 2022 CTC, Inc.
+ * Copyright (C) 2022 Huawei Technologies Co., Ltd.
* ==============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -83,7 +84,8 @@ public class AaiEventNotificationCallbackTest {
jsonObject.addProperty("sliceanalysisms.vesNotifChangeType", "1");
jsonObject.addProperty("sliceanalysisms.vesNotifPollingInterval", "1");
jsonObject.addProperty("sliceanalysisms.ccvpnEvalInterval", "1");
- jsonObject.addProperty("sliceanalysisms.ccvpnEvalThreshold", "1");
+ jsonObject.addProperty("sliceanalysisms.ccvpnEvalUpperThreshold", "1");
+ jsonObject.addProperty("sliceanalysisms.ccvpnEvalLowerThreshold", "1");
jsonObject.addProperty("sliceanalysisms.ccvpnEvalPrecision", "1");
jsonObject.addProperty("sliceanalysisms.ccvpnEvalPeriodicCheckOn", "1");
jsonObject.addProperty("sliceanalysisms.ccvpnEvalOnDemandCheckOn", "1");
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/VesNotificationCallbackTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/VesNotificationCallbackTest.java
index 74f75a8c..97ee9fa9 100644
--- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/VesNotificationCallbackTest.java
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/VesNotificationCallbackTest.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2020 Wipro Limited.
* Copyright (C) 2022 Huawei Canada Limited.
+ * Copyright (C) 2022 Huawei Technologies Co., Ltd.
* ==============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,12 +23,20 @@
package org.onap.slice.analysis.ms.dmaap;
import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.HashSet;
+import java.util.Set;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
+import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.Spy;
+import org.onap.slice.analysis.ms.aai.AaiService;
+import org.onap.slice.analysis.ms.service.ccvpn.CCVPNPmDatastore;
+import org.powermock.api.mockito.PowerMockito;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.IOException;
@@ -39,6 +48,12 @@ import java.nio.file.Paths;
public class VesNotificationCallbackTest {
ObjectMapper obj = new ObjectMapper();
+ @Mock
+ AaiService aaiService;
+
+ @Mock
+ CCVPNPmDatastore ccvpnPmDatastore;
+
@Spy
@InjectMocks
VesNotificationCallback vesNotificationCallback;
@@ -57,6 +72,11 @@ public class VesNotificationCallbackTest {
} catch (IOException e) {
e.printStackTrace();
}
+ Set<String> cllInstances = new HashSet<>();
+ cllInstances.add("cll-01");
+ cllInstances.add("cll-02");
+ Mockito.when(aaiService.fetchAllCllInstances()).thenReturn(cllInstances);
+ Mockito.doNothing().when(ccvpnPmDatastore).updateCllInstances(Mockito.any());
vesNotificationCallback.activateCallBack(input);
Mockito.verify(vesNotificationCallback, Mockito.atLeastOnce()).activateCallBack(Mockito.anyString());
}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigurationTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigurationTest.java
index 3d9b58d4..78379094 100644
--- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigurationTest.java
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigurationTest.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2020-2021 Wipro Limited.
* Copyright (C) 2022 Huawei Canada Limited.
+ * Copyright (C) 2022 Huawei Technologies Co., Ltd.
* ==============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,7 +59,9 @@ public class ConfigurationTest {
configuration.setVesNotifChangeType("BandwidthChanged");
configuration.setCcvpnEvalInterval(5);
configuration.setCcvpnEvalPrecision(100);
- configuration.setCcvpnEvalThreshold(0.8);
+ configuration.setCcvpnEvalUpperThreshold(0.8);
+ configuration.setCcvpnEvalLowerThreshold(0.3);
+ configuration.setCcvpnEvalStrategy("FlexibleThresholdStrategy");
assertEquals(true,configuration.isSecured());
assertEquals("user", configuration.getAafUsername());
assertEquals("password", configuration.getAafPassword());
@@ -85,6 +88,8 @@ public class ConfigurationTest {
assertEquals("BandwidthChanged", configuration.getVesNotifChangeType());
assertEquals(5, configuration.getCcvpnEvalInterval());
assertEquals(100.0, configuration.getCcvpnEvalPrecision(), 0.001);
- assertEquals(0.8, configuration.getCcvpnEvalThreshold(), 0.001);
+ assertEquals(0.8, configuration.getCcvpnEvalUpperThreshold(), 0.001);
+ assertEquals(0.3, configuration.getCcvpnEvalLowerThreshold(), 0.001);
+ assertEquals("FlexibleThresholdStrategy", configuration.getCcvpnEvalStrategy());
}
}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/ccvpn/CCVPNPmDatastoreTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/ccvpn/CCVPNPmDatastoreTest.java
index 673ec6a8..8b0b99f3 100644
--- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/ccvpn/CCVPNPmDatastoreTest.java
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/ccvpn/CCVPNPmDatastoreTest.java
@@ -3,6 +3,7 @@
* slice-analysis-ms
* ================================================================================
* Copyright (C) 2022 Huawei Canada Limited.
+ * Copyright (C) 2022 Huawei Technologies Co., Ltd.
* ==============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +22,8 @@
package org.onap.slice.analysis.ms.service.ccvpn;
+import java.util.HashSet;
+import java.util.Set;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@@ -119,4 +122,28 @@ public class CCVPNPmDatastoreTest {
.mapToInt(o -> (int)o)
.sum() == 300602 );
}
+
+ @Test
+ public void updateCllInstancesTest() {
+ datastore.addUsedBwToEndpoint("cll-01", "uni-n1", "300Mb");
+ datastore.updateUpperBoundBw("cll-01", 300);
+ datastore.updateProvBw("cll-01", "300");
+ datastore.updateSvcState("cll-01", ServiceState.RUNNING);
+ datastore.updateOriginalBw("cll-01", 1000);
+ datastore.updateClosedloopStatus("cll-01", true);
+ datastore.addUsedBwToEndpoint("cll-02", "uni-n2", "300Mb");
+ datastore.updateUpperBoundBw("cll-02", 300);
+ datastore.updateProvBw("cll-02", "300");
+ datastore.updateSvcState("cll-02", ServiceState.RUNNING);
+ datastore.updateOriginalBw("cll-02", 1000);
+ datastore.updateClosedloopStatus("cll-02", true);
+ Set<String> cllId = new HashSet<>();
+ cllId.add("cll-01");
+ datastore.updateCllInstances(cllId);
+ assertEquals(datastore.getEndpointToUsedBw().keySet().size(), 1);
+ assertEquals(datastore.getUpperBoundBw().keySet().equals(cllId), true);
+ assertEquals(datastore.getEndpointToProvBw().keySet().equals(cllId), true);
+ assertEquals(datastore.getSvcStatus().keySet().equals(cllId), true);
+ assertEquals(datastore.getEndpointToOriginalBw().keySet().equals(cllId), true);
+ }
}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/ccvpn/FlexibleThresholdStrategyTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/ccvpn/FlexibleThresholdStrategyTest.java
new file mode 100644
index 00000000..40028923
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/ccvpn/FlexibleThresholdStrategyTest.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * slice-analysis-ms
+ * ================================================================================
+ * Copyright (C) 2022 Huawei Technologies Co., Ltd.
+ * ==============================================================================
+ * 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=========================================================
+ *
+ *******************************************************************************/
+package org.onap.slice.analysis.ms.service.ccvpn;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = FixedUpperBoundStrategyTest.class)
+public class FlexibleThresholdStrategyTest {
+
+ @Spy
+ @InjectMocks
+ BandwidthEvaluator bandwidthEvaluator;
+
+ @Spy
+ @InjectMocks
+ FlexibleThresholdStrategy flexibleThresholdStrategy;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void initTest() {
+ flexibleThresholdStrategy.init();
+ Mockito.verify(flexibleThresholdStrategy, Mockito.atLeastOnce()).init();
+ }
+
+ @Test
+ public void executeTest() {
+ Event evt = new SimpleEvent(null, "{}");
+ flexibleThresholdStrategy.execute(evt);
+ Mockito.verify(flexibleThresholdStrategy, Mockito.atLeastOnce())
+ .execute(Mockito.any(Event.class));
+ }
+
+ @Test
+ public void getNameTest() {
+ flexibleThresholdStrategy.getName();
+ Mockito.verify(flexibleThresholdStrategy, Mockito.atLeastOnce()).getName();
+ }
+}
diff --git a/components/slice-analysis-ms/src/test/resources/config_all.json b/components/slice-analysis-ms/src/test/resources/config_all.json
index f37e438c..fc18cc14 100644
--- a/components/slice-analysis-ms/src/test/resources/config_all.json
+++ b/components/slice-analysis-ms/src/test/resources/config_all.json
@@ -106,7 +106,8 @@
"sliceanalysisms.aaiNotif.targetSource" : "UUI",
"sliceanalysisms.aaiNotif.targetEntity" : "service-instance",
"sliceanalysisms.ccvpnEvalInterval": 5,
- "sliceanalysisms.ccvpnEvalThreshold": 0.8,
+ "sliceanalysisms.ccvpnEvalUpperThreshold": 0.8,
+ "sliceanalysisms.ccvpnEvalLowerThreshold": 0.3,
"sliceanalysisms.ccvpnEvalPrecision": 100.0,
"sliceanalysisms.ccvpnEvalPeriodicCheckOn": true,
"sliceanalysisms.ccvpnEvalOnDemandCheckOn": true,