aboutsummaryrefslogtreecommitdiffstats
path: root/services/services-onappf/src/test
diff options
context:
space:
mode:
authorshaoqiu <tim.huang@est.tech>2019-12-13 15:10:29 +0800
committershaoqiu <tim.huang@est.tech>2020-01-08 10:11:17 +0800
commitb2bb847016d780377ea4ff26b389885e9295e7ff (patch)
tree559cff3b4d638ae3a9cd91ea7e4d092a1ebe371a /services/services-onappf/src/test
parent79a7ee5e295a5661b12f250495dbe311c8816107 (diff)
Populate the PdpStatistics data in heartbeat
Apex to populate the PdpStatistics data in every heartbeat sent to PAP Issue-ID: POLICY-2302 Change-Id: I2d3a6c1e8605d53bf754a135980527bd50762abd Signed-off-by: shaoqiu <tim.huang@est.tech>
Diffstat (limited to 'services/services-onappf/src/test')
-rw-r--r--services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterMain.java6
-rw-r--r--services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpStateChangeListener.java16
2 files changed, 18 insertions, 4 deletions
diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterMain.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterMain.java
index 2fcfe886f..43d36f84d 100644
--- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterMain.java
+++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/TestApexStarterMain.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@ import static org.junit.Assert.assertTrue;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.policy.apex.service.engine.main.ApexPolicyStatisticsManager;
import org.onap.policy.apex.services.onappf.exception.ApexStarterException;
import org.onap.policy.apex.services.onappf.parameters.CommonTestData;
import org.onap.policy.common.utils.services.Registry;
@@ -71,7 +72,8 @@ public class TestApexStarterMain {
// ensure items were added to the registry
assertNotNull(Registry.get(ApexStarterConstants.REG_APEX_STARTER_ACTIVATOR, ApexStarterActivator.class));
-
+ assertNotNull(Registry.get(ApexPolicyStatisticsManager.REG_APEX_PDP_POLICY_COUNTER,
+ ApexPolicyStatisticsManager.class));
apexStarter.shutdown();
}
diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpStateChangeListener.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpStateChangeListener.java
index 7f7de3b42..17f909fcc 100644
--- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpStateChangeListener.java
+++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpStateChangeListener.java
@@ -1,8 +1,7 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2020 Nordix Foundation.
* Modifications Copyright (C) 2019 AT&T Intellectual Property. 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.
@@ -23,6 +22,7 @@
package org.onap.policy.apex.services.onappf.comm;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
@@ -35,6 +35,7 @@ import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.policy.apex.service.engine.main.ApexPolicyStatisticsManager;
import org.onap.policy.apex.services.onappf.ApexStarterActivator;
import org.onap.policy.apex.services.onappf.ApexStarterCommandLineArguments;
import org.onap.policy.apex.services.onappf.ApexStarterConstants;
@@ -94,6 +95,7 @@ public class TestPdpStateChangeListener {
activator = new ApexStarterActivator(parameterGroup);
Registry.register(ApexStarterConstants.REG_APEX_STARTER_ACTIVATOR, activator);
+ Registry.register(ApexPolicyStatisticsManager.REG_APEX_PDP_POLICY_COUNTER, new ApexPolicyStatisticsManager());
activator.initialize();
}
@@ -161,6 +163,16 @@ public class TestPdpStateChangeListener {
pdpUpdateMessageListener.onTopicEvent(INFRA, TOPIC, null, pdpUpdateMsg);
assertTrue(outContent.toString().contains("Apex engine started and policies are running."));
assertEquals(PdpState.ACTIVE, pdpStatus.getState());
+
+ final ApexPolicyStatisticsManager policyCounterManager = ApexPolicyStatisticsManager.getInstanceFromRegistry();
+ assertNotNull(policyCounterManager);
+ assertEquals(policyCounterManager.getPolicyDeployCount(),
+ policyCounterManager.getPolicyDeploySuccessCount() + policyCounterManager.getPolicyDeployFailCount());
+
+ apexEngineHandler =
+ Registry.getOrDefault(ApexStarterConstants.REG_APEX_ENGINE_HANDLER, ApexEngineHandler.class, null);
+ assertNotNull(apexEngineHandler);
+ assertTrue(apexEngineHandler.getEngineStats().size() > 0);
}
@Test