aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/feature-controlloop-trans/src/test
diff options
context:
space:
mode:
authorjhh <jorge.hernandez-herrero@att.com>2021-02-18 18:08:34 -0600
committerjhh <jorge.hernandez-herrero@att.com>2021-02-19 12:53:20 -0600
commitea029d57c8c132b8dac6a280b7037ff495c184a4 (patch)
treeedfac385efdb459244a6fabbfe22c4caff22f728 /controlloop/common/feature-controlloop-trans/src/test
parentbb7c33c3d181f1dbeb83bda815f41256a54b5a32 (diff)
support control loop transaction metrics
Issue-ID: POLICY-3033 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: Ic13275607a56b36506a0c79d1880603ff374b0c2 Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'controlloop/common/feature-controlloop-trans/src/test')
-rw-r--r--controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java34
1 files changed, 33 insertions, 1 deletions
diff --git a/controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java b/controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java
index a19006e05..480c8d474 100644
--- a/controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java
+++ b/controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2021 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.
@@ -32,6 +32,7 @@ import java.nio.file.Path;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.junit.AfterClass;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
@@ -52,6 +53,17 @@ public class ControlLoopMetricsFeatureTest {
private static final Path configPath = SystemPersistenceConstants.getManager().getConfigurationPath();
private static PolicyController testController;
+ private static void resetStats() {
+ PolicyEngineConstants.getManager().getStats().getGroupStat().setAverageExecutionTime(0d);
+ PolicyEngineConstants.getManager().getStats().getGroupStat().setLastExecutionTime(0L);
+ PolicyEngineConstants.getManager().getStats().getGroupStat().setLastStart(0L);
+ PolicyEngineConstants.getManager().getStats().getGroupStat().setAverageExecutionTime(0d);
+ PolicyEngineConstants.getManager().getStats().getGroupStat().setPolicyExecutedCount(0L);
+ PolicyEngineConstants.getManager().getStats().getGroupStat().setPolicyExecutedFailCount(0L);
+ PolicyEngineConstants.getManager().getStats().getGroupStat().setPolicyExecutedSuccessCount(0L);
+ PolicyEngineConstants.getManager().getStats().getGroupStat().setTotalElapsedTime(0d);
+ }
+
/**
* Setup method.
*/
@@ -65,6 +77,12 @@ public class ControlLoopMetricsFeatureTest {
@AfterClass
public static void tearDown() {
SystemPersistenceConstants.getManager().setConfigurationDir(configPath.toString());
+ resetStats();
+ }
+
+ @Before
+ public void beforeTest() {
+ resetStats();
}
@Test
@@ -231,6 +249,19 @@ public class ControlLoopMetricsFeatureTest {
Serialization.gsonPretty.fromJson(finalSuccessNotification, VirtualControlLoopNotification.class);
feature.beforeDeliver(testController, CommInfrastructure.DMAAP, POLICY_CL_MGT, finalSuccess);
assertEquals(0, ControlLoopMetricsManager.getManager().getTransactionIds().size());
+ assertEquals(1,
+ PolicyEngineConstants.getManager().getStats().getGroupStat().getPolicyExecutedSuccessCount());
+ assertEquals(0,
+ PolicyEngineConstants.getManager().getStats().getGroupStat().getPolicyExecutedFailCount());
+ assertEquals(1, PolicyEngineConstants.getManager().getStats().getGroupStat().getPolicyExecutedCount());
+ assertEquals(1587409937684L,
+ PolicyEngineConstants.getManager().getStats().getGroupStat().getLastExecutionTime());
+ assertEquals(461d,
+ PolicyEngineConstants.getManager().getStats().getGroupStat().getAverageExecutionTime(), 0.0d);
+ assertEquals(1587409937223L,
+ PolicyEngineConstants.getManager().getStats().getGroupStat().getLastStart());
+ assertEquals(461d,
+ PolicyEngineConstants.getManager().getStats().getGroupStat().getTotalElapsedTime(), 0.0d);
}
@Test
@@ -255,4 +286,5 @@ public class ControlLoopMetricsFeatureTest {
Thread.sleep((ControlLoopMetricsManager.getManager().getTransactionTimeout() + 1) * 1000L); // NOSONAR
assertEquals(0, ControlLoopMetricsManager.getManager().getTransactionIds().size());
}
+
}