summaryrefslogtreecommitdiffstats
path: root/main/src/test/java/org/onap
diff options
context:
space:
mode:
authorRam Krishna Verma <ram_krishna.verma@bell.ca>2021-06-29 17:01:21 -0400
committerAjith Sreekumar <ajith.sreekumar@bell.ca>2021-06-30 09:18:52 +0000
commit57e39b87ac53c128502110b64b06947e9e380d4e (patch)
treedfac02665737e73f8bba0ee6f6a85745970c92a0 /main/src/test/java/org/onap
parent38a0a3888dc752bc6f88bdcc3477d20e38aeed3f (diff)
Add ability to turn on/off pdp statistics
Adding an ability in pap to turn on/off processing of pdp statistics. By default it will be turned on and can be changed via configuration. Issue-ID: POLICY-3450 Change-Id: I093fe3f1390769f9acf2cfe85dd0d4edf0539de8 Signed-off-by: Ram Krishna Verma <ram_krishna.verma@bell.ca>
Diffstat (limited to 'main/src/test/java/org/onap')
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java31
1 files changed, 28 insertions, 3 deletions
diff --git a/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java b/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
index 31d4af46..2344c4f3 100644
--- a/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/comm/PdpHeartbeatListenerTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2020-2021 AT&T Intellectual Property.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -69,7 +70,7 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
@Test
public void testPdpHeartbeatListener() throws CoderException, PfModelException {
addGroups("PdpGroups.json");
- pdpHeartbeatListener = new PdpHeartbeatListener(new PdpParameters());
+ pdpHeartbeatListener = new PdpHeartbeatListener(new PdpParameters(), true);
// Testing pdp registration success case
final PdpStatus status1 = new PdpStatus();
@@ -222,7 +223,7 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
PdpParameters params = testData.getPapParameterGroup(1).getPdpParameters();
List<ToscaConceptIdentifier> polsUndep = policies.stream().map(ToscaPolicy::getIdentifier)
.collect(Collectors.toList());
- PdpStatusMessageHandler handler = new PdpStatusMessageHandler(params);
+ PdpStatusMessageHandler handler = new PdpStatusMessageHandler(params, true);
PdpUpdate update10 = handler.createPdpUpdateMessage(
status3.getPdpGroup(), new PdpSubGroup(), "pdp_2",
policies, polsUndep);
@@ -234,7 +235,7 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
@Test
public void testPdpStatistics() throws CoderException, PfModelException, ParseException {
addGroups("PdpGroups.json");
- pdpHeartbeatListener = new PdpHeartbeatListener(new PdpParameters());
+ pdpHeartbeatListener = new PdpHeartbeatListener(new PdpParameters(), true);
timeStamp = Instant.parse("2021-02-12T17:48:01.029211400Z");
// init default pdp group
@@ -345,6 +346,30 @@ public class PdpHeartbeatListenerTest extends End2EndBase {
pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status5);
verifyPdpStatistics(null, DEFAULT_GROUP, null, 1);
+
+ // Test pdp statistics save disabled case, sending valid pdp status but count should still remain 1
+ pdpHeartbeatListener = new PdpHeartbeatListener(new PdpParameters(), false);
+ timeStamp = Instant.parse("2021-02-12T17:48:05.029211400Z");
+ final PdpStatus status7 = new PdpStatus();
+ status7.setName(PDP_NAME);
+ status7.setState(PdpState.ACTIVE);
+ status7.setPdpGroup(DEFAULT_GROUP);
+ status7.setPdpType(APEX_TYPE);
+ status7.setHealthy(PdpHealthStatus.HEALTHY);
+ status7.setPdpSubgroup(APEX_TYPE);
+ final List<ToscaConceptIdentifier> idents7 =
+ Arrays.asList(new ToscaConceptIdentifier(POLICY_NAME, POLICY_VERSION));
+ status7.setPolicies(idents7);
+
+ PdpStatistics pdpStatistics07 = new PdpStatistics();
+ pdpStatistics07.setPdpInstanceId(PDP_NAME);
+ pdpStatistics07.setPdpGroupName(DEFAULT_GROUP);
+ pdpStatistics07.setPdpSubGroupName(APEX_TYPE);
+ pdpStatistics07.setTimeStamp(timeStamp);
+ status7.setStatistics(pdpStatistics07);
+ pdpHeartbeatListener.onTopicEvent(INFRA, TOPIC, status7);
+ verifyPdpStatistics(PDP_NAME, DEFAULT_GROUP, null, 1);
+
}
private void verifyPdpGroup(final String name, final int count) throws PfModelException {