Search in sources :

Example 76 with Stack

use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.

the class FreeIpaInstanceHealthDetailsServiceTest method getStack.

private Stack getStack(Set<InstanceMetaData> instanceMetaData) {
    Stack stack = new Stack();
    stack.setResourceCrn(ENVIRONMENT_ID);
    InstanceGroup instanceGroup = new InstanceGroup();
    stack.getInstanceGroups().add(instanceGroup);
    instanceGroup.setInstanceGroupType(InstanceGroupType.MASTER);
    instanceGroup.setInstanceMetaData(instanceMetaData);
    return stack;
}
Also used : Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup)

Example 77 with Stack

use of com.sequenceiq.freeipa.entity.Stack 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 78 with Stack

use of com.sequenceiq.freeipa.entity.Stack 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 79 with Stack

use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.

the class FreeIpaInstanceHealthDetailsServiceTest method testCheckFreeIpaHealthThrowsWhenFqdnIsMissing.

@Test
public void testCheckFreeIpaHealthThrowsWhenFqdnIsMissing() {
    Mockito.when(healthCheckAvailabilityChecker.isCdpFreeIpaHeathAgentAvailable(any())).thenReturn(true);
    InstanceMetaData instanceMetaData = getInstance();
    instanceMetaData.setDiscoveryFQDN(null);
    Stack stack = getStack(Set.of(instanceMetaData));
    Assert.assertThrows(FreeIpaClientException.class, () -> underTest.checkFreeIpaHealth(stack, instanceMetaData));
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 80 with Stack

use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.

the class FreeIpaInstanceHealthDetailsServiceTest method testCheckFreeIpaHealthLegacyHealthyNode.

@Test
public void testCheckFreeIpaHealthLegacyHealthyNode() throws Exception {
    FreeIpaClient mockIpaClient = Mockito.mock(FreeIpaClient.class);
    Mockito.when(healthCheckAvailabilityChecker.isCdpFreeIpaHeathAgentAvailable(any())).thenReturn(false);
    Mockito.when(mockIpaClient.getHostname()).thenReturn("test.host");
    Mockito.when(freeIpaClientFactory.getFreeIpaClientForStackForLegacyHealthCheck(any(), any())).thenReturn(mockIpaClient);
    Mockito.when(mockIpaClient.serverConnCheck(anyString(), anyString())).thenReturn(getLegacyGoodPayload(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) FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

Stack (com.sequenceiq.freeipa.entity.Stack)468 Test (org.junit.jupiter.api.Test)237 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)107 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)63 Map (java.util.Map)63 Bean (org.springframework.context.annotation.Bean)50 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)45 StackEvent (com.sequenceiq.freeipa.flow.stack.StackEvent)41 List (java.util.List)37 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)34 Inject (javax.inject.Inject)30 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)29 Collectors (java.util.stream.Collectors)29 Logger (org.slf4j.Logger)29 LoggerFactory (org.slf4j.LoggerFactory)29 Set (java.util.Set)28 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)25 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)25 ImageSettingsRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest)24 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)23