1 package org.openecomp.sdc.ci.tests.execute.devCI;
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNotNull;
5 import static org.junit.Assert.assertTrue;
8 import java.util.stream.Collectors;
10 import org.junit.Rule;
11 import org.junit.rules.TestName;
12 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
13 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
14 import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
15 import org.openecomp.sdc.ci.tests.utils.rest.CommonRestUtils;
16 import org.openecomp.sdc.common.api.Constants;
17 import org.openecomp.sdc.common.api.HealthCheckInfo;
18 import org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckStatus;
19 import org.openecomp.sdc.common.api.HealthCheckWrapper;
20 import org.testng.annotations.Test;
22 import com.google.gson.Gson;
24 public class HealthCheckAPI extends ComponentBaseTest {
27 public static TestName name = new TestName();
29 public HealthCheckAPI() {
30 super(name, HealthCheckAPI.class.getName());
34 public void checkAmdocsHealthCheckAPI() throws Exception {
35 RestResponse healthCheckInfoResponse = CommonRestUtils.getHealthCheck();
36 BaseRestUtils.checkSuccess(healthCheckInfoResponse);
38 Gson gson = new Gson();
39 HealthCheckWrapper healthCheckInfo = gson.fromJson(healthCheckInfoResponse.getResponse(), HealthCheckWrapper.class);
40 assertNotNull("Health check not contains components info", healthCheckInfo.getComponentsInfo());
41 HealthCheckInfo amdocsHC = healthCheckInfo.getComponentsInfo().stream().filter(x -> x.getHealthCheckComponent().equals(Constants.HC_COMPONENT_ON_BOARDING)).findFirst().orElse(null);
42 assertNotNull("Amdocs health check not exists in Health Check info", amdocsHC);
43 assertEquals("Amdocs health check is down", HealthCheckInfo.HealthCheckStatus.UP, amdocsHC.getHealthCheckStatus());
44 assertNotNull("Amdocs componentsInfo not exists in health check", amdocsHC.getComponentsInfo());
45 Map<String, HealthCheckStatus> amdocsHCComponents = amdocsHC.getComponentsInfo().stream().collect(Collectors.toMap(HealthCheckInfo::getHealthCheckComponent, HealthCheckInfo::getHealthCheckStatus));
46 assertNotNull(amdocsHCComponents);
47 assertTrue("Amdocs health check ZU component is down or not exists", amdocsHCComponents.get("ZU") != null && amdocsHCComponents.get("ZU").equals(HealthCheckStatus.UP));
48 assertTrue("Amdocs health check BE component is down or not exists", amdocsHCComponents.get("BE") != null && amdocsHCComponents.get("BE").equals(HealthCheckStatus.UP));
49 assertTrue("Amdocs health check CAS component is down or not exists", amdocsHCComponents.get("CAS") != null && amdocsHCComponents.get("CAS").equals(HealthCheckStatus.UP));
50 assertTrue("Amdocs health check FE component is down or not exists", amdocsHCComponents.get("FE") != null && amdocsHCComponents.get("FE").equals(HealthCheckStatus.UP));
54 public void checkDcaeHealthCheckAPI() throws Exception {
55 RestResponse healthCheckInfoResponse = CommonRestUtils.getHealthCheck();
56 BaseRestUtils.checkSuccess(healthCheckInfoResponse);
58 Gson gson = new Gson();
59 HealthCheckWrapper healthCheckInfo = gson.fromJson(healthCheckInfoResponse.getResponse(), HealthCheckWrapper.class);
60 assertNotNull("Health check not contains components info", healthCheckInfo.getComponentsInfo());
61 HealthCheckInfo dcaeHC = healthCheckInfo.getComponentsInfo().stream().filter(x -> x.getHealthCheckComponent().equals(Constants.HC_COMPONENT_DCAE)).findFirst().orElse(null);
62 assertNotNull("DCAE health check not exists in Health Check info", dcaeHC);
63 assertEquals("DCAE health check is down", HealthCheckInfo.HealthCheckStatus.UP, dcaeHC.getHealthCheckStatus());
64 assertNotNull("DCAE componentsInfo not exists in health check", dcaeHC.getComponentsInfo());
65 Map<String, HealthCheckStatus> dcaeHCComponents = dcaeHC.getComponentsInfo().stream().collect(Collectors.toMap(HealthCheckInfo::getHealthCheckComponent, HealthCheckInfo::getHealthCheckStatus));
66 assertNotNull(dcaeHCComponents);
67 assertTrue("DCAE health check BE component is down or not exists", dcaeHCComponents.get("BE") != null && dcaeHCComponents.get("BE").equals(HealthCheckStatus.UP));
68 assertTrue("DCAE health check FE component is down or not exists", dcaeHCComponents.get("FE") != null && dcaeHCComponents.get("FE").equals(HealthCheckStatus.UP));
72 public void checkCassandraHealthCheck() throws Exception {
73 RestResponse healthCheckInfoResponse = CommonRestUtils.getHealthCheck();
74 BaseRestUtils.checkSuccess(healthCheckInfoResponse);
76 Gson gson = new Gson();
77 HealthCheckWrapper healthCheckInfo = gson.fromJson(healthCheckInfoResponse.getResponse(), HealthCheckWrapper.class);
78 assertNotNull("Health check not contains components info", healthCheckInfo.getComponentsInfo());
79 HealthCheckInfo cassandraHC = healthCheckInfo.getComponentsInfo().stream().filter(x -> x.getHealthCheckComponent().equals(Constants.HC_COMPONENT_CASSANDRA)).findFirst().orElse(null);
80 assertNotNull("Cassandra health check not exists in Health Check info", cassandraHC);
81 assertEquals("Cassandra health check is down", HealthCheckInfo.HealthCheckStatus.UP, cassandraHC.getHealthCheckStatus());