aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/test/java/org/onap/policy/pap/main/rest
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/test/java/org/onap/policy/pap/main/rest')
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/ProviderSuper.java6
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java14
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeleteTest.java3
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeployTest.java7
4 files changed, 29 insertions, 1 deletions
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/ProviderSuper.java b/main/src/test/java/org/onap/policy/pap/main/rest/ProviderSuper.java
index 153a2bfa..b5667145 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/ProviderSuper.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/ProviderSuper.java
@@ -30,6 +30,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import io.micrometer.core.instrument.MeterRegistry;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
@@ -92,6 +93,7 @@ public class ProviderSuper {
protected PdpModifyRequestMap reqmap;
protected ToscaPolicy policy1;
protected PapStatisticsManager statsmanager;
+ protected MeterRegistry meterRegistry;
/**
* Configures DAO, captors, and various mocks.
@@ -109,6 +111,8 @@ public class ProviderSuper {
policy1 = loadPolicy("policy.json");
statsmanager = mock(PapStatisticsManager.class);
+ meterRegistry = mock(MeterRegistry.class);
+
List<PdpGroup> groups = loadGroups("groups.json");
when(pdpGroupService.getFilteredPdpGroups(any())).thenReturn(groups);
@@ -119,6 +123,8 @@ public class ProviderSuper {
Registry.register(PapConstants.REG_PDP_MODIFY_LOCK, lockit);
Registry.register(PapConstants.REG_PDP_MODIFY_MAP, reqmap);
Registry.register(PapConstants.REG_STATISTICS_MANAGER, statsmanager);
+ Registry.register(PapConstants.REG_METER_REGISTRY, meterRegistry);
+
}
/**
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java
index 9c9f36ad..575e33ff 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/End2EndBase.java
@@ -22,6 +22,7 @@
package org.onap.policy.pap.main.rest.e2e;
+import io.micrometer.core.instrument.MeterRegistry;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -34,12 +35,14 @@ import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.resources.PrometheusUtils;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroups;
import org.onap.policy.models.pdp.concepts.PdpPolicyStatus;
+import org.onap.policy.models.pdp.concepts.PdpPolicyStatus.State;
import org.onap.policy.models.pdp.concepts.PdpStatistics;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
@@ -81,6 +84,15 @@ public abstract class End2EndBase extends CommonPapRestServer {
@Autowired
public ToscaServiceTemplateService toscaService;
+ @Autowired
+ public MeterRegistry meterRegistry;
+
+ public String deploymentsCounterName = "pap_" + PrometheusUtils.POLICY_DEPLOYMENTS_METRIC;
+ public String[] deploymentSuccessTag = {PrometheusUtils.OPERATION_METRIC_LABEL, PrometheusUtils.DEPLOY_OPERATION,
+ PrometheusUtils.STATUS_METRIC_LABEL, State.SUCCESS.name()};
+ public String[] unDeploymentSuccessTag = {PrometheusUtils.OPERATION_METRIC_LABEL,
+ PrometheusUtils.UNDEPLOY_OPERATION, PrometheusUtils.STATUS_METRIC_LABEL, State.SUCCESS.name()};
+
/**
* Tears down.
*/
@@ -95,7 +107,7 @@ public abstract class End2EndBase extends CommonPapRestServer {
}
context = null;
}
-
+ meterRegistry.clear();
super.tearDown();
}
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeleteTest.java b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeleteTest.java
index e3ad0044..a8387881 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeleteTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeleteTest.java
@@ -22,6 +22,7 @@
package org.onap.policy.pap.main.rest.e2e;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -149,6 +150,8 @@ public class PdpGroupDeleteTest extends End2EndBase {
assertEquals(0, deleted.getIncompleteCount());
assertEquals(new ToscaConceptIdentifier("onap.restart.tcaB", "1.0.0"), deleted.getPolicy());
+ assertThat(meterRegistry.counter(deploymentsCounterName, unDeploymentSuccessTag).count()).isEqualTo(2);
+
rawresp = invocationBuilder.delete();
resp = rawresp.readEntity(PdpGroupDeployResponse.class);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), rawresp.getStatus());
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeployTest.java b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeployTest.java
index cdb1fa9d..df749a88 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeployTest.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupDeployTest.java
@@ -22,6 +22,7 @@
package org.onap.policy.pap.main.rest.e2e;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -121,6 +122,8 @@ public class PdpGroupDeployTest extends End2EndBase {
assertEquals(PdpGroupDeployControllerV1.POLICY_STATUS_URI, resp.getUri());
assertNull(resp.getErrorDetails());
+ assertThat(meterRegistry.counter(deploymentsCounterName, deploymentSuccessTag).count()).isEqualTo(2);
+
// repeat with unknown group - should fail
DeploymentGroup group = groups.getGroups().get(0);
group.setName("unknown-group");
@@ -167,6 +170,8 @@ public class PdpGroupDeployTest extends End2EndBase {
notifications.add(msg);
});
+ assertThat(meterRegistry.counter(deploymentsCounterName, deploymentSuccessTag).count()).isEqualTo(0);
+
Invocation.Builder invocationBuilder = sendRequest(DEPLOY_POLICIES_ENDPOINT);
PdpDeployPolicies policies = loadJsonFile("deployPoliciesReq2.json", PdpDeployPolicies.class);
@@ -202,5 +207,7 @@ public class PdpGroupDeployTest extends End2EndBase {
resp = rawresp.readEntity(PdpGroupDeployResponse.class);
assertEquals(Response.Status.ACCEPTED.getStatusCode(), rawresp.getStatus());
assertNull(resp.getErrorDetails());
+
+ assertThat(meterRegistry.counter(deploymentsCounterName, deploymentSuccessTag).count()).isEqualTo(2);
}
}