Search in sources :

Example 6 with FreeIpaHealthCheckClient

use of com.sequenceiq.freeipa.client.FreeIpaHealthCheckClient 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());
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) FreeIpaHealthCheckClient(com.sequenceiq.freeipa.client.FreeIpaHealthCheckClient) CheckResult(com.sequenceiq.freeipa.client.healthcheckmodel.CheckResult) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 7 with FreeIpaHealthCheckClient

use of com.sequenceiq.freeipa.client.FreeIpaHealthCheckClient in project cloudbreak by hortonworks.

the class FreeIpaInstanceHealthDetailsServiceTest method testCheckFreeIpaHealthHealthyNode.

@Test
public void testCheckFreeIpaHealthHealthyNode() 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(getGoodPayload(HOST));
    InstanceMetaData instanceMetaData = getInstance();
    Stack stack = getStack(Set.of(instanceMetaData));
    RPCResponse<Boolean> response = underTest.checkFreeIpaHealth(stack, instanceMetaData);
    Assertions.assertTrue(response.getResult());
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) FreeIpaHealthCheckClient(com.sequenceiq.freeipa.client.FreeIpaHealthCheckClient) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

FreeIpaHealthCheckClient (com.sequenceiq.freeipa.client.FreeIpaHealthCheckClient)7 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)7 Stack (com.sequenceiq.freeipa.entity.Stack)7 Test (org.junit.jupiter.api.Test)7 NodeHealthDetails (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.health.NodeHealthDetails)2 CheckResult (com.sequenceiq.freeipa.client.healthcheckmodel.CheckResult)1