summaryrefslogtreecommitdiffstats
path: root/services/services-engine/src/test
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@est.tech>2022-02-10 13:18:43 +0000
committerGerrit Code Review <gerrit@onap.org>2022-02-10 13:18:43 +0000
commit2f2c5465cd23c8c3300a5c3d185806bb3e7d73c1 (patch)
tree8dc32111bc837459be7e61b048e3fd073e3bc5a8 /services/services-engine/src/test
parentc9da04cc4ff4b133edd68ceee77f5bb5128d6574 (diff)
parentd71f322fa9eb51967527b14c1eeeba49838464be (diff)
Merge "rename metrics as per global constants for prometheus"
Diffstat (limited to 'services/services-engine/src/test')
-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