use of com.sequenceiq.freeipa.client.healthcheckmodel.CheckResult in project cloudbreak by hortonworks.
the class FreeIpaInstanceHealthDetailsServiceTest method getErrorPayloadWithMixedResults.
private RPCResponse<CheckResult> getErrorPayloadWithMixedResults(String host) {
CheckResult checkResult = new CheckResult();
checkResult.setHost(host);
CheckEntry healthy = new CheckEntry();
healthy.setStatus("HEALTHY");
healthy.setCheckId("hId");
healthy.setPlugin("good");
CheckEntry unhealthy = new CheckEntry();
unhealthy.setStatus("UNHEALTHY");
unhealthy.setCheckId("unhId");
unhealthy.setPlugin("bad");
checkResult.setChecks(List.of(healthy, unhealthy));
PluginStatusEntry healthyPlugin = new PluginStatusEntry();
healthyPlugin.setPlugin("healthyPlugin");
healthyPlugin.setStatus("HEALTHY");
healthyPlugin.setHost(host);
PluginStatusEntry unhealthyPlugin = new PluginStatusEntry();
unhealthyPlugin.setPlugin("unhealthyPlugin");
unhealthyPlugin.setStatus("UNHEALTHY");
unhealthyPlugin.setHost(host);
checkResult.setPluginStats(List.of(healthyPlugin, unhealthyPlugin));
RPCResponse<CheckResult> badResponse;
badResponse = new RPCResponse<>();
badResponse.setResult(checkResult);
RPCMessage message = new RPCMessage();
message.setCode(503);
message.setMessage(JsonUtil.writeValueAsStringSilentSafe(checkResult));
badResponse.setMessages(List.of(message));
return badResponse;
}
use of com.sequenceiq.freeipa.client.healthcheckmodel.CheckResult in project cloudbreak by hortonworks.
the class FreeIpaInstanceHealthDetailsServiceTest method getGoodPayload.
private RPCResponse<CheckResult> getGoodPayload(String host) {
CheckResult checkResult = new CheckResult();
checkResult.setHost(host);
RPCResponse<CheckResult> goodResponse;
goodResponse = new RPCResponse<>();
goodResponse.setResult(checkResult);
RPCMessage message = new RPCMessage();
message.setCode(200);
message.setMessage("success");
goodResponse.setMessages(List.of(message));
return goodResponse;
}
use of com.sequenceiq.freeipa.client.healthcheckmodel.CheckResult in project cloudbreak by hortonworks.
the class FreeipaHealthCheckController method healthCheck.
@RequestMapping("/freeipahealthcheck")
public ResponseEntity<CheckResult> healthCheck(@PathVariable("mock_uuid") String mockUuid) {
SpiDto read = spiStoreService.read(mockUuid.replace(":9443", ""));
Optional<CloudVmMetaDataStatus> first = read.getVmMetaDataStatuses().stream().findFirst();
CheckResult checkResult = new CheckResult();
if (first.isPresent() && first.get().getCloudVmInstanceStatus().getStatus() == InstanceStatus.STARTED) {
checkResult.setHost(first.get().getMetaData().getPublicIp());
checkResult.setStatus("healthy");
return ResponseEntity.ok(checkResult);
}
return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE).build();
}
use of com.sequenceiq.freeipa.client.healthcheckmodel.CheckResult in project cloudbreak by hortonworks.
the class FreeIpaInstanceHealthDetailsServiceTest method getErrorPayload.
private RPCResponse<CheckResult> getErrorPayload(String host) {
CheckResult checkResult = new CheckResult();
checkResult.setHost(host);
RPCResponse<CheckResult> badResponse;
badResponse = new RPCResponse<>();
badResponse.setResult(checkResult);
RPCMessage message = new RPCMessage();
message.setCode(503);
message.setMessage("failure");
badResponse.setMessages(List.of(message));
return badResponse;
}
use of com.sequenceiq.freeipa.client.healthcheckmodel.CheckResult in project cloudbreak by hortonworks.
the class FreeIpaInstanceHealthDetailsServiceTest method testCheckFreeIpaHealthUnhealthyNodeWithFiltering.
@Test
public void testCheckFreeIpaHealthUnhealthyNodeWithFiltering() throws Exception {
FreeIpaHealthCheckClient mockIpaHealthClient = Mockito.mock(FreeIpaHealthCheckClient.class);
Mockito.when(healthCheckAvailabilityChecker.isCdpFreeIpaHeathAgentAvailable(any())).thenReturn(true);
Mockito.when(freeIpaHealthCheckClientFactory.getClient(any(), any())).thenReturn(mockIpaHealthClient);
Mockito.when(mockIpaHealthClient.nodeHealth()).thenReturn(getErrorPayloadWithMixedResults(HOST));
InstanceMetaData instanceMetaData = getInstance();
Stack stack = getStack(Set.of(instanceMetaData));
RPCResponse<Boolean> response = underTest.checkFreeIpaHealth(stack, instanceMetaData);
assertFalse(response.getResult());
assertEquals("node health check", response.getFirstRpcMessage().getName());
CheckResult checkResult = JsonUtil.readValue(response.getFirstRpcMessage().getMessage(), CheckResult.class);
assertEquals(1, checkResult.getChecks().size());
assertEquals("UNHEALTHY", checkResult.getChecks().get(0).getStatus());
assertEquals(1, checkResult.getPluginStats().size());
assertEquals("UNHEALTHY", checkResult.getPluginStats().get(0).getStatus());
assertEquals(HOST, checkResult.getHost());
assertEquals(HOST, checkResult.getPluginStats().get(0).getHost());
}
Aggregations