Search in sources :

Example 1 with FreeIpaHealthCheckClient

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

the class FreeIpaInstanceHealthDetailsServiceTest method testCheckFreeIpaHealthUnresponsiveNodeThrows.

@Test
public void testCheckFreeIpaHealthUnresponsiveNodeThrows() 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()).thenThrow(ipaClientException);
    InstanceMetaData instanceMetaData = getInstance();
    Stack stack = getStack(Set.of(instanceMetaData));
    Assert.assertThrows(FreeIpaClientException.class, () -> underTest.checkFreeIpaHealth(stack, instanceMetaData));
}
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)

Example 2 with FreeIpaHealthCheckClient

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

the class FreeIpaInstanceHealthDetailsServiceTest method testGetInstanceHealthDetailsHealthyNode.

@Test
public void testGetInstanceHealthDetailsHealthyNode() 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));
    NodeHealthDetails response = underTest.getInstanceHealthDetails(stack, instanceMetaData);
    assertEquals(InstanceStatus.CREATED, response.getStatus());
    assertEquals(INSTANCE_ID, response.getInstanceId());
    assertEquals(HOST, response.getName());
    Assertions.assertTrue(response.getIssues().isEmpty());
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) FreeIpaHealthCheckClient(com.sequenceiq.freeipa.client.FreeIpaHealthCheckClient) NodeHealthDetails(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.health.NodeHealthDetails) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 3 with FreeIpaHealthCheckClient

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

the class FreeIpaInstanceHealthDetailsServiceTest method testGetInstanceHealthDetailsUnresponsiveNodeThrows.

@Test
public void testGetInstanceHealthDetailsUnresponsiveNodeThrows() 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()).thenThrow(ipaClientException);
    InstanceMetaData instanceMetaData = getInstance();
    Stack stack = getStack(Set.of(instanceMetaData));
    Assert.assertThrows(FreeIpaClientException.class, () -> underTest.getInstanceHealthDetails(stack, instanceMetaData));
}
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)

Example 4 with FreeIpaHealthCheckClient

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

the class FreeIpaInstanceHealthDetailsServiceTest method testGetInstanceHealthDetailsUnhealthyNode.

@Test
public void testGetInstanceHealthDetailsUnhealthyNode() 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(getErrorPayload(HOST));
    InstanceMetaData instanceMetaData = getInstance();
    Stack stack = getStack(Set.of(instanceMetaData));
    NodeHealthDetails response = underTest.getInstanceHealthDetails(stack, instanceMetaData);
    assertEquals(InstanceStatus.UNHEALTHY, response.getStatus());
    assertEquals(INSTANCE_ID, response.getInstanceId());
    assertEquals(HOST, response.getName());
    assertFalse(response.getIssues().isEmpty());
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) FreeIpaHealthCheckClient(com.sequenceiq.freeipa.client.FreeIpaHealthCheckClient) NodeHealthDetails(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.health.NodeHealthDetails) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 5 with FreeIpaHealthCheckClient

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

the class FreeIpaInstanceHealthDetailsServiceTest method testCheckFreeIpaHealthUnhealthyNode.

@Test
public void testCheckFreeIpaHealthUnhealthyNode() 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(getErrorPayload(HOST));
    InstanceMetaData instanceMetaData = getInstance();
    Stack stack = getStack(Set.of(instanceMetaData));
    RPCResponse<Boolean> response = underTest.checkFreeIpaHealth(stack, instanceMetaData);
    assertFalse(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