summaryrefslogtreecommitdiffstats
path: root/main/src/test/java
diff options
context:
space:
mode:
authorRam Krishna Verma <ram_krishna.verma@bell.ca>2020-06-19 17:49:21 -0400
committerputhuparambil.aditya <aditya.puthuparambil@bell.ca>2020-06-29 12:03:29 +0100
commit552af85d4daa66dff8d4b920db61fe6010eee388 (patch)
treee726a215a4c4c552eb1da2a60de7a18721c265ea /main/src/test/java
parent5168a89883aaf86f64afb222cf0047b5769af6bb (diff)
Parallel execution of Client Health check
Issue-ID: POLICY-2390 Signed-off-by: puthuparambil.aditya <aditya.puthuparambil@bell.ca> Change-Id: I42f443c64bcf6652adb9795ee8e71e37d8fa8c71
Diffstat (limited to 'main/src/test/java')
-rw-r--r--main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyComponentsHealthCheckProvider.java32
1 files changed, 19 insertions, 13 deletions
diff --git a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyComponentsHealthCheckProvider.java b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyComponentsHealthCheckProvider.java
index 9d2fa63f..bdf4700c 100644
--- a/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyComponentsHealthCheckProvider.java
+++ b/main/src/test/java/org/onap/policy/pap/main/rest/TestPolicyComponentsHealthCheckProvider.java
@@ -65,6 +65,7 @@ public class TestPolicyComponentsHealthCheckProvider {
private static final String CLIENT_1 = "client1";
private static final String PDP_GROUP_DATA_FILE = "rest/pdpGroup.json";
private static final String PAP_GROUP_PARAMS_NAME = "PapGroup";
+ private static final String HEALTHY = "healthy";
@Mock
private PolicyModelsProvider dao;
@@ -135,6 +136,9 @@ public class TestPolicyComponentsHealthCheckProvider {
List<BusTopicParams> params = papParameterGroup.getHealthCheckRestClientParameters();
when(clientFactory.build(params.get(0))).thenReturn(client1);
when(clientFactory.build(params.get(1))).thenReturn(client2);
+
+ PolicyComponentsHealthCheckProvider.initializeClientHealthCheckExecutorService(papParameterGroup,
+ clientFactory);
}
/**
@@ -147,56 +151,58 @@ public class TestPolicyComponentsHealthCheckProvider {
} else {
ParameterService.deregister(PAP_GROUP_PARAMS_NAME);
}
+ PolicyComponentsHealthCheckProvider.cleanup();
}
+
@Test
- public void testFetchPolicyComponentsHealthStatus_allHealthy() throws Exception {
- PolicyComponentsHealthCheckProvider provider = new PolicyComponentsHealthCheckProvider(clientFactory);
+ public void testFetchPolicyComponentsHealthStatus_allHealthy() {
+ PolicyComponentsHealthCheckProvider provider = new PolicyComponentsHealthCheckProvider();
Pair<Status, Map<String, Object>> ret = provider.fetchPolicyComponentsHealthStatus();
assertEquals(Response.Status.OK, ret.getLeft());
- assertTrue((Boolean) ret.getRight().get("healthy"));
+ assertTrue((Boolean) ret.getRight().get(HEALTHY));
}
@Test
- public void testFetchPolicyComponentsHealthStatus_unhealthyClient() throws Exception {
+ public void testFetchPolicyComponentsHealthStatus_unhealthyClient() {
when(response1.getStatus()).thenReturn(HttpURLConnection.HTTP_INTERNAL_ERROR);
when(response1.readEntity(HealthCheckReport.class))
- .thenReturn(createReport(HttpURLConnection.HTTP_INTERNAL_ERROR, false));
+ .thenReturn(createReport(HttpURLConnection.HTTP_INTERNAL_ERROR, false));
Map<String, Object> result = callFetchPolicyComponentsHealthStatus();
- assertFalse((Boolean) result.get("healthy"));
+ assertFalse((Boolean) result.get(HEALTHY));
HealthCheckReport report = (HealthCheckReport) result.get(CLIENT_1);
assertFalse(report.isHealthy());
when(response1.getStatus()).thenReturn(HttpURLConnection.HTTP_OK);
when(response1.readEntity(HealthCheckReport.class)).thenReturn(createReport(HttpURLConnection.HTTP_OK, false));
Map<String, Object> result2 = callFetchPolicyComponentsHealthStatus();
- assertFalse((Boolean) result2.get("healthy"));
+ assertFalse((Boolean) result2.get(HEALTHY));
HealthCheckReport report2 = (HealthCheckReport) result.get(CLIENT_1);
assertFalse(report2.isHealthy());
}
@SuppressWarnings("unchecked")
@Test
- public void testFetchPolicyComponentsHealthStatus_unhealthyPdps() throws Exception {
+ public void testFetchPolicyComponentsHealthStatus_unhealthyPdps() {
// Get a PDP and set it unhealthy
groups.get(0).getPdpSubgroups().get(0).getPdpInstances().get(0).setHealthy(PdpHealthStatus.NOT_HEALTHY);
Map<String, Object> result = callFetchPolicyComponentsHealthStatus();
Map<String, List<Pdp>> pdpListWithType = (Map<String, List<Pdp>>) result.get(PapConstants.POLICY_PDPS);
assertEquals(2, pdpListWithType.size());
- assertFalse((Boolean) result.get("healthy"));
+ assertFalse((Boolean) result.get(HEALTHY));
}
@Test
- public void testFetchPolicyComponentsHealthStatus_unhealthyPap() throws Exception {
+ public void testFetchPolicyComponentsHealthStatus_unhealthyPap() {
when(papActivator.isAlive()).thenReturn(false);
Map<String, Object> result = callFetchPolicyComponentsHealthStatus();
- assertFalse((Boolean) result.get("healthy"));
+ assertFalse((Boolean) result.get(HEALTHY));
HealthCheckReport report = (HealthCheckReport) result.get(PapConstants.POLICY_PAP);
assertFalse(report.isHealthy());
}
- private Map<String, Object> callFetchPolicyComponentsHealthStatus() throws Exception {
- PolicyComponentsHealthCheckProvider provider = new PolicyComponentsHealthCheckProvider(clientFactory);
+ private Map<String, Object> callFetchPolicyComponentsHealthStatus() {
+ PolicyComponentsHealthCheckProvider provider = new PolicyComponentsHealthCheckProvider();
return provider.fetchPolicyComponentsHealthStatus().getRight();
}