summaryrefslogtreecommitdiffstats
path: root/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexPolicyStatisticsManagerTest.java
diff options
context:
space:
mode:
authorRashmi Pujar <rashmi.pujar1@bell.ca>2022-01-26 22:39:11 -0500
committerRashmi Pujar <rashmi.pujar1@bell.ca>2022-02-09 14:26:16 -0500
commitd71f322fa9eb51967527b14c1eeeba49838464be (patch)
tree42ca8a44b0393711a395f2b3dc90f53a383a3be2 /services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexPolicyStatisticsManagerTest.java
parenta84cda443bb55b74e89a61150814596d3a311dd3 (diff)
rename metrics as per global constants for prometheus
Issue-ID: POLICY-3760 Signed-off-by: Rashmi Pujar <rashmi.pujar1@bell.ca> Change-Id: I0fb59e8d9c95fd81a1754bb769705ef753b9022d
Diffstat (limited to 'services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexPolicyStatisticsManagerTest.java')
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexPolicyStatisticsManagerTest.java25
1 files changed, 24 insertions, 1 deletions
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexPolicyStatisticsManagerTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexPolicyStatisticsManagerTest.java
index a63cea5eb..6213cae1f 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexPolicyStatisticsManagerTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/main/ApexPolicyStatisticsManagerTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation.
- * Modifications Copyright (C) 2021 Bell Canada Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2021-2022 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.
@@ -23,8 +23,10 @@ package org.onap.policy.apex.service.engine.main;
import static org.junit.Assert.assertEquals;
+import io.prometheus.client.CollectorRegistry;
import org.junit.Before;
import org.junit.Test;
+import org.onap.policy.common.utils.resources.PrometheusUtils;
public class ApexPolicyStatisticsManagerTest {
@@ -46,6 +48,7 @@ public class ApexPolicyStatisticsManagerTest {
statisticsManager.updatePolicyDeployCounter(true);
statisticsManager.updatePolicyDeployCounter(true);
assertDeploys(3, 2, 1);
+ checkDeploymentsMetrics("deploy");
}
@Test
@@ -64,6 +67,7 @@ public class ApexPolicyStatisticsManagerTest {
statisticsManager.updatePolicyUndeployCounter(true);
assertUndeploys(2, 1, 1);
+ checkDeploymentsMetrics("undeploy");
}
private void assertDeploys(long count, long success, long fail) {
@@ -84,4 +88,23 @@ public class ApexPolicyStatisticsManagerTest {
assertEquals(fail, statisticsManager.getPolicyExecutedFailCount());
}
+ private void checkDeploymentsMetrics(String operation) {
+ final var defaultRegistry = CollectorRegistry.defaultRegistry;
+ Double totalCount = defaultRegistry.getSampleValue("pdpa_policy_deployments_total",
+ new String[]{"operation", "status"}, new String[]{operation, "TOTAL"});
+ Double successCount = defaultRegistry.getSampleValue("pdpa_policy_deployments_total",
+ new String[]{"operation", "status"}, new String[]{operation, "SUCCESS"});
+ Double failCount = defaultRegistry.getSampleValue("pdpa_policy_deployments_total",
+ new String[]{"operation", "status"}, new String[]{operation, "FAIL"});
+
+ if (PrometheusUtils.DEPLOY_OPERATION.equals(operation)) {
+ assertEquals(totalCount.intValue(), statisticsManager.getPolicyDeployCount());
+ assertEquals(successCount.intValue(), statisticsManager.getPolicyDeploySuccessCount());
+ assertEquals(failCount.intValue(), statisticsManager.getPolicyDeployFailCount());
+ } else if (PrometheusUtils.UNDEPLOY_OPERATION.equals(operation)) {
+ assertEquals(totalCount.intValue(), statisticsManager.getPolicyUndeployCount());
+ assertEquals(successCount.intValue(), statisticsManager.getPolicyUndeploySuccessCount());
+ assertEquals(failCount.intValue(), statisticsManager.getPolicyUndeployFailCount());
+ }
+ }
} \ No newline at end of file